Skip to content

Commit

Permalink
feat: 修改instance为弱引用
Browse files Browse the repository at this point in the history
  • Loading branch information
heiazu committed Jun 24, 2024
1 parent 1de88e5 commit 1857a38
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,26 @@ export class TaroElement<
layer: 0 // 渲染层级
}

public hm_instance: TaroAny
public _hm_instance: TaroAny
public weak_hm_instance: WeakRef<TaroAny>
public use_weak_hm_instance: boolean = true


public get hm_instance(): TaroAny {
if (this.use_weak_hm_instance) {
return this.weak_hm_instance?.deref()
}
return this._hm_instance
}

public set hm_instance(v) {
if (this.use_weak_hm_instance) {
this.weak_hm_instance = new WeakRef(v);

Check failure on line 51 in packages/taro-platform-harmony/src/runtime-ets/dom/element/element.ts

View workflow job for this annotation

GitHub Actions / Testing on Node.js 18.x (ubuntu-latest)

Extra semicolon

Check failure on line 51 in packages/taro-platform-harmony/src/runtime-ets/dom/element/element.ts

View workflow job for this annotation

GitHub Actions / Testing on Node.js 20.x (ubuntu-latest)

Extra semicolon

Check failure on line 51 in packages/taro-platform-harmony/src/runtime-ets/dom/element/element.ts

View workflow job for this annotation

GitHub Actions / Testing on Node.js (macos-12)

Extra semicolon

Check failure on line 51 in packages/taro-platform-harmony/src/runtime-ets/dom/element/element.ts

View workflow job for this annotation

GitHub Actions / Testing on Node.js (windows-latest)

Extra semicolon
return
}
this._hm_instance = v
}


public get _instance () {
return this.hm_instance
Expand Down

0 comments on commit 1857a38

Please sign in to comment.