Css-what

css-what

CSS selector parser.

css-what a THE CSS selector parser! Zero dep module that helps you to parse complex CSS selectors.

Get it: npm install css-what

Sample usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const cssWhat = require('css-what');

cssWhat('foo[bar]:baz');

/*~> 
[ [ { type: 'tag', name: 'foo' },
    { type: 'attribute',
      name: 'bar',
      action: 'exists',
      value: '',
      ignoreCase: false },
    { type: 'pseudo',
      name: 'baz',
      data: null } ] ]
*/

The function returns a two-dimensional array. The first dimension represents selectors separated by commas (eg. sub1, sub2), the second contains the relevant tokens for that selector.

GIF FTW!

css-what.gif

Suggest a module

Comments