pub struct ElementRef { /* private fields */ }
Expand description
Wrapper around a reference to an element node.
This wrapper implements the Element
trait from the selectors
crate, which allows
it to be matched against CSS selectors.
Implementations§
Source§impl ElementRef
impl ElementRef
Sourcepub fn wrap(node: NodeRef<Node>) -> Option<Self>
pub fn wrap(node: NodeRef<Node>) -> Option<Self>
Wraps a NodeRef
only if it references a Node::Element
.
Sourcepub fn map_value<F, R>(&self, map_fn: F) -> Option<R>
pub fn map_value<F, R>(&self, map_fn: F) -> Option<R>
Maps a function to the Element
referenced by self
.
Sourcepub fn select(&self, selector: Selector) -> Select ⓘ
pub fn select(&self, selector: Selector) -> Select ⓘ
Returns an iterator over descendent elements matching a selector.
Sourcepub fn inner_html(&self) -> String
pub fn inner_html(&self) -> String
Returns the inner HTML of this element.
Sourcepub fn inner_text(&self) -> String
pub fn inner_text(&self) -> String
Returns all the descendent text nodes content concatenated.
Methods from Deref<Target = NodeRef<Node>>§
Sourcepub fn prev_siblings(&self) -> PrevSiblings<T>
pub fn prev_siblings(&self) -> PrevSiblings<T>
Returns an iterator over previous siblings.
Sourcepub fn next_siblings(&self) -> NextSiblings<T>
pub fn next_siblings(&self) -> NextSiblings<T>
Returns an iterator over next siblings.
Sourcepub fn first_children(&self) -> FirstChildren<T>
pub fn first_children(&self) -> FirstChildren<T>
Returns an iterator over first children.
Sourcepub fn last_children(&self) -> LastChildren<T>
pub fn last_children(&self) -> LastChildren<T>
Returns an iterator over last children.
Sourcepub fn traverse(&self) -> Traverse<T>
pub fn traverse(&self) -> Traverse<T>
Returns an iterator which traverses the subtree starting at this node.
Sourcepub fn descendants(&self) -> Descendants<T>
pub fn descendants(&self) -> Descendants<T>
Returns an iterator over this node and its descendants.
Sourcepub fn map_value<F, R>(&self, map_fn: F) -> Option<R>
pub fn map_value<F, R>(&self, map_fn: F) -> Option<R>
Returns the result of map_fn applied to the value of this node.
Sourcepub fn update_value<F>(&self, update_fn: F) -> bool
pub fn update_value<F>(&self, update_fn: F) -> bool
Update the value of this node.
Sourcepub fn prev_sibling(&self) -> Option<NodeRef<T>>
pub fn prev_sibling(&self) -> Option<NodeRef<T>>
Returns the previous sibling of this node.
Sourcepub fn next_sibling(&self) -> Option<NodeRef<T>>
pub fn next_sibling(&self) -> Option<NodeRef<T>>
Returns the next sibling of this node.
Sourcepub fn first_child(&self) -> Option<NodeRef<T>>
pub fn first_child(&self) -> Option<NodeRef<T>>
Returns the first child of this node.
Sourcepub fn last_child(&self) -> Option<NodeRef<T>>
pub fn last_child(&self) -> Option<NodeRef<T>>
Returns the last child of this node.
Sourcepub fn has_siblings(&self) -> bool
pub fn has_siblings(&self) -> bool
Returns true if this node has siblings.
Sourcepub fn has_children(&self) -> bool
pub fn has_children(&self) -> bool
Returns true if this node has children.
Trait Implementations§
Source§impl Clone for ElementRef
impl Clone for ElementRef
Source§fn clone(&self) -> ElementRef
fn clone(&self) -> ElementRef
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ElementRef
impl Debug for ElementRef
Source§impl Deref for ElementRef
impl Deref for ElementRef
Source§impl Element for ElementRef
Note: will never match against non-tree-structure pseudo-classes.
impl Element for ElementRef
Note: will never match against non-tree-structure pseudo-classes.
type Impl = Simple
Source§fn opaque(&self) -> OpaqueElement
fn opaque(&self) -> OpaqueElement
fn parent_element(&self) -> Option<Self>
Source§fn parent_node_is_shadow_root(&self) -> bool
fn parent_node_is_shadow_root(&self) -> bool
Source§fn containing_shadow_host(&self) -> Option<Self>
fn containing_shadow_host(&self) -> Option<Self>
Source§fn is_pseudo_element(&self) -> bool
fn is_pseudo_element(&self) -> bool
fn is_part(&self, _name: &CssLocalName) -> bool
Source§fn is_same_type(&self, other: &Self) -> bool
fn is_same_type(&self, other: &Self) -> bool
other
element have the same local name and namespace.Source§fn imported_part(&self, _: &CssLocalName) -> Option<CssLocalName>
fn imported_part(&self, _: &CssLocalName) -> Option<CssLocalName>
exportparts
attribute in the reverse
direction, that is, in an outer-tree -> inner-tree direction.Source§fn prev_sibling_element(&self) -> Option<Self>
fn prev_sibling_element(&self) -> Option<Self>
Source§fn next_sibling_element(&self) -> Option<Self>
fn next_sibling_element(&self) -> Option<Self>
Source§fn first_element_child(&self) -> Option<Self>
fn first_element_child(&self) -> Option<Self>
fn is_html_element_in_html_document(&self) -> bool
fn has_local_name(&self, name: &CssLocalName) -> bool
Source§fn has_namespace(&self, namespace: &Namespace) -> bool
fn has_namespace(&self, namespace: &Namespace) -> bool
fn attr_matches( &self, ns: &NamespaceConstraint<&Namespace>, local_name: &CssLocalName, operation: &AttrSelectorOperation<&CssString>, ) -> bool
fn match_non_ts_pseudo_class( &self, _pc: &NonTSPseudoClass, _context: &mut MatchingContext<'_, Self::Impl>, ) -> bool
fn match_pseudo_element( &self, _pe: &PseudoElement, _context: &mut MatchingContext<'_, Self::Impl>, ) -> bool
Source§fn is_html_slot_element(&self) -> bool
fn is_html_slot_element(&self) -> bool
fn has_id(&self, id: &CssLocalName, case_sensitivity: CaseSensitivity) -> bool
fn has_class( &self, name: &CssLocalName, case_sensitivity: CaseSensitivity, ) -> bool
Source§fn is_root(&self) -> bool
fn is_root(&self) -> bool
:root
,
i.e. whether it is the root element of a document. Read more