Expand description
Component-scoped CSS for the Style: section — a real tokenizer, not string surgery.
scope stamps the component’s scope class onto the SUBJECT compound of every complex
selector (.card h1 → .card h1.lgx-todos). Every element the component’s own view
renders carries that class (stamped at compile time), and a child component’s elements
do not, so a scoped rule can match only this component’s elements — no wrapper element,
no leakage in either direction. :global(…) opts a compound out of scoping.
Group at-rules (@media, @supports, @container, @layer, @scope,
@starting-style) have a nested RULE LIST for a body, so scoping recurses into them;
every other block at-rule (@keyframes, @font-face, @page, @property, …) passes
through VERBATIM (a keyframe’s 0%/to are offsets, not selectors), and a statement
at-rule (@import …;) is untouched. A prefixed at-rule would be invalid CSS a browser
silently drops — which is why the prelude of an at-rule is never treated as a selector.
Declarations are copied byte for byte; comments are removed.
Every offset an error reports is a byte offset into the stylesheet as written, at any depth: comments are blanked in place rather than cut out, and a group at-rule’s body is parsed at its own position.
Structs§
Enums§
- CssError
Kind - CssItem
- One item of a rule list.
Constants§
- GROUP_
AT_ RULES - Conditional-group at-rules whose body is a nested rule list.
Functions§
- parse_
items - Split a stylesheet into its top-level items (comments removed).
- scope
- scope_
selector - Scope one complex selector: stamp
.classon the last non-:globalcompound and unwrap every:global(…).