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