(parent: Element, replaceNode: Element | Element[])
| 100 | |
| 101 | // From https://gist.github.com/developit/f4c67a2ede71dc2fab7f357f39cff28c, modified to be TypeScript compliant |
| 102 | function createRootFragment(parent: Element, replaceNode: Element | Element[]) { |
| 103 | const replaceNodes: Element[] = ([] as Element[]).concat(replaceNode); |
| 104 | const s = replaceNodes[replaceNodes.length - 1].nextSibling; |
| 105 | function insert(c: Node, r: Node | null) { |
| 106 | return parent.insertBefore(c, r || s); |
| 107 | } |
| 108 | return ((parent as any).__k = { |
| 109 | nodeType: 1, |
| 110 | parentNode: parent, |
| 111 | firstChild: replaceNodes[0], |
| 112 | childNodes: replaceNodes, |
| 113 | contains: (c: Node) => parent.contains(c), |
| 114 | insertBefore: insert, |
| 115 | appendChild: (c: Node) => insert(c, null), |
| 116 | removeChild: function (c: Node) { |
| 117 | return parent.removeChild(c); |
| 118 | } |
| 119 | }); |
| 120 | } |
| 121 | |
| 122 | render( |
| 123 | h('div', {}), |
no test coverage detected
searching dependent graphs…