slicker

The Slick CSS selector parser, just the parser for nodejs / amd / browser as a simple export

Usage no npm install needed!

<script type="module">
  import slicker from 'https://cdn.skypack.dev/slicker';
</script>

README

(Slick is an official MooTools project)

Slicker

Just the Slick parser for nodejs

Slick CSS Selector Parser

Parse a CSS selector string into a JavaScript object

Usage

.parse() selector into object

Parse a CSS Selector String into a Selector Object.

Expects: String

Returns: SelectorObject

var slicker = require('slick');

slicker.parse("#foo > bar.baz") → SelectorObject

SelectorObject format

slicker.parse('#foo > bar.baz');
{
    "raw":"#foo > bar.baz",
    "expressions": [[
        { "combinator":" ", "tag":"*", "id":"foo" },
        { "combinator":">", "tag":"bar", "classList": ["baz"], "classes": [{"value":"baz", "regexp":RegExp }]}
    ]]
}

slicker.parse('h1, h2, ul > li, .things')
{
    "raw": "h1, h2, ul > li, .things",
    "expressions": [
        [{ "combinator":" ", "tag": "h1" }],
        [{ "combinator":" ", "tag": "h2" }],
        [{ "combinator":" ", "tag": "ul" }, { "combinator": ">", "tag": "li" }],
        [{ "combinator":" ", "tag": "*", "classList": ["things"], "classes": [{"value": "things", "regexp":RegExp }] }]
    ]
}