MCPcopy
hub / github.com/midrender/revideo / spawnChildren

Method spawnChildren

packages/2d/src/lib/components/Node.ts:1288–1309  ·  view source on GitHub ↗
(reactive: boolean, children: ComponentChildren)

Source from the content-addressed store, hash-verified

1286 }
1287
1288 protected spawnChildren(reactive: boolean, children: ComponentChildren) {
1289 const parsedChildren = this.parseChildren(children);
1290
1291 const keep = new Set<string>();
1292 for (const newChild of parsedChildren) {
1293 const current = newChild.parent.context.raw() as Node | null;
1294 if (current && current !== this) {
1295 current.removeChild(newChild);
1296 }
1297 keep.add(newChild.key);
1298 newChild.parent(this);
1299 }
1300
1301 for (const oldChild of this.realChildren) {
1302 if (!keep.has(oldChild.key)) {
1303 oldChild.parent(null);
1304 }
1305 }
1306
1307 this.hasSpawnedChildren = reactive;
1308 this.realChildren = parsedChildren;
1309 }
1310
1311 /**
1312 * Parse any `ComponentChildren` into an array of nodes.

Callers 2

setChildrenMethod · 0.95
spawnedChildrenMethod · 0.95

Calls 4

parseChildrenMethod · 0.95
removeChildMethod · 0.80
addMethod · 0.65
rawMethod · 0.45

Tested by

no test coverage detected