Skip to content

Commit db12659

Browse files
Fix: Destroy attached children when destroying a Node (#328)
This never got moved over from the stripping out of ThreadX
2 parents 113d744 + bd1d64e commit db12659

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/core/CoreNode.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,12 +1312,19 @@ export class CoreNode extends EventEmitter {
13121312
this.props.texture = null;
13131313
this.props.shader = this.stage.defShaderCtr;
13141314

1315+
const children = [...this.children];
1316+
for (let i = 0; i < children.length; i++) {
1317+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1318+
children[i]!.destroy();
1319+
}
1320+
// This very action will also remove the node from the parent's children array
1321+
this.parent = null;
1322+
13151323
if (this.rtt) {
13161324
this.stage.renderer.removeRTTNode(this);
13171325
}
13181326

13191327
this.removeAllListeners();
1320-
this.parent = null;
13211328
}
13221329

13231330
renderQuads(renderer: CoreRenderer): void {

0 commit comments

Comments
 (0)