UNPKG

css-tree

Version:

A tool set for CSS: fast detailed parser (CSS → AST), walker (AST traversal), generator (AST → CSS) and lexer (validation and matching) based on specs and browser implementations

36 lines (28 loc) 676 B
import { Comma } from '../../tokenizer/index.js'; export const name = 'SelectorList'; export const walkContext = 'selector'; export const structure = { children: [[ 'Selector', 'Raw' ]] }; export function parse() { const children = this.createList(); while (!this.eof) { children.push(this.Selector()); if (this.tokenType === Comma) { this.next(); continue; } break; } return { type: 'SelectorList', loc: this.getLocationFromList(children), children }; } export function generate(node) { this.children(node, () => this.token(Comma, ',')); }