Skip to content

Commit 0a9aac4

Browse files
committed
feat: check attached and isMounted
1 parent 117dc0e commit 0a9aac4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

vue-skia-framework/plugin/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const VSKNode = (name: string) => {
6464
instance._ssw_id = (
6565
parent as ComponentInternalInstanceWithSoftSkiaWASM
6666
)._ssw_id;
67+
instance._ssw_attached = true;
6768

6869
instance._ssw_grouped = (child) => {
6970
core.setAttrBySerde(instance._ssw_id, {
@@ -103,6 +104,7 @@ const VSKNode = (name: string) => {
103104
}
104105
const core = root.ssw;
105106
instance._ssw_id = SelfIncreaseCount.count;
107+
instance._ssw_attached = true;
106108
var parent = instance.parent;
107109
while (!('_ssw_id' in parent)) {
108110
parent = parent.parent;
@@ -208,7 +210,10 @@ const VSKNode = (name: string) => {
208210
while (!('_ssw_id' in parent)) {
209211
parent = parent.parent;
210212
}
211-
core.removeChildFromContainer(child_id, (parent as ComponentInternalInstanceWithSoftSkiaWASM)._ssw_id)
213+
instance._ssw_attached = false;
214+
if ((parent as ComponentInternalInstanceWithSoftSkiaWASM)._ssw_attached && parent.isMounted) {
215+
core.removeChildFromContainer(child_id, (parent as ComponentInternalInstanceWithSoftSkiaWASM)._ssw_id)
216+
}
212217
});
213218

214219
return () => h(name, {}, slots.default?.())

vue-skia-framework/type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { SoftSkiaWASM } from '../soft-skia-wasm/pkg/';
66
export type ComponentInternalInstanceWithSoftSkiaWASM = ComponentInternalInstance & {
77
ssw: SoftSkiaWASM;
88
_ssw_id: number;
9+
_ssw_attached: boolean;
910
_ssw_grouped?: (instance: ComponentInternalInstanceWithSoftSkiaWASM) => void;
1011
_ssw_batchDraw?: () => void;
1112
}

0 commit comments

Comments
 (0)