pub struct Tree<T> {
pub root: NodeRef<T>,
/* private fields */
}Expand description
Represents a tree with a single root node
Fields§
§root: NodeRef<T>Implementations§
Source§impl Tree<HtmlNodeType>
impl Tree<HtmlNodeType>
Sourcepub fn get_elements_by_tag_name(
&self,
tag_name: &str,
) -> Vec<NodeRef<HtmlNodeType>> ⓘ
pub fn get_elements_by_tag_name( &self, tag_name: &str, ) -> Vec<NodeRef<HtmlNodeType>> ⓘ
Returns all elements with the given tag name
Sourcepub fn get_element_by_id(&self, id: &str) -> Option<NodeRef<HtmlNodeType>>
pub fn get_element_by_id(&self, id: &str) -> Option<NodeRef<HtmlNodeType>>
Returns the element with the given id
Sourcepub fn get_elements_by_class_name(
&self,
class_name: &str,
) -> Vec<NodeRef<HtmlNodeType>> ⓘ
pub fn get_elements_by_class_name( &self, class_name: &str, ) -> Vec<NodeRef<HtmlNodeType>> ⓘ
Returns all elements that have the given class
Sourcepub fn inner_text(node: &NodeRef<HtmlNodeType>) -> String
pub fn inner_text(node: &NodeRef<HtmlNodeType>) -> String
Returns the concatenated text content of this node (including children). Shadow root children are skipped (they are not part of light DOM text).
Sourcepub fn set_text_content(node: &NodeRef<HtmlNodeType>, new_text: &str)
pub fn set_text_content(node: &NodeRef<HtmlNodeType>, new_text: &str)
Replace all text content of this node with the given string
Sourcepub fn collect_text_by_tag(&self, tag_name: &str) -> Vec<String>
pub fn collect_text_by_tag(&self, tag_name: &str) -> Vec<String>
指定したタグ名の要素のテキストノードをすべて集める
Sourcepub fn collect_classic_scripts(&self) -> Vec<ClassicScriptSource>
pub fn collect_classic_scripts(&self) -> Vec<ClassicScriptSource>
Collects classic scripts in document order.
Module scripts and data blocks with a non-JavaScript MIME type are not classic scripts and are ignored here.
Sourcepub fn query_selector(&self, selector: &str) -> Option<NodeRef<HtmlNodeType>>
pub fn query_selector(&self, selector: &str) -> Option<NodeRef<HtmlNodeType>>
Returns the first element matching selector in document order.
Sourcepub fn query_selector_all(&self, selector: &str) -> Vec<NodeRef<HtmlNodeType>> ⓘ
pub fn query_selector_all(&self, selector: &str) -> Vec<NodeRef<HtmlNodeType>> ⓘ
Returns all elements matching selector in document order.
Sourcepub fn query_selector_within(
scope: &NodeRef<HtmlNodeType>,
selector: &str,
) -> Option<NodeRef<HtmlNodeType>>
pub fn query_selector_within( scope: &NodeRef<HtmlNodeType>, selector: &str, ) -> Option<NodeRef<HtmlNodeType>>
Returns the first matching descendant of scope in document order.
The scope element itself is not considered, matching Element’s DOM API.
Sourcepub fn query_selector_all_within(
scope: &NodeRef<HtmlNodeType>,
selector: &str,
) -> Vec<NodeRef<HtmlNodeType>> ⓘ
pub fn query_selector_all_within( scope: &NodeRef<HtmlNodeType>, selector: &str, ) -> Vec<NodeRef<HtmlNodeType>> ⓘ
Returns all matching descendants of scope in document order.
The scope element itself is not included in the result.
Sourcepub fn element_matches_selector(
node: &NodeRef<HtmlNodeType>,
selector: &str,
) -> bool
pub fn element_matches_selector( node: &NodeRef<HtmlNodeType>, selector: &str, ) -> bool
Returns true if the element itself matches the given CSS selector.
Sourcepub fn element_closest(
node: &NodeRef<HtmlNodeType>,
selector: &str,
) -> Option<NodeRef<HtmlNodeType>>
pub fn element_closest( node: &NodeRef<HtmlNodeType>, selector: &str, ) -> Option<NodeRef<HtmlNodeType>>
Walks ancestors starting from node and returns the first ancestor
(including the node itself) that matches the given CSS selector.
Sourcepub fn collect_classic_script_descriptors(&self) -> Vec<ClassicScriptDescriptor>
pub fn collect_classic_script_descriptors(&self) -> Vec<ClassicScriptDescriptor>
Collects classic scripts and their scheduling attributes in document order.
Sourcepub fn collect_inline_scripts(&self) -> Vec<String>
pub fn collect_inline_scripts(&self) -> Vec<String>
Collects only inline classic scripts.
Kept for callers that do not yet fetch external script resources.
Source§impl<T: Clone> Tree<T>
impl<T: Clone> Tree<T>
Sourcepub fn from_root(root: NodeRef<T>) -> Self
pub fn from_root(root: NodeRef<T>) -> Self
Wrap an already-built root in a fresh tree.
The version counter starts at zero, so the resulting tree is treated as a newly parsed document.
Sourcepub fn mark_dirty(&self)
pub fn mark_dirty(&self)
Records a DOM mutation by bumping the tree’s version counter.
Sourcepub fn map<U, F>(&self, f: F) -> Tree<U>
pub fn map<U, F>(&self, f: F) -> Tree<U>
Map each node value to another type, returning a new Tree
Sourcepub fn map_with_node<U, F>(&self, f: F) -> Tree<U>
pub fn map_with_node<U, F>(&self, f: F) -> Tree<U>
Map using the NodeRef itself (for access to parent/children)
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for Tree<T>
impl<T> !RefUnwindSafe for Tree<T>
impl<T> !Send for Tree<T>
impl<T> !Sync for Tree<T>
impl<T> !UnwindSafe for Tree<T>
impl<T> Unpin for Tree<T>
impl<T> UnsafeUnpin for Tree<T>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more