Pseudo element separator, PostCSS plugin
npm install postcss-pseudoratorPseudo element separator, [PostCSS] plugin.
[PostCSS]: https://github.com/postcss/postcss
If part of comma-separated list of selectors contains unknown pseudo element, browser will ignore the whole block,
including parts it could use.
For example
``css`
.highlight,
.block:focus-within {
background: yellow;
}`
is completely ignored by IE and Edge(EdgeHTML) forhtml`Important information`
To work arount the problem, selector should be separated into two parts, so that browser can pick up one and ignore another:css`
.highlight {
background: yellow;
}
.block:focus-within {
background: yellow;
}
and this is what Pseudorator does for you.
Please note that Pseudorator is not a polyfill for unknown pseudo element.
`html`
npm install postcss postcss-pseudorator --save-dev
Check you project for existed PostCSS config: postcss.config.js"postcss"
in the project root, section in package.jsonpostcss
or in bundle config.
Add the plugin to your PostCSS pipeline, in relatively early stage.
Just before autoprefixer should be a nice place.
`diff`
module.exports = {
plugins: [
+ require('postcss-pseudorator')(...),
require('autoprefixer')
]
}
If you do not use PostCSS, add it according to [official docs]
and set this plugin in settings.
[official docs]: https://github.com/postcss/postcss#usage
- separate: array of pseudo elements which should be separated from others.[":focus-within", ":dir"]
For example: .debug`: boolean. Print out all separated selectors. Default false.
-