Check if an element matches a given selector.
$ component install component/matches-selector
var matches = require('matches-selector');
matches(el, 'ul li a');
// => true
MIT
Check if an element matches a given selector string
@visionmedia @azer @ForbesLindesay can we sort out this madness please?
component/matches-selector is now published on npm in 3 different variants:
From these 3 repos:
They're all (mostly) the same damn code.
Now I'm sure this happened because everyone needed a solution asap, I'm not suggesting anyone screwed up, but can we take a moment to detangle?
Reasonable request?
Hi there,
Thanks for your work on matches-selector
.
When testing some of our React Component that depends on matches-selector
, we got the following exception:
> mocha --compilers js:babel-core/register --timeout 10000 app/assets/javascripts/tests/**/**.spec.js app/assets/javascripts/tests/**/**/**.spec.js
/Users/olivier/Documents/sources/outfit_repos/outfit/node_modules/matches-selector/index.js:3
var proto = Element.prototype;
^
ReferenceError: Element is not defined
at Object.<anonymous> (/Users/olivier/Documents/sources/outfit_repos/outfit/node_modules/matches-selector/index.js:3:13)
at Module._compile (module.js:456:26)
at Module._extensions..js (module.js:474:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/olivier/Documents/sources/outfit_repos/outfit/node_modules/babel-core/lib/api/register/node.js:214:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
The only code I need to write to get this error is:
import matches from 'matches-selector';
It would be awesome if requiring this module on Node land would not raise any exception, same way it is possible to require jQuery (which is also meant for browser environment) without generating exceptions.
Thanks for your feedback guys!
The unprefixed version of this DOM method will be known as just matches()
: http://dev.w3.org/2006/webapi/selectors-api2/#matchtesting
IE has no window.Element.
Element.prototype
will raise error.
when we have a component
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.