MCPcopy Create free account
hub / github.com/ampproject/amphtml / createSubtree

Function createSubtree

test/unit/core/context/test-node-discover.js:17–28  ·  view source on GitHub ↗
(id, children, depth)

Source from the content-addressed store, hash-verified

15
16 tree = (() => {
17 function createSubtree(id, children, depth) {
18 const el = doc.createElement('div');
19 el.id = id;
20 el.textContent = id;
21 if (depth > 1) {
22 for (let i = 0; i < children; i++) {
23 const child = createSubtree(`${id}-${i + 1}`, children, depth - 1);
24 el.appendChild(child);
25 }
26 }
27 return el;
28 }
29 return createSubtree('T', 4, 4);
30 })();
31

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected