All Downloads are FREE. Search and download functionalities are using the official Maven repository.

.selenide-core.7.3.3.source-code.find-in-shadow-roots.js Maven / Gradle / Ivy

There is a newer version: 7.7.0
Show newest version
(function () {
  function findInShadows(target, shadowRoots, searchContext) {
    if (shadowRoots.length === 0) {
      return Array.from(searchContext.querySelectorAll(target));
    }

    const nextSelector = shadowRoots[0];
    const otherSelectors = shadowRoots.slice(1);
    const nextInnerShadowRoots = Array.from(searchContext.querySelectorAll(nextSelector));
    return nextInnerShadowRoots.map(function (childShadowRoot) {
      return findInShadows(target, otherSelectors, getShadowRoot(childShadowRoot));
    }).flat();
  }

  function getShadowRoot(element) {
    if (!element.shadowRoot) {
      throw Error('The element is not a shadow host or has \'closed\' shadow-dom mode: ' + element);
    }
    return element.shadowRoot;
  }

  function searchContext(element) {
    return !element ? document : (element.shadowRoot || element);
  }

  return findInShadows(arguments[0], arguments[1], searchContext(arguments[2]));
})(...arguments)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy