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

Package detail

bo-selector

featurist602.5kBSD0.0.10

CSS selector parser based on jison

css, selector, parser, jison, shamone

readme

bo-selector

A CSS selector parser based on jison

Build Status

Example

var parser = require('bo-selector').parser;
var ast = parser.parse('p:has(.foo), b');
console.log(require('util').inspect(ast, false, null));

Generates

{ type: 'selector_list',
  selectors:
   [ { type: 'selector',
      element:
       { type: 'element',
         name: 'p',
         constraints:
          [ { type: 'pseudo_func',
              func:
               { type: 'function',
                 name: 'has',
                 body:
                  { type: 'selector_list',
                    selectors:
                     [ { type: 'selector',
                         element:
                          { type: 'element',
                            name: '*',
                            constraints: [ { type: 'class', name: 'foo' } ] } } ] } } } ] } },
    { type: 'selector',
      element: { type: 'element', name: 'b', constraints: [] } } ] }

License

BSD