(id, children, depth)
| 43 | |
| 44 | tree = (() => { |
| 45 | function createSubtree(id, children, depth) { |
| 46 | const el = doc.createElement('div'); |
| 47 | el.id = id; |
| 48 | el.textContent = id; |
| 49 | if (depth > 1) { |
| 50 | for (let i = 0; i < children; i++) { |
| 51 | const child = createSubtree(`${id}-${i + 1}`, children, depth - 1); |
| 52 | el.appendChild(child); |
| 53 | } |
| 54 | } |
| 55 | return el; |
| 56 | } |
| 57 | return createSubtree('T', 4, 4); |
| 58 | })(); |
| 59 |