use crate::tdom::node::Node;
impl Node {
pub fn get_id(&self) -> Option<&String> {
self.attributes.get("id")
}
pub fn get_class(&self) -> Option<Vec<String>> {
self.attributes
.get("class")
.map(|s| s.split_whitespace().map(str::to_string).collect())
}
pub fn has_class(&self, name: &str) -> bool {
self.get_class()
.is_some_and(|classes| classes.iter().any(|c| c == name))
}
pub fn get_src(&self) -> Option<&String> {
self.attributes.get("src")
}
pub fn get_type(&self) -> Option<&String> {
self.attributes.get("type")
}
pub fn get_width(&self) -> Option<u32> {
self.attributes.get("width").and_then(|v| v.parse().ok())
}
pub fn get_height(&self) -> Option<u32> {
self.attributes.get("height").and_then(|v| v.parse().ok())
}
}