Use lol_html's on_end_tag convenience method - #137
Merged
Conversation
lol_html 2.8 added Element::on_end_tag, which collapses end_tag_handlers().unwrap().push(Box::new(...)) into a single call and surfaces a typed error for void elements instead of panicking. Replaces the three call sites in the rewriter and sanitizer. Two of them silently ignore the void-element error to preserve the previous behavior (selma's self_closing list and lol_html's void list don't fully overlap, e.g. SVG <path>); the user-facing on_end_tag dispatch in process_element_handlers propagates the error as a magnus RuntimeError so callers wiring on_end_tag to a void selector get a clear message. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
el.end_tag_handlers().unwrap().push(Box::new(...))call sites inrewriter.rsandsanitizer.rswith the newElement::on_end_tagconvenience added in lol_html 2.8.process_element_handlersnow surfaces lol_html's"<tag> can't have content"error as a magnusRuntimeErrorinstead of panicking via.unwrap(). The two internal call sites continue to swallow the void-element case to preserve prior behavior (selma'sself_closingtable and lol_html's void-element list don't fully overlap — e.g. SVG<path>).Test plan
bundle exec rake compilebundle exec rake test— 201 runs, 975 assertions, 0 failures