fix: preserve text content with bindings after void elements#243
Merged
fix: preserve text content with bindings after void elements#243
Conversation
e175859 to
0d8cc20
Compare
4 tasks
mohamedmansour
approved these changes
Apr 16, 2026
Tree-sitter HTML parses void elements like `<br>` with following text
as children of the void element node (e.g., `<br>Part B: {{value2}}`
becomes one element node spanning both the tag and the text). The parser
skipped content processing for void elements since they have no end tag,
which silently dropped any text nodes and bindings that tree-sitter
attached as children.
Process content children for void elements so that text and bindings
following `<br>`, `<hr>`, `<img>`, etc. are correctly emitted as
fragments.
Co-authored-by: Copilot <[email protected]>
0d8cc20 to
ccf3685
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix text nodes and
{{bindings}}being silently dropped when they follow HTML void elements like<br>,<hr>,<img>, etc.Tree-sitter HTML parses void elements with following text as children of the void element node. For example,
<br>Part B: {{value2}}is parsed as a singleelementnode wherePart B: {{value2}}is atextchild of<br>. The parser previously skipped content processing for void elements (since they have no end tag), which caused any text nodes and bindings that tree-sitter attached as children to be silently dropped.The fix adds
process_content_children()for void elements, matching the behavior already used for elements with end tags.Before:
After:
Test Plan
test_text_with_binding_after_void_elementcargo xtask checkpasses (license-headers, fmt, clippy, test)Checklist