JSPM

element-matches-polyfill

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3910
  • Score
    100M100P100Q126015F
  • License MIT

Element.matches Polyfill

Package Exports

  • element-matches-polyfill

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-matches-polyfill) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

element-matches-polyfill

Polyfill for Element.matches

Provides a polyfill for Element.forEach() to all Browsers.

Native support

See MDN for more information.

Import

// CommonJS
require('element-matches-polyfill');

// ES6 Modules import / Typescript import
import 'element-matches-polyfill';

Usage

<ul id="birds">
  <li>Orange-winged parrot</li>
  <li class="endangered">Philippine eagle</li>
  <li>Great white pelican</li>
</ul>

<script type="text/javascript">
  var birds = document.getElementsByTagName('li');

  for (var i = 0; i < birds.length; i++) {
    if (birds[i].matches('.endangered')) {
      console.log('The ' + birds[i].textContent + ' is endangered!');
    }
  }
</script>