
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
desandro-matches-selector
Advanced tools
The desandro-matches-selector npm package is a utility for checking if a DOM element matches a given CSS selector. It provides a cross-browser solution for the Element.matches() method, ensuring compatibility with older browsers.
Check if an element matches a selector
This feature allows you to check if a specific DOM element matches a given CSS selector. The code sample demonstrates how to use the package to verify if an element with the class 'my-element' matches the selector '.my-element'.
const matchesSelector = require('desandro-matches-selector');
const element = document.querySelector('.my-element');
const isMatch = matchesSelector(element, '.my-element');
console.log(isMatch); // true
The matches-selector package provides similar functionality by offering a cross-browser implementation of the Element.matches() method. It ensures compatibility with older browsers and is a direct alternative to desandro-matches-selector.
The element-matches package is another alternative that provides a polyfill for the Element.matches() method. It aims to offer a consistent API across different browsers, similar to desandro-matches-selector.
matches
/matchesSelector
is pretty hot :fire:, but has vendor-prefix baggage :handbag: :pouch:. This helper function takes care of that, without polyfilling or augmenting Element.prototype
.
matchesSelector( elem, selector );
// for example
matchesSelector( myElem, 'div.my-hawt-selector' );
Download matches-selector.js
Install with Bower: bower install matches-selector
Install with npm: npm install desandro-matches-selector
IE10+, all modern browsers
Use matchesSelector v1 for IE8 and IE9 support.
matchesSelector is released under the MIT license
FAQs
matches/matchesSelector helper
The npm package desandro-matches-selector receives a total of 294,152 weekly downloads. As such, desandro-matches-selector popularity was classified as popular.
We found that desandro-matches-selector demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.