aboutsummaryrefslogtreecommitdiff
path: root/src/emitter.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/emitter.rs')
-rw-r--r--src/emitter.rs23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/emitter.rs b/src/emitter.rs
index aa84215..bb12ca4 100644
--- a/src/emitter.rs
+++ b/src/emitter.rs
@@ -83,6 +83,11 @@ pub trait Emitter<O> {
/// [`push_tag_name`]: Self::push_tag_name
fn terminate_tag_name(&mut self, offset: O) {}
+ /// Called after the last [`push_attribute_name`] call for an attribute name.
+ ///
+ /// [`push_attribute_name`]: Self::push_attribute_name
+ fn terminate_attribute_name(&mut self, offset: O) {}
+
/// Called after the last [`push_attribute_value`] call for an attribute value.
///
/// [`push_attribute_value`]: Self::push_attribute_value
@@ -224,16 +229,14 @@ impl<O> DefaultEmitter<O> {
Entry::Vacant(vacant) => {
vacant.insert(map_val);
}
- Entry::Occupied(entry) => {
- let name_len = entry.key().len();
- self.push_error(Error::DuplicateAttribute, map_val.name_span(name_len));
+ Entry::Occupied(_) => {
+ self.push_error(Error::DuplicateAttribute, map_val.name_span);
}
},
Some(Token::EndTag(_)) => {
- let name_span = map_val.name_span(name.len());
- self.attr_in_end_tag_span = Some(name_span.clone());
+ self.attr_in_end_tag_span = Some(map_val.name_span.clone());
if !self.seen_attributes.insert(name) {
- self.push_error(Error::DuplicateAttribute, name_span);
+ self.push_error(Error::DuplicateAttribute, map_val.name_span);
}
}
_ => {
@@ -420,7 +423,7 @@ impl<O: Offset> Emitter<O> for DefaultEmitter<O> {
self.current_attribute = Some((
String::new(),
crate::attr::AttrInternal {
- name_offset: offset,
+ name_span: offset..O::default(),
value: String::new(),
value_span: O::default()..O::default(),
value_syntax: None,
@@ -437,6 +440,12 @@ impl<O: Offset> Emitter<O> for DefaultEmitter<O> {
let current_attr = self.current_attribute.as_mut().unwrap();
current_attr.0.push_str(s);
}
+
+ fn terminate_attribute_name(&mut self, offset: O) {
+ let current_attr = self.current_attribute.as_mut().unwrap();
+ current_attr.1.name_span.end = offset;
+ }
+
fn push_attribute_value(&mut self, s: &str) {
let current_attr = self.current_attribute.as_mut().unwrap();
current_attr.1.value.push_str(s);