Selectors Level 4, over component values, as
StylesheetParser.parse_component_values/1 returns them: an attribute selector is a []
StylesheetParser.SimpleBlock, and a functional pseudo-class or pseudo-element is a
StylesheetParser.Function, its arguments its component values, except for the pseudo-classes whose
arguments parse here, a StylesheetParser.PseudoClass: :is(), :where(), :not() and the
:nth-*() ones. & is the nesting selector of
CSS Nesting.
Each parser returns what it parsed, or nil, and the component values after it. A selector list parses whole when nothing is after it:
iex> {:ok, values} = StylesheetParser.parse_component_values("nav > a:hover, .button")
iex> {selectors, []} = StylesheetParser.Selector.Parser.selector_list(values)
iex> Enum.map(selectors, &to_string/1)
["nav > a:hover", ".button"]
iex> {:ok, values} = StylesheetParser.parse_component_values("a, #1st")
iex> {[%StylesheetParser.SimpleSelector{value: "a"}], rest} =
...> StylesheetParser.Selector.Parser.selector_list(values)
iex> rest
[comma: ",", whitespace: " ", hash: "#1st"]A nested rule's selectors may be relative, as > a:
iex> {:ok, values} = StylesheetParser.parse_component_values("> a, + b")
iex> {selectors, []} = StylesheetParser.Selector.Parser.relative_selector_list(values)
iex> Enum.map(selectors, &to_string/1)
["> a", "+ b"]
Summary
Functions
The An+B microsyntax, {a, b}, as 2n+1
and odd are {2, 1}. It isn't a token of its own: 2n+1 is a dimension and a number, n-1
an ident, 2n - 1 a dimension, a - and a number.
The <declaration-value> production matches any sequence of one or more tokens, so long as the
sequence does not contain <bad-string-token>, <bad-url-token>, unmatched <)-token>,
<]-token>, or <}-token>, or top-level <semicolon-token> tokens or <delim-token> tokens with
a value of "!". It represents the entirety of what a valid declaration can have as its value.
Functions
The An+B microsyntax, {a, b}, as 2n+1
and odd are {2, 1}. It isn't a token of its own: 2n+1 is a dimension and a number, n-1
an ident, 2n - 1 a dimension, a - and a number.
<attribute-selector> = '[' <wq-name> ']' |
'[' <wq-name> <attr-matcher> [ <string-token> | <ident-token> ] <attr-modifier>? ']'
<complex-selector> = <compound-selector> [ <combinator>? <compound-selector> ]*
<compound-selector> = [ <type-selector>? <subclass-selector>*
[ <pseudo-element-selector> <pseudo-class-selector>* ]* ]!
<compound-selector-list> = <compound-selector>#
The <declaration-value> production matches any sequence of one or more tokens, so long as the
sequence does not contain <bad-string-token>, <bad-url-token>, unmatched <)-token>,
<]-token>, or <}-token>, or top-level <semicolon-token> tokens or <delim-token> tokens with
a value of "!". It represents the entirety of what a valid declaration can have as its value.
<relative-selector> = <combinator>? <complex-selector>A complex selector, its first compound selector after its combinator, as > a is
%ComplexSelector{value: [[{:child_combinator, ">"}, a]]}.
<relative-selector-list> = <relative-selector>#
<selector-list> = <complex-selector-list>
<complex-selector-list> = <complex-selector>#
<simple-selector> = <type-selector> | <subclass-selector>
<simple-selector-list> = <simple-selector>#
<subclass-selector> = <id-selector> | <class-selector> |
<attribute-selector> | <pseudo-class-selector>and the & nesting selector.