Sha256: 1cb4c866417c5bbb7aa27cdbd5af4b1f7bb86542d2f6becb870daff869d6fdbb

Contents?: true

Size: 765 Bytes

Versions: 12

Compression:

Stored size: 765 Bytes

Contents

/**
 * Module dependencies.
 */

var query = require('query');

/**
 * Element prototype.
 */

var proto = Element.prototype;

/**
 * Vendor function.
 */

var vendor = proto.matches
  || proto.webkitMatchesSelector
  || proto.mozMatchesSelector
  || proto.msMatchesSelector
  || proto.oMatchesSelector;

/**
 * Expose `match()`.
 */

module.exports = match;

/**
 * Match `el` to `selector`.
 *
 * @param {Element} el
 * @param {String} selector
 * @return {Boolean}
 * @api public
 */

function match(el, selector) {
  if (!el || el.nodeType !== 1) return false;
  if (vendor) return vendor.call(el, selector);
  var nodes = query.all(selector, el.parentNode);
  for (var i = 0; i < nodes.length; ++i) {
    if (nodes[i] == el) return true;
  }
  return false;
}

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ende-0.5.22 components/component/matches-selector/0.1.5/index.js
ende-0.5.21 components/component/matches-selector/0.1.5/index.js
ende-0.5.20 components/component/matches-selector/0.1.5/index.js
ende-0.5.19 components/component/matches-selector/0.1.5/index.js
ende-0.5.18 components/component/matches-selector/0.1.5/index.js
ende-0.5.17 components/component/matches-selector/0.1.5/index.js
ende-0.5.16 components/component/matches-selector/0.1.5/index.js
ende-0.5.15 components/component/matches-selector/0.1.5/index.js
ende-0.5.14 components/component/matches-selector/0.1.5/index.js
ende-0.5.13 components/component/matches-selector/0.1.5/index.js
ende-0.5.12 components/component/matches-selector/0.1.5/index.js
ende-0.5.10 components/component/matches-selector/0.1.5/index.js