MCPcopy
hub / github.com/ampproject/amphtml / scopedQuerySelectionFallback

Function scopedQuerySelectionFallback

src/core/dom/query.js:33–42  ·  view source on GitHub ↗

* Finds all elements that matche `selector`, scoped inside `root` * for user-agents that do not support native scoping. * * This method isn't required for modern builds, can be removed. * TODO(#37136): This will fail if `root` is a `ShadowRoot`. * * @param {Element|ShadowRoot} root * @param {

(root, selector)

Source from the content-addressed store, hash-verified

31 * @return {NodeList}
32 */
33function scopedQuerySelectionFallback(root, selector) {
34 const {classList} = /** @type {Element} */ (root);
35
36 const unique = 'i-amphtml-scoped';
37 classList.add(unique);
38 const scopedSelector = prependSelectorsWith(selector, `.${unique}`);
39 const elements = root./*OK*/ querySelectorAll(scopedSelector);
40 classList.remove(unique);
41 return elements;
42}
43
44/**
45 * Finds the first element that matches `selector`, scoped inside `root`.

Callers 2

scopedQuerySelectorFunction · 0.85
scopedQuerySelectorAllFunction · 0.85

Calls 3

prependSelectorsWithFunction · 0.90
addMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected