pub enum Node {
Element(Element),
Text(String),
Comment(String),
Doctype(Doctype),
}Expand description
Node of DOM
Variants§
Implementations§
Source§impl Node
impl Node
Sourcepub fn is_element(&self) -> bool
pub fn is_element(&self) -> bool
Check if it is an element node.
use html_editor::Node;
assert_eq!(Node::new_element("div", vec![("id", "app")], vec![]).is_element(), true);
assert_eq!(Node::Text("Lorem Ipsum".to_string()).is_element(), false);pub fn into_element(self) -> Element
👎Deprecated: Please use
is_element insteadSourcepub fn as_element(&self) -> Option<&Element>
pub fn as_element(&self) -> Option<&Element>
Convert the node into an element.
Returns None if the node is not an element.
Example:
use html_editor::{Node, Element};
let a: Node = Node::new_element("div", vec![("id", "app")], vec![]);
assert!(a.as_element().is_some());
let b: Node = Node::Text("hello".to_string());
assert!(b.as_element().is_none());Sourcepub fn as_element_mut(&mut self) -> Option<&mut Element>
pub fn as_element_mut(&mut self) -> Option<&mut Element>
Convert the node into a mutable element.
Returns None if the node is not an element.
Example:
use html_editor::{Node, Element};
let mut a: Node = Node::new_element("div", vec![("id", "app")], vec![]);
assert!(a.as_element_mut().is_some());
let mut b: Node = Node::Text("hello".to_string());
assert!(b.as_element_mut().is_none());Trait Implementations§
Source§impl Htmlifiable for Node
impl Htmlifiable for Node
Source§impl Queryable for Node
impl Queryable for Node
Source§fn query(&self, selector: &Selector) -> Option<&Element>
fn query(&self, selector: &Selector) -> Option<&Element>
Query the node in
self for the given selector. Read moreSource§fn query_all(&self, selector: &Selector) -> Vec<&Element>
fn query_all(&self, selector: &Selector) -> Vec<&Element>
Query all the nodes in
self for the given selector. Read moreAuto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnwindSafe for Node
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