utils/dom/containsnode
module
Functions
containsNode( container, node ) → booleanmodule:utils/dom/containsnode~containsNodeChecks whether
nodeis insidecontainer, looking through shadow roots on the way.Use it instead of
Node#contains(), which stops at a shadow root: that one saysfalseeven whencontainerreally is an ancestor, as long as a shadow root sits between the two. A node contains itself here, just like it does there.containercan also be aDocumentor aShadowRoot– useful for ascrollevent, for example, whose target is the document and not an element. Works with open and closed shadow roots.Parameters
container: NodeThe node that may be the ancestor.
node: Node | nullThe node to look for. May be
null, which always givesfalse.
Returns
boolean