{"version":3,"file":"dom.mjs","names":["attachedRoot","node","getRootNode","parentNode","document","root","composed"],"sources":["../../src/util/dom.ts"],"sourcesContent":["/**\n * Returns:\n * - 'null' if the node is not attached to the DOM\n * - the root node (HTMLDocument | ShadowRoot) otherwise\n */\nexport function attachedRoot (node: Node): null | HTMLDocument | ShadowRoot {\n /* istanbul ignore next */\n if (typeof node.getRootNode !== 'function') {\n // Shadow DOM not supported (IE11), lets find the root of this node\n while (node.parentNode) node = node.parentNode\n\n // The root parent is the document if the node is attached to the DOM\n if (node !== document) return null\n\n return document\n }\n\n const root = node.getRootNode()\n\n // The composed root node is the document if the node is attached to the DOM\n if (root !== document && root.getRootNode({ composed: true }) !== document) return null\n\n return root as HTMLDocument | ShadowRoot\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,YAAYA,CAAEC,IAAU,EAAoC;EAC1E;EACA,IAAI,OAAOA,IAAI,CAACC,WAAW,KAAK,UAAU,EAAE;IAC1C;IACA,OAAOD,IAAI,CAACE,UAAU,EAAEF,IAAI,GAAGA,IAAI,CAACE,UAAU;;IAE9C;IACA,IAAIF,IAAI,KAAKG,QAAQ,EAAE,OAAO,IAAI;IAElC,OAAOA,QAAQ;EACjB;EAEA,MAAMC,IAAI,GAAGJ,IAAI,CAACC,WAAW,CAAC,CAAC;;EAE/B;EACA,IAAIG,IAAI,KAAKD,QAAQ,IAAIC,IAAI,CAACH,WAAW,CAAC;IAAEI,QAAQ,EAAE;EAAK,CAAC,CAAC,KAAKF,QAAQ,EAAE,OAAO,IAAI;EAEvF,OAAOC,IAAI;AACb","ignoreList":[]}