Parser fails on mixed-case end tags for retained SVG desc and title elements
Summary
The parser's retained SVG body scanner compares tag names case-sensitively in Parser.consumeUntilMatchingTag() in src/parser/parser.ts.
For <svg><desc></DESC></svg>, the scanner does not recognize </DESC> as the end of the retained desc element. It consumes the remaining input. The outer discardForeignBody() scan then reaches the end of input without finding the SVG closing tag and throws a parser error.
This issue predates !1473 (merged). Its base commit, bfc95e5d8e0935feef1c07b212e4b1767b30737d, already contains the case-sensitive comparison and the retained SVG scanning path. This conclusion is based on source inspection; no repository code was executed.
Required changes
- Update
Parser.consumeUntilMatchingTag()to match retained SVG tag names case-insensitively. - Keep
svgShouldRetainTag()unchanged. Its exact lowercase check defines which SVG elements are retained. - Add regression coverage in
src/parser/parser.spec.tsfor mixed-case closing tags on retaineddescandtitleelements. - Preserve nesting behavior and correct parsing of elements after the SVG.
Acceptance criteria
<svg><desc></DESC></svg>parses without the scanner exhausting the token stream.- The equivalent retained
titlecase parses successfully. - Retained elements receive correct end-tag metadata and completion events.
- A following HTML sibling remains outside the SVG.
- Existing nested retained SVG behavior remains unchanged.
Context
Requested by @extsidvind as a separate work item, outside the scope of !1473 (merged).
- Merge request: !1473 (merged)
- Review thread: !1473 (comment 4044582949)