Skip to main content

validate_selector

Function validate_selector 

Source
pub fn validate_selector(sel: &str) -> Result<(), String>
Expand description

Basic syntactic sanity check for a selector before it is executed.

Returns a human-readable reason when the selector is obviously malformed (unbalanced brackets/parens/quotes), or Ok otherwise. This is a cheap pre-flight only — the browser’s querySelector remains the authority.

§Errors

Returns a description of the malformed part when the selector has unbalanced brackets, parentheses, or quotes.