(/** @type {HtmlNode} */ node)
| 4776 | }; |
| 4777 | |
| 4778 | const findParent = (/** @type {HtmlNode} */ node) => { |
| 4779 | // search the whole document tree for the parent of node |
| 4780 | /** @type {(HtmlElement | HtmlDocument | HtmlDocumentFragment)[]} */ |
| 4781 | const stack = [doc]; |
| 4782 | while (stack.length) { |
| 4783 | const x = |
| 4784 | /** @type {HtmlElement | HtmlDocument | HtmlDocumentFragment} */ ( |
| 4785 | stack.pop() |
| 4786 | ); |
| 4787 | for (const k of childrenOf(x)) { |
| 4788 | if (k === node) return x; |
| 4789 | if (k.type === NodeType.Element) stack.push(k); |
| 4790 | } |
| 4791 | } |
| 4792 | return null; |
| 4793 | }; |
| 4794 | |
| 4795 | const insertAtPlace = ( |
| 4796 | /** @type {InsertionPlace} */ place, |
no test coverage detected