/** * Splits a selector list on top-level commas, ignoring commas inside `(...)`, `[...]`, and quoted strings. */ export declare function splitSelectorList(selector: string): string[]; /** * Whether this parser will read `selector` at all. * * An escape can hide a quote or a bracket from the scanner, and can carry a space of its own - `CSS.escape('1foo')` is * `\\31 foo`, whose trailing space would read as a descendant combinator. A comment can hide a quote too, and so a * combinator. Either would be read as a selector meaning something else entirely, so neither is read at all. */ export declare function isReadableSelector(selector: string): boolean; /** * Throws a `SyntaxError` unless `selector` is one the browser accepts. * * Registered selectors are queried joined into one list, and a list with one invalid part is invalid as a whole, so a * selector is checked before it joins the others. One the browser accepts only by closing what it leaves open * (`[data-x`) passes, and still breaks the list it joins. */ export declare function assertValidSelector(selector: string): void; /** * One simple selector of a compound. Every one carries the `source` it was read from, and concatenating those in order * reproduces the compound exactly, so a caller can rebuild one out of the simple selectors it keeps. * * Names are reported as written, except a pseudo-class's, which is lowercased because CSS matches it case-insensitively * while a tag or attribute name's case can matter (an SVG element keeps `viewBox`, an HTML one lowercases it). A * caller that needs a tag name folded does it itself. * * An attribute's `name` is `null` when the selector namespaces it (`[xlink|href]`), which this parser does not read. A * pseudo's `element` marks the `::` form, and its `argument` is the text between the parens, or `null` when it has * none. */ export type SimpleSelector = { kind: 'tag'; source: string; name: string; } | { kind: 'universal'; source: string; } | { kind: 'id'; source: string; name: string; } | { kind: 'class'; source: string; name: string; } | { kind: 'attribute'; source: string; name: string | null; } | { kind: 'pseudo'; source: string; name: string; element: boolean; argument: string | null; }; /** * The simple selectors of a single compound - a type or universal selector, `#id`, `.class`, `[attribute]` and * pseudo-classes - in source order. `input.a:not(.b)` reads as a tag, a class, and a pseudo-class holding `.b`. * * Returns `null` when the compound is not one this parser can read: an identifier that is missing, a bracket or paren * that is unbalanced, or a combinator, which belongs between compounds rather than inside one. Pass a whole complex * selector through {@link rightmostCompound} first. * * Nothing here decides what a compound *means* - a namespaced attribute keeps its source and loses its name, and a * pseudo-class is reported rather than judged. Callers differ on which of those they can accept, so each reads the * list on its own terms. */ export declare function tokenizeCompound(compound: string): SimpleSelector[] | null; /** * The attribute names whose change on an element can make `selector` start or stop matching it, or `null` when the * selector is not read as a self-contained selector: its match could also change through something other than the * element's own attributes (an ancestor, a sibling, focus, user input), or it uses syntax this parser does not read. */ export declare function selectorAttributes(selector: string): string[] | null; /** * Returns the substring after the last top-level combinator (descendant whitespace, `>`, `+`, `~`), or `null` if the * selector is malformed (unbalanced brackets/parens/quotes). */ export declare function rightmostCompound(selector: string): string | null; /** * One selector per part of `selector`, each matching a superset of that part by depending only on its subject: the * rightmost compound, with pseudo-classes and pseudo-elements dropped. `.open .item:hover, a` becomes * `['.item', 'a']`. Returned as parts rather than one joined selector so a caller combining several selectors can drop * the duplicates between them - the cost of querying with the result grows with the number of parts in it. * * A removed subtree is detached by the time its mutation record is delivered, so the ancestors and siblings an * anchored selector needs are out of reach and querying the selector itself would find nothing. The subject is enough * to enumerate the elements a watcher could have been tracking, which is all a disconnect needs. * * Returns `null` when no such selector exists - a subject of `*` or a bare `:is(...)` has nothing to query on - or for * a selector {@link isReadableSelector} rejects, where the subject read out would mean something else entirely rather * than a superset. Callers fall back to walking every element. */ export declare function subjectSelectors(selector: string): string[] | null; //# sourceMappingURL=selector.d.ts.map