pub struct Selector(/* private fields */);Expand description
Parsed CSS selector.
Parsed selector can be used for different element content handlers without a necessity to re-parse CSS selector string for each of them.
§Example
The structure implements the FromStr trait, so it can be constructed through
str’s parse method.
use lol_html::Selector;
let selector: Selector = "#foo".parse().unwrap();§Supported selector
Currently the rewriter supports the following CSS selectors:
| Pattern | Represents |
|---|---|
* | any element |
E | any element of type E |
E:nth-child(n) | an E element, the n-th child of its parent |
E:first-child | an E element, first child of its parent |
E:nth-of-type(n) | an E element, the n-th sibling of its type |
E:first-of-type | an E element, first sibling of its type |
E:not(s) | an E element that does not match either compound selector s |
E.warning | an E element belonging to the class warning |
E#myid | an E element with ID equal to "myid". |
E[foo] | an E element with a foo attribute |
E[foo="bar"] | an E element whose foo attribute value is exactly equal to "bar" |
E[foo="bar" i] | an E element whose foo attribute value is exactly equal to any (ASCII-range) case-permutation of "bar" |
E[foo="bar" s] | an E element whose foo attribute value is exactly and case-sensitively equal to "bar" |
E[foo~="bar"] | an E element whose foo attribute value is a list of whitespace-separated values, one of which is exactly equal to "bar" |
E[foo^="bar"] | an E element whose foo attribute value begins exactly with the string "bar" |
E[foo$="bar"] | an E element whose foo attribute value ends exactly with the string "bar" |
E[foo*="bar"] | an E element whose foo attribute value contains the substring "bar" |
E[foo|=“en”] | an E element whose foo attribute value is a hyphen-separated list of values beginning with "en" |
E F | an F element descendant of an E element |
E > F | an F element child of an E element |
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Selector
impl RefUnwindSafe for Selector
impl Send for Selector
impl Sync for Selector
impl Unpin for Selector
impl UnwindSafe for Selector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more