
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
normalize-selector
Advanced tools
The normalize-selector npm package is designed to normalize CSS selectors by formatting them into a consistent structure. This can be particularly useful for CSS processing tasks, such as minification, linting, or when implementing CSS-in-JS solutions where consistent selector formatting is crucial. It helps in cleaning up and standardizing selectors by removing unnecessary whitespace, sorting pseudo-classes, and ensuring a uniform structure.
Normalization of CSS Selectors
This feature demonstrates how normalize-selector can take a messy CSS selector string with extra spaces and inconsistent formatting, and normalize it into a clean, standardized format. This is particularly useful for CSS optimization and ensuring consistency across a codebase.
"const normalize = require('normalize-selector');
const normalizedSelector = normalize(' ul > li:first-child ');
console.log(normalizedSelector); // Outputs: 'ul > li:first-child'"
postcss-selector-parser is a parser for CSS selectors that allows for manipulation and stringification of CSS selectors. It provides a more comprehensive API for parsing and manipulating selectors compared to normalize-selector, which focuses solely on normalization.
css-what is a package that parses CSS selectors into an understandable structure (tokens). While it doesn't directly normalize selectors in the same way as normalize-selector, it can be used as part of a toolchain to analyze and potentially reformat selectors.
Normalize CSS selectors.
Examples:
#foo>.bar
-> #foo > .bar
#foo > .bar
-> #foo > .bar
foo[ a = 'b' ]
-> foo[a='b']
Run mocha tests on node.js with:
npm test
or:
node ./test/mocha/node-suite.js
View the browser suite directly on rawgithub
The code and all the documentation are released under the MIT license.
FAQs
Normalize CSS Selectors
The npm package normalize-selector receives a total of 935,024 weekly downloads. As such, normalize-selector popularity was classified as popular.
We found that normalize-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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.