Nearsighted Paramecium Multiverse
Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

postcss-pseudoelements

5.0.0 • Public • Published

postcss-pseudoelements

postcss helper for pseudo element colons, it handles double -> single and single -> double.

Usage

Double to Single (default)

var pe = require('postcss-pseudoelements');
var postcss = require('postcss');
var options = {
    single: true, // default
    selectors: ['before','after','first-letter','first-line'], // default
};
 
var processor = postcss(pe(options));
 
console.log(processor.process('a:before {}').css) // outputs: a:before {}
console.log(processor.process('a::before {}').css) // outputs: a:before {}

Single to Double

var pe = require('postcss-pseudoelements');
var postcss = require('postcss');
var options = {
    single: false,
    selectors: ['before','after','first-letter','first-line'], // default
};
 
var processor = postcss(pe(options));
 
console.log(processor.process('a:before {}').css) // outputs: a::before {}
console.log(processor.process('a::before {}').css) // outputs: a::before {}

Options

single: Boolean

  • true (default) if you want to move from double colon to colon for backwards compatibility
  • false if you need double colons

selectors: Array of pseudo-element selectors to rewrite with single and double colons. Note that these values will be used in a regexp without escaping. Defaults to ['before','after','first-letter','first-line']

example selectors:

var options = {
  selectors: [
    'hover',
    'focus',
    'active',
    'after',
    'ms-expand',
    'not',
    'first-child',
    'last-child'
  ],
};

Defaults

var options = {
  single: true,
  [
    'before',
    'after',
    'first-letter',
    'first-line'
  ]
};

Install

npm i postcss-pseudoelements

DownloadsWeekly Downloads

238,724

Version

5.0.0

License

MIT

Last publish

Collaborators

  • avatar