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

Package detail

postcss-pseudoelements

axa-ch608.4kMIT5.0.0

PostCSS plugin to add single-colon CSS 2.1 syntax pseudo selectors (i.e. :before)

postcss, postcss-plugin, pseudoelements, before, after

readme

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'
  ]
};

changelog

2.1.1

  • Remove unused runtime dependency to minimatch
  • Update postcss in test to >=3.0.5

2.1.0

  • Add first-letter and first-line to the default value of the selectors option

2.0.0

  • Output the single colon selectors only, since rules containing double colon selectors are ignored by IE 8

1.0.0

  • Initial version