Struct html_editor::Selector
source · [−]pub struct Selector { /* private fields */ }Expand description
Simple query selector
Implementations
sourceimpl Selector
impl Selector
sourcepub fn from(selector: &str) -> Self
pub fn from(selector: &str) -> Self
The selector only supports type selector, ID selector and class selector.
For example, div#app, span would be ok, but .container > div,
#app * would get unexpected results.
use html_editor::Selector;
// Ok: Simple tag, class and ID selectors.
let selector = Selector::from("span");
let selector = Selector::from(".class");
let selector = Selector::from("#id");
// Ok: Mixed selector
let selector = Selector::from("div#app");
let selector = Selector::from("span.info#first");
// Disallowed
let selector = Selector::from("div span");
let selector = Selector::from("a[target=_blank]");sourcepub fn matches(&self, element: &Element) -> bool
pub fn matches(&self, element: &Element) -> bool
Check if the element matches the selector.
use html_editor::{Node, Element, Selector};
use html_editor::prelude::*;
let element: Element = Element::new(
"div",
vec![("id", "app")],
vec![Node::Text("Hello World!".to_string())],
);
let selector = Selector::from("div#app");
assert_eq!(selector.matches(&element), true);Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Selector
impl Send for Selector
impl Sync for Selector
impl Unpin for Selector
impl UnwindSafe for Selector
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more