From 767356df8d337fc1b19e615cb9f80f85d5103117 Mon Sep 17 00:00:00 2001 From: Kristian Rickert Date: Tue, 11 Aug 2026 23:40:04 -0400 Subject: [PATCH] Return None from value_source_location() for attributes written without a value AttributeOutline::value defaulted to 0..0 for valueless attributes, and iter_attrs inferred "has a value" from `base + value.start` being nonzero. As a result Attribute::value_source_location() returned a zero-length span pointing at the start of the parser's current buffer -- or None, together with the name location, whenever the tag happened to sit at buffer offset 0 -- so the reported spans depended on where the tag fell relative to a write() boundary. Carry value presence explicitly as Option instead of deriving it from the offset. name_source_location() is now always present for parsed attributes, value_source_location() is None for valueless ones, and both are independent of how the input was chunked. Fixes #333. --- CHANGELOG.md | 9 +++ src/parser/lexer/actions.rs | 8 ++- src/parser/lexer/lexeme/token_outline.rs | 3 +- src/parser/tree_builder_simulator/mod.rs | 4 +- src/rewritable_units/tokens/attributes.rs | 22 +++--- src/rewriter/mod.rs | 84 +++++++++++++++++++++++ src/selectors_vm/attribute_matcher.rs | 8 ++- 7 files changed, 121 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad231060..a58e87a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## Unreleased + +- Fixed `Attribute::value_source_location()` returning a bogus span for attributes written + without a value (e.g. `