ranui
Version:
A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.
21 lines (20 loc) • 1.18 kB
TypeScript
import type { DocumentFragmentMock, HTMLElementMock } from './mocks';
export type MockNode = HTMLElementMock | DocumentFragmentMock | string;
/**
* Matches a compound selector such as `slot[name="footer"]` or `div.row#first`.
*
* Every qualifier must match. Supporting only one at a time meant a selector like
* `slot[name="footer"]` fell through to the tag comparison and matched nothing, which broke
* server rendering for any component that located a node that way — silently, because a
* `querySelector` returning null there is usually asserted away with `!`.
*
* Anything the tokenizer cannot consume in full — a descendant combinator, `>`, a
* pseudo-class — returns false rather than matching on the part it understood. A selector
* this engine does not implement should find nothing, not something arbitrary.
*
* @param node The node to test.
* @param selector The selector to match.
* @returns Whether the node matches every part of the selector.
*/
export declare const matchSelector: (node: HTMLElementMock, selector: string) => boolean;
export declare const collectMatches: (nodes: MockNode[], selector: string, result: HTMLElementMock[]) => void;