postcss-tags-without-class

1.0.1 • Public • Published

postcss-tags-without-class

Applies tag selectors only if no class is present on the tag.

Only Style Pure Tags

button {
    color: red;
}
<button>I'm red.</button>
<button class="opt-out">I'm still black.</button>

Installation and Usage

npm i postcss postcss-tags-without-class
const postcss = require('postcss')
const tagsWithoutClass = require('postcss-tags-without-class')
 
postcss([tagsWithoutClass]).process('button {color: red;}').then(result => {
    const transformedCSS = result.css
 
    transformedCSS === 'button:not([class]){color: red;}' // true
})

How?

This plugin will add :not([class]) to each tag. Multiple tags button, a, chained tags ul li and tags with pseudo classes button:focus are supported as well.

button {}
 
button,
a {}
 
button:focus {}
 
a span {}

will become

button:not([class]) {}
 
button:not([class]),
a:not([class]) {}
 
button:not([class]):focus {}
 
a:not([class]) span:not([class]) {}

License

MIT

Package Sidebar

Install

npm i postcss-tags-without-class

Weekly Downloads

4

Version

1.0.1

License

MIT

Unpacked Size

2.19 kB

Total Files

3

Last publish

Collaborators

  • naminho
  • tobua