Skip to main content

selector_to_web

Function selector_to_web 

Source
pub fn selector_to_web(sel: &SelectorBuf, names: &WebNames<'_>) -> String
Expand description

Serialize a compiled SelectorBuf as the selector that picks the same elements out of an emitted HTML document.

Three things change and nothing else does. A tag becomes the class the document carries it as, wrapped in :where() so it keeps contributing nothing to specificity: Lumen orders a tag rule under a class rule, and without the wrapper the shift from row to .lm-row would invert that. The four states the browser has no selector for become the attributes the runtime mirrors them onto. :checked and :disabled become :is(<the real one>, <the mirror>), because a real checkbox is checked in the browser’s own eyes and a <toggle> is not.

A <checkbox> and a <radio> are two elements here, a row around the control the browser draws, so a selector for one of them says which of the two it means: the checked state moves to the control, the way it routes into the indicator’s fill on the desktop, and focus is read through the row, because the browser focuses the control inside it.

Everything else, structural pseudo-classes and selector-list arguments included, is the same text selector_to_css writes.