#[non_exhaustive]pub struct NodeRef(/* private fields */);
Expand description
A reference to an HTML node.
Implementations§
Source§impl NodeRef
impl NodeRef
Sourcepub fn as_element(&self) -> Option<&ElementData>
pub fn as_element(&self) -> Option<&ElementData>
Returns the data of this Node
if it is an Element (aka an HTML tag).
Sourcepub fn as_text(&self) -> Option<&RefCell<StrTendril>>
pub fn as_text(&self) -> Option<&RefCell<StrTendril>>
Returns the text content of this Node
, if it is a NodeData::Text
.
Sourcepub fn parent(&self) -> Option<NodeRef>
pub fn parent(&self) -> Option<NodeRef>
The parent node of this node.
Returns None
if the parent is the root node.
Sourcepub fn next_sibling(&self) -> Option<NodeRef>
pub fn next_sibling(&self) -> Option<NodeRef>
The next sibling node of this node.
Returns None
if this is the last of its siblings.
Sourcepub fn prev_sibling(&self) -> Option<NodeRef>
pub fn prev_sibling(&self) -> Option<NodeRef>
The previous sibling node of this node.
Returns None
if this is the first of its siblings.
Sourcepub fn has_children(&self) -> bool
pub fn has_children(&self) -> bool
Whether this node has children.
Sourcepub fn first_child(&self) -> Option<NodeRef>
pub fn first_child(&self) -> Option<NodeRef>
The first child node of this node.
Returns None
if this node has no children.
Sourcepub fn last_child(&self) -> Option<NodeRef>
pub fn last_child(&self) -> Option<NodeRef>
The last child node of this node.
Returns None
if this node has no children.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NodeRef
impl !RefUnwindSafe for NodeRef
impl !Send for NodeRef
impl !Sync for NodeRef
impl Unpin for NodeRef
impl !UnwindSafe for NodeRef
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