MCPcopy
hub / github.com/webpack/webpack / findParent

Function findParent

lib/html/syntax.js:4778–4793  ·  view source on GitHub ↗
(/** @type {HtmlNode} */ node)

Source from the content-addressed store, hash-verified

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,

Callers 3

appropriatePlaceFunction · 0.85
placeForCommonAncestorFunction · 0.85
detachFunction · 0.85

Calls 3

childrenOfFunction · 0.85
popMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected