pub struct ElementNode {
pub tag_name: String,
pub attributes: HashMap<String, String>,
pub text_content: Option<String>,
pub children: Vec<ElementNode>,
pub index: Option<usize>,
pub is_visible: bool,
pub is_interactive: bool,
pub bounding_box: Option<BoundingBox>,
}Expand description
Represents a DOM element node
Fields§
§tag_name: StringHTML tag name (e.g., “div”, “button”, “input”)
attributes: HashMap<String, String>Element attributes (e.g., id, class, href, etc.)
text_content: Option<String>Text content of the element
children: Vec<ElementNode>Child elements
index: Option<usize>Index assigned to this element (for interactive elements)
is_visible: boolWhether the element is visible in the viewport
is_interactive: boolWhether the element is interactive (clickable, input, etc.)
bounding_box: Option<BoundingBox>Bounding box information (x, y, width, height)
Implementations§
Source§impl ElementNode
impl ElementNode
Sourcepub fn with_attributes(self, attributes: HashMap<String, String>) -> Self
pub fn with_attributes(self, attributes: HashMap<String, String>) -> Self
Builder method: set attributes
Sourcepub fn with_children(self, children: Vec<ElementNode>) -> Self
pub fn with_children(self, children: Vec<ElementNode>) -> Self
Builder method: set children
Sourcepub fn with_index(self, index: usize) -> Self
pub fn with_index(self, index: usize) -> Self
Builder method: set index
Sourcepub fn with_visibility(self, visible: bool) -> Self
pub fn with_visibility(self, visible: bool) -> Self
Builder method: set visibility
Sourcepub fn with_interactivity(self, interactive: bool) -> Self
pub fn with_interactivity(self, interactive: bool) -> Self
Builder method: set interactivity
Sourcepub fn with_bounding_box(self, x: f64, y: f64, width: f64, height: f64) -> Self
pub fn with_bounding_box(self, x: f64, y: f64, width: f64, height: f64) -> Self
Builder method: set bounding box
Sourcepub fn add_attribute(
&mut self,
key: impl Into<String>,
value: impl Into<String>,
)
pub fn add_attribute( &mut self, key: impl Into<String>, value: impl Into<String>, )
Add a single attribute
Sourcepub fn add_child(&mut self, child: ElementNode)
pub fn add_child(&mut self, child: ElementNode)
Add a child element
Sourcepub fn get_attribute(&self, key: &str) -> Option<&String>
pub fn get_attribute(&self, key: &str) -> Option<&String>
Get attribute value by key
Sourcepub fn compute_interactivity(&mut self)
pub fn compute_interactivity(&mut self)
Determine if this element should be considered interactive
Sourcepub fn simplify(&mut self)
pub fn simplify(&mut self)
Simplify element by removing unnecessary children (like scripts, styles)
Sourcepub fn to_simple_string(&self) -> String
pub fn to_simple_string(&self) -> String
Convert to a simplified string representation
Trait Implementations§
Source§impl Clone for ElementNode
impl Clone for ElementNode
Source§fn clone(&self) -> ElementNode
fn clone(&self) -> ElementNode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more