main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 2 weeks ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
677 bytes
|
Line | |
---|
1 | import { isShadowRoot } from "./instanceOf.js";
|
---|
2 | export default function contains(parent, child) {
|
---|
3 | var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
|
---|
4 |
|
---|
5 | if (parent.contains(child)) {
|
---|
6 | return true;
|
---|
7 | } // then fallback to custom implementation with Shadow DOM support
|
---|
8 | else if (rootNode && isShadowRoot(rootNode)) {
|
---|
9 | var next = child;
|
---|
10 |
|
---|
11 | do {
|
---|
12 | if (next && parent.isSameNode(next)) {
|
---|
13 | return true;
|
---|
14 | } // $FlowFixMe[prop-missing]: need a better way to handle this...
|
---|
15 |
|
---|
16 |
|
---|
17 | next = next.parentNode || next.host;
|
---|
18 | } while (next);
|
---|
19 | } // Give up, the result is false
|
---|
20 |
|
---|
21 |
|
---|
22 | return false;
|
---|
23 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.