Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

postcss-selector-not

csstools17.8mMIT8.0.1TypeScript support: included

PostCSS plugin to transform :not() W3C CSS level 4 pseudo class to :not() CSS level 3 selectors

Not, postcss, postcss-plugin, selector

readme

PostCSS Selector Not PostCSS Logo

npm install postcss-selector-not --save-dev

PostCSS Selector Not transforms :not() W3C CSS level 4 pseudo classes to :not() CSS level 3 selectors following the Selectors 4 Specification.

p:not(:first-child, .special) {
    color: red;
}

/* becomes */

p:not(:first-child):not(.special) {
    color: red;
}

[!CAUTION] Only lists of simple selectors (:not(.a, .b)) will work as expected. Complex selectors (:not(.a > .b, .c ~ .d)) can not be downgraded.

Usage

Add PostCSS Selector Not to your project:

npm install postcss postcss-selector-not --save-dev

Use it as a PostCSS plugin:

const postcss = require('postcss');
const postcssSelectorNot = require('postcss-selector-not');

postcss([
    postcssSelectorNot(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);

changelog

Changes to PostCSS Selector Not

8.0.1

October 23, 2024

  • Updated: postcss-selector-parser

Full CHANGELOG