Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

dom-matches

necolas364.2kMIT2.0.0TypeScript support: definitely-typed

Check if a DOM element matches a given selector

browser, dom, element, matches, selector

readme

dom-matches

Build Status

Check if a DOM element matches a given selector.

Installation

npm install dom-matches

API

matches(elem, selector)

  • elem: a DOM node.
  • selector: a CSS selector string.
var matches = require('dom-matches');
var elem = document.querySelector('.foo');

matches(elem, '.foo');
// => true

matches(elem, '.bar');
// => false

Browser support

  • Google Chrome
  • Firefox ESR+
  • Internet Explorer 10+
  • Safari 6+
  • Opera

changelog

=== HEAD

=== 2.0.0 (August 18, 2015)

  • Only touch DOM when the matches function is run.
  • Support IE 10+. Remove IE 9 orphan node fix.

=== 1.0.1 (August 20, 2014)

  • Fallback uses for loop instead of reverse while.

=== 1.0.0 (August 16, 2014)

  • Initial release.