release candidate
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "matches-selector",
|
||||
"description": "matches/matchesSelector helper",
|
||||
"main": "matches-selector.js",
|
||||
"devDependencies": {
|
||||
"qunit": "1.x"
|
||||
},
|
||||
"homepage": "https://github.com/desandro/matches-selector",
|
||||
"authors": [
|
||||
"David DeSandro"
|
||||
],
|
||||
"moduleType": [
|
||||
"amd",
|
||||
"globals",
|
||||
"node"
|
||||
],
|
||||
"keywords": [
|
||||
"DOM",
|
||||
"matchesSelector",
|
||||
"matches"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests",
|
||||
"tests.*",
|
||||
"package.json"
|
||||
],
|
||||
"version": "2.0.2",
|
||||
"_release": "2.0.2",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v2.0.2",
|
||||
"commit": "1e7d535ee374ff0823f7232ca1fe2b4ac8e56ae9"
|
||||
},
|
||||
"_source": "https://github.com/desandro/matches-selector.git",
|
||||
"_target": "^2.0.0",
|
||||
"_originalSource": "desandro-matches-selector"
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
# matchesSelector helper
|
||||
|
||||
[`matches`/`matchesSelector`](https://developer.mozilla.org/en-US/docs/Web/API/Element/matches) is pretty hot :fire:, but has [vendor-prefix baggage](http://caniuse.com/#feat=matchesselector) :handbag: :pouch:. This helper function takes care of that, without polyfilling or augmenting `Element.prototype`.
|
||||
|
||||
``` js
|
||||
matchesSelector( elem, selector );
|
||||
// for example
|
||||
matchesSelector( myElem, 'div.my-hawt-selector' );
|
||||
```
|
||||
|
||||
## Install
|
||||
|
||||
Download [matches-selector.js](https://github.com/desandro/matches-selector/raw/master/matches-selector.js)
|
||||
|
||||
Install with [Bower](http://bower.io): `bower install matches-selector`
|
||||
|
||||
[Install with npm](https://www.npmjs.org/package/desandro-matches-selector): `npm install desandro-matches-selector`
|
||||
|
||||
## Browser support
|
||||
|
||||
IE10+, all modern browsers
|
||||
|
||||
Use [matchesSelector v1](https://github.com/desandro/matches-selector/releases/tag/v1.0.3) for IE8 and IE9 support.
|
||||
|
||||
## MIT license
|
||||
|
||||
matchesSelector is released under the [MIT license](http://desandro.mit-license.org)
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "matches-selector",
|
||||
"description": "matches/matchesSelector helper",
|
||||
"main": "matches-selector.js",
|
||||
"devDependencies": {
|
||||
"qunit": "1.x"
|
||||
},
|
||||
"homepage": "https://github.com/desandro/matches-selector",
|
||||
"authors": [
|
||||
"David DeSandro"
|
||||
],
|
||||
"moduleType": [
|
||||
"amd",
|
||||
"globals",
|
||||
"node"
|
||||
],
|
||||
"keywords": [
|
||||
"DOM",
|
||||
"matchesSelector",
|
||||
"matches"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests",
|
||||
"tests.*",
|
||||
"package.json"
|
||||
]
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* matchesSelector v2.0.2
|
||||
* matchesSelector( element, '.selector' )
|
||||
* MIT license
|
||||
*/
|
||||
|
||||
/*jshint browser: true, strict: true, undef: true, unused: true */
|
||||
|
||||
( function( window, factory ) {
|
||||
/*global define: false, module: false */
|
||||
'use strict';
|
||||
// universal module definition
|
||||
if ( typeof define == 'function' && define.amd ) {
|
||||
// AMD
|
||||
define( factory );
|
||||
} else if ( typeof module == 'object' && module.exports ) {
|
||||
// CommonJS
|
||||
module.exports = factory();
|
||||
} else {
|
||||
// browser global
|
||||
window.matchesSelector = factory();
|
||||
}
|
||||
|
||||
}( window, function factory() {
|
||||
'use strict';
|
||||
|
||||
var matchesMethod = ( function() {
|
||||
var ElemProto = window.Element.prototype;
|
||||
// check for the standard method name first
|
||||
if ( ElemProto.matches ) {
|
||||
return 'matches';
|
||||
}
|
||||
// check un-prefixed
|
||||
if ( ElemProto.matchesSelector ) {
|
||||
return 'matchesSelector';
|
||||
}
|
||||
// check vendor prefixes
|
||||
var prefixes = [ 'webkit', 'moz', 'ms', 'o' ];
|
||||
|
||||
for ( var i=0; i < prefixes.length; i++ ) {
|
||||
var prefix = prefixes[i];
|
||||
var method = prefix + 'MatchesSelector';
|
||||
if ( ElemProto[ method ] ) {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
return function matchesSelector( elem, selector ) {
|
||||
return elem[ matchesMethod ]( selector );
|
||||
};
|
||||
|
||||
}));
|
||||
Reference in New Issue
Block a user