Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
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
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.