Struct accessibility_scraper::element_ref::ElementRef
source · pub struct ElementRef<'a> { /* 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<'a> ElementRef<'a>
impl<'a> ElementRef<'a>
sourcepub fn wrap(node: NodeRef<'a, Node>) -> Option<Self>
pub fn wrap(node: NodeRef<'a, Node>) -> Option<Self>
Wraps a NodeRef
only if it references a Node::Element
.
sourcepub fn select<'b>(&self, selector: &'b Selector) -> Select<'a, 'b> ⓘ
pub fn select<'b>(&self, selector: &'b Selector) -> Select<'a, 'b> ⓘ
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 has_attribute(&self, attr: &str) -> bool
pub fn has_attribute(&self, attr: &str) -> bool
Returns if the element has the attibute and not empty
Methods from Deref<Target = NodeRef<'a, Node>>§
sourcepub fn prev_sibling(&self) -> Option<NodeRef<'a, T>>
pub fn prev_sibling(&self) -> Option<NodeRef<'a, T>>
Returns the previous sibling of this node.
sourcepub fn next_sibling(&self) -> Option<NodeRef<'a, T>>
pub fn next_sibling(&self) -> Option<NodeRef<'a, T>>
Returns the next sibling of this node.
sourcepub fn first_child(&self) -> Option<NodeRef<'a, T>>
pub fn first_child(&self) -> Option<NodeRef<'a, T>>
Returns the first child of this node.
sourcepub fn last_child(&self) -> Option<NodeRef<'a, T>>
pub fn last_child(&self) -> Option<NodeRef<'a, 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.
sourcepub fn prev_siblings(&self) -> PrevSiblings<'a, T>
pub fn prev_siblings(&self) -> PrevSiblings<'a, T>
Returns an iterator over previous siblings.
sourcepub fn next_siblings(&self) -> NextSiblings<'a, T>
pub fn next_siblings(&self) -> NextSiblings<'a, T>
Returns an iterator over next siblings.
sourcepub fn first_children(&self) -> FirstChildren<'a, T>
pub fn first_children(&self) -> FirstChildren<'a, T>
Returns an iterator over first children.
sourcepub fn last_children(&self) -> LastChildren<'a, T>
pub fn last_children(&self) -> LastChildren<'a, T>
Returns an iterator over last children.
sourcepub fn traverse(&self) -> Traverse<'a, T>
pub fn traverse(&self) -> Traverse<'a, T>
Returns an iterator which traverses the subtree starting at this node.
sourcepub fn descendants(&self) -> Descendants<'a, T>
pub fn descendants(&self) -> Descendants<'a, T>
Returns an iterator over this node and its descendants.
Trait Implementations§
source§impl<'a> Clone for ElementRef<'a>
impl<'a> Clone for ElementRef<'a>
source§fn clone(&self) -> ElementRef<'a>
fn clone(&self) -> ElementRef<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a> Debug for ElementRef<'a>
impl<'a> Debug for ElementRef<'a>
source§impl<'a> Deref for ElementRef<'a>
impl<'a> Deref for ElementRef<'a>
source§impl<'a> Element for ElementRef<'a>
impl<'a> Element for ElementRef<'a>
Note: will never match against non-tree-structure pseudo-classes.
type Impl = Simple
fn is_part(&self, _name: &LocalName) -> bool
source§fn imported_part(&self, _: &LocalName) -> Option<LocalName>
fn imported_part(&self, _: &LocalName) -> Option<LocalName>
exportparts
attribute in the reverse
direction, that is, in an outer-tree -> inner-tree direction.source§fn exported_part(&self, _: &LocalName) -> Option<LocalName>
fn exported_part(&self, _: &LocalName) -> Option<LocalName>
exportparts
attribute in the regular
direction, that is, inner-tree -> outer-tree.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 is_pseudo_element(&self) -> bool
fn is_pseudo_element(&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
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 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>
fn is_html_element_in_html_document(&self) -> bool
fn attr_matches( &self, ns: &NamespaceConstraint<&Namespace>, local_name: &CssLocalName, operation: &AttrSelectorOperation<&CssString>, ) -> bool
fn match_non_ts_pseudo_class<F>( &self, pseudo_class: &NonTSPseudoClass, _context: &mut MatchingContext<'_, Self::Impl>, _flags_setter: &mut F, ) -> 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 moresource§fn pseudo_element_originating_element(&self) -> Option<Self>
fn pseudo_element_originating_element(&self) -> Option<Self>
source§fn assigned_slot(&self) -> Option<Self>
fn assigned_slot(&self) -> Option<Self>
source§fn ignores_nth_child_selectors(&self) -> bool
fn ignores_nth_child_selectors(&self) -> bool
source§impl<'a> PartialEq for ElementRef<'a>
impl<'a> PartialEq for ElementRef<'a>
source§fn eq(&self, other: &ElementRef<'a>) -> bool
fn eq(&self, other: &ElementRef<'a>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a> Serialize for ElementRef<'a>
impl<'a> Serialize for ElementRef<'a>
source§fn serialize<S: Serializer>(
&self,
serializer: &mut S,
traversal_scope: TraversalScope,
) -> Result<(), Error>
fn serialize<S: Serializer>( &self, serializer: &mut S, traversal_scope: TraversalScope, ) -> Result<(), Error>
impl<'a> Copy for ElementRef<'a>
impl<'a> Eq for ElementRef<'a>
impl<'a> StructuralPartialEq for ElementRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for ElementRef<'a>
impl<'a> !RefUnwindSafe for ElementRef<'a>
impl<'a> Send for ElementRef<'a>
impl<'a> Sync for ElementRef<'a>
impl<'a> Unpin for ElementRef<'a>
impl<'a> !UnwindSafe for ElementRef<'a>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)