postcss-attribute-selector-prefix

0.1.1 • Public • Published

postcss-attribute-selector-prefix

PostCSS plugin adds a namespace/prefix to attribute selector.

Travis Build StatusAppVeyor Build Statusnodenpm versionDependency StatusXO code styleCoveralls status

npm downloadsnpmGreenkeeper badge

Why ?

Needs to escape from the third-party frameworks.

Install

$ npm install postcss-attribute-selector-prefix 

Note: This project is compatible with node v6+

Usage

// Dependencies
var fs = require('fs');
var postcss = require('postcss');
var attrSelectorPrefix = require('postcss-attribute-selector-prefix');
 
// CSS to be processed
var css = fs.readFileSync('css/input.css', 'utf8');
 
// Process css
var output = postcss()
  .use(attrSelectorPrefix({prefix: 'test-'}))
  .process(css)
  .css;
 
console.log(output);

Example

/* input.css */
.class
[type="text"]
[class*="lorem"] {
color:red; 
}
/* Output example */
.class
[type="text"]
[class*="test-lorem"] { 
    color:red; 
}

Options

prefix

Type: string
Default: ``
Description: add prefix to attribute selector

filter

Type: Array
Default: []
Description: attribute selector to which we must add the prefix
Example: ['class', 'id']

/* input.css */
.class
[type="text"]
[class*="lorem"],
[id^="myID"] { 
    color: red; 
}
/* Output example */
.class
[type="text"]
[class*="test-lorem"],
[id^="test-myID"] { 
    color: red; 
}

ignore

Type: Array
Default: []
Description: ignored attribute selector
Example: ['type', 'alt']

/* input.css */
.class
[type="text"]
[alt*="ALT"],
[class*="class"] { 
    color: red; 
}
/* Output example */
.class
[type="text"]
[alt*="ALT"],
[class*="test-class"] { 
    color: red; 
}

Package Sidebar

Install

npm i postcss-attribute-selector-prefix

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

40.7 kB

Total Files

5

Last publish

Collaborators

  • scrum