style-selector
CSS selector constructor
Uses Slick to parse and tokenize the CSS selectors.
Install
Install with npm
npm install --save style-selector
Usage v2
var selector = require('style-selector'),
bodySelector = selector('body', [ 0, 0, 0, 1 ]);
console.log(bodySelector);
console.log(bodySelector.parsed());
console.log(bodySelector.specificity());
Usage v1
var Selector = require('style-selector'),
bodySelector = new Selector('body', [ 0, 0, 0, 1 ]);
console.log(bodySelector);
console.log(bodySelector.parsed());
console.log(bodySelector.specificity());
v2 API
selector(text, spec)
CSS selector constructor
text
Type: String
Default: none
Selector text
spec
Type: Array
Default: none
Optional, precalculated specificity
selector.parsed()
Get parsed selector
selector.specificity()
Lazy specificity getter
v1 API
Selector(text, spec)
CSS selector constructor
text
Type: String
Default: none
Selector text
spec
Type: Array
Default: none
Optional, precalculated specificity
Selector.prototype.parsed()
Get parsed selector
Selector.prototype.specificity()
Lazy specificity getter
Credit
The code for this module was originally taken from the Juice library.
License
MIT