aboutsummaryrefslogtreecommitdiff
path: root/src/emitter.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/emitter.rs')
-rw-r--r--src/emitter.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/emitter.rs b/src/emitter.rs
index 6d9b60e..e56ddd5 100644
--- a/src/emitter.rs
+++ b/src/emitter.rs
@@ -78,6 +78,11 @@ pub trait Emitter<O> {
/// If the current token is not a doctype, this method may panic.
fn emit_current_doctype(&mut self, offset: O);
+ /// Called after the last [`push_attribute_value`] call for an attribute value.
+ ///
+ /// [`push_attribute_value`]: Self::push_attribute_value
+ fn terminate_attribute_value(&mut self, offset: O) {}
+
/// Assuming the _current token_ is a start tag, set the self-closing flag.
///
/// If the current token is not a start or end tag, this method may panic.
@@ -391,14 +396,14 @@ impl<O: Offset> Emitter<O> for DefaultEmitter<O> {
crate::attr::AttrInternal {
name_offset: offset,
value: String::new(),
- value_offset: O::default(),
+ value_span: O::default()..O::default(),
value_syntax: None,
},
));
}
fn init_attribute_value(&mut self, syntax: AttrValueSyntax, offset: O) {
let (_, current_attribute) = self.current_attribute.as_mut().unwrap();
- current_attribute.value_offset = offset;
+ current_attribute.value_span.start = offset;
current_attribute.value_syntax = Some(syntax);
}
@@ -410,6 +415,12 @@ impl<O: Offset> Emitter<O> for DefaultEmitter<O> {
let current_attr = self.current_attribute.as_mut().unwrap();
current_attr.1.value.push_str(s);
}
+
+ fn terminate_attribute_value(&mut self, offset: O) {
+ let current_attr = self.current_attribute.as_mut().unwrap();
+ current_attr.1.value_span.end = offset;
+ }
+
fn init_doctype_public_id(&mut self, offset: O) {
let Some(Token::Doctype(doctype)) = &mut self.current_token else {
debug_assert!(false);