MCPcopy Create free account
hub / github.com/ampproject/amphtml / documentContainsPolyfill

Function documentContainsPolyfill

src/polyfills/document-contains.js:9–15  ·  view source on GitHub ↗

* Polyfill for `document.contains()` method. Notice that according to spec * `document.contains` is inclusionary. * See https://developer.mozilla.org/en-US/docs/Web/API/Node/contains * @param {?Node} node * @return {boolean} * @this {Document}

(node)

Source from the content-addressed store, hash-verified

7 * @this {Document}
8 */
9function documentContainsPolyfill(node) {
10 // Per spec, "contains" method is inclusionary
11 // i.e. `node.contains(node) == true`. However, we still need to test
12 // equality to the document itself.
13 // eslint-disable-next-line local/no-invalid-this
14 return node == this || this.documentElement.contains(node);
15}
16
17/**
18 * Polyfills `HTMLDocument.contains` API.

Callers

nothing calls this directly

Calls 1

containsMethod · 0.45

Tested by

no test coverage detected