Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
matches-selector
Advanced tools
Check if a DOM element matches a given selector, with decent browser support and unit tests.
The matches-selector npm package is a utility that allows you to check if a DOM element matches a given CSS selector. It provides a simple and consistent way to perform this check across different 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 matches-selector package to check if an element with the ID 'myElement' matches the CSS class '.myClass'.
const matchesSelector = require('matches-selector');
const element = document.querySelector('#myElement');
const isMatch = matchesSelector(element, '.myClass');
console.log(isMatch); // true or false
The element-matches package provides similar functionality to matches-selector by allowing you to check if a DOM element matches a given CSS selector. It also ensures compatibility across different browsers.
The matches package is another alternative that offers the same core functionality of checking if a DOM element matches a CSS selector. It is lightweight and straightforward to use, similar to matches-selector.
Check if an element matches a given selector. For use with browserify.
$ npm install matches-selector
var matches = require('matches-selector');
matches(el, 'ul li a');
// => true or false
Tests can be easilly run locally in the browser of your choice, and have passed if it ends with # ok
. They are also run on testling-ci when pushed to the repository:
npm install
npm test
To re-run tests after making changes, just refresh your browser
MIT
FAQs
Check if a DOM element matches a given selector, with decent browser support and unit tests.
The npm package matches-selector receives a total of 99,026 weekly downloads. As such, matches-selector popularity was classified as popular.
We found that 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
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.