{ } qjs-modules

parsel

Source: lib/parsel.js (pure JS)

A port of the parsel CSS-selector tokenizer/parser: turns a selector string into a token list / AST and back.

Exports

ExportArgsKindDescription
tokenize(selector, grammar=TOKENS)1–2functionSplits a selector into tokens.
nestTokens(tokens, {list})1–2functionBuilds a nested AST from a flat token list.
parse(selector, {recursive, list})1–2functionTokenizes and nests into a selector AST.
flatten(node, parent)1–2generatorYields [node, parent] pairs walking the AST.
walk(node, visit, parent)2–3functionVisits every AST node with visit(node, parent).
stringify(listOrNode)1functionSerializes an AST back to a selector string.