pub struct Element {
pub name: QualName,
pub attrs: Vec<Attr>,
pub template_contents: Option<NodeId>,
pub mathml_annotation_xml_integration_point: bool,
}Expand description
An element with attributes.
Fields§
§name: QualName§attrs: Vec<Attr>§template_contents: Option<NodeId>For HTML <template> elements, the template contents.
mathml_annotation_xml_integration_point: boolWhether the element is a MathML annotation-xml integration point.
This is set by the parser when an annotation-xml element in the MathML
namespace has an encoding of text/html or application/xhtml+xml
(ASCII case-insensitive), making it an integration point for HTML.
See the HTML parsing spec for “MathML annotation-xml integration points”.
Implementations§
Source§impl Element
impl Element
Sourcepub fn new(
name: QualName,
attrs: Vec<Attribute>,
template_contents: Option<NodeId>,
mathml_annotation_xml_integration_point: bool,
) -> Element
pub fn new( name: QualName, attrs: Vec<Attribute>, template_contents: Option<NodeId>, mathml_annotation_xml_integration_point: bool, ) -> Element
Create a new element.
Sourcepub fn node_name(&self) -> StrTendril
pub fn node_name(&self) -> StrTendril
The name of the node.
Sourcepub fn class(&self) -> Option<StrTendril>
pub fn class(&self) -> Option<StrTendril>
Get the class attribute of the node.
Sourcepub fn id(&self) -> Option<StrTendril>
pub fn id(&self) -> Option<StrTendril>
Get the id attribute of the node.
Sourcepub fn has_class_bytes(
&self,
name: &[u8],
case_sensitivity: CaseSensitivity,
) -> bool
pub fn has_class_bytes( &self, name: &[u8], case_sensitivity: CaseSensitivity, ) -> bool
Whether the element has the given class.
Sourcepub fn remove_class(&mut self, class: &str)
pub fn remove_class(&mut self, class: &str)
Remove a class from the element.
Sourcepub fn attr(&self, name: &str) -> Option<StrTendril>
pub fn attr(&self, name: &str) -> Option<StrTendril>
Gets the specified attribute’s value.
Sourcepub fn remove_attr(&mut self, name: &str)
pub fn remove_attr(&mut self, name: &str)
Removes the specified attribute from the element.
Sourcepub fn remove_attrs(&mut self, names: &[&str])
pub fn remove_attrs(&mut self, names: &[&str])
Removes the specified attributes from the element.
§Arguments
names: A slice of attribute names to remove. Empty slice removes no attributes.
Sourcepub fn retain_attrs(&mut self, names: &[&str])
pub fn retain_attrs(&mut self, names: &[&str])
Retains only the attributes with the specified names.
§Arguments
names: A slice of attribute names to retain. Empty slice retains no attributes.
Sourcepub fn remove_all_attrs(&mut self)
pub fn remove_all_attrs(&mut self)
Removes all attributes from the element.
Sourcepub fn has_attr(&self, name: &str) -> bool
pub fn has_attr(&self, name: &str) -> bool
Checks if the element has an attribute with the name.