JSPM

element-qsa-scope

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12917
  • Score
    100M100P100Q137656F
  • License CC0-1.0

Return elements matching a selector relative to the current node

Package Exports

  • element-qsa-scope

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (element-qsa-scope) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

QSA Scope

Return elements matching a selector relative to the current node

NPM Version Build Status Licensing Changelog Gitter Chat

QSA Scope is a polyfill for :scope support within QSA methods (#Element.querySelector and #Element.querySelectorAll).

<ul>
    <li><a>Link</a>
        <ul>
            <li><a>Sublink</a></li>
        </ul>
    </li>
</ul>
<script>
li = document.querySelector('ul li')
</script>

By default, QSA methods return any element matching the CSS selector absolutely, similar to the element being matched by #Element.matches.

li.querySelector('li a'); // returns <a>Link</a> due to it technically matching

Adding scope is especially useful when traversing the DOM.

li.querySelector(':scope li a'); // returns <a>Sublink</a> due to its context

Browser compatibility

Browser Native Support Polyfill Support
Android 2.2+
Blackberry 7+
Chrome 27+ 4 - 26
Edge 12+
Firefox 32+ 3.5 - 31
Internet Explorer 8 - 11
Opera 15+ 10 - 14
Opera Mini 5+
Safari (iOS) 3.2 - 8.4
Safari (MacOS) 6.2+ 4 - 6

Test Results

Additional tests were run against the latest 3 versions of browsers, including common outliers such as Internet Explorer 8+ and Safari 6+.

Native Support Polyfilled Support