Skip to content

fix(parser): end tag names, attribute names and unquoted values like Angular - #760

Merged
Brooooooklyn merged 6 commits into
mainfrom
fix/tag-name-end-like-angular
Dec 5, 2026
Merged

Brooooooklyn merged 6 commits into
mainfrom
fix/tag-name-end-like-angular

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Member

Follow-up to #759. Open tag names, attribute names and unquoted attribute values now end where Angular 22.3.0's lexer ends them.

What changes

Template Angular 22.3.0 Before
<a href=x?a=b> href="x?a", then an attribute with an empty name and value b href="x?a=b"
<div a=b=c> / <div a= =b> a="b" + ""="c" / a="" + ""="b" one attribute
<a=b> <a> with ""="b" tag name a=b
<a"b>c</a> incomplete <a>, text "b>c tag name a"b
<div class=a"b> incomplete <div>, class="a", text "b> value a"b
title={{a}}{{b}} (unquoted) interpolation anywhere in the value: interpolate2 interpolate(a)
*ngIf=a=b, [(ngModel)]=v=w compiles false "assignments" errors

The new name ends exposed three older gaps, fixed here too: a namespace prefix with no name (<a:>, </a:>, <a b:>), entity errors inside a tag (Angular drops them; in <title>/<textarea> text one ends the text), and a bad escape inside a tag in escaped-string templates.

Note: like Angular, <a href=x?a=b> now gets the extra empty-name attribute, so unquoted values with = compile as Angular compiles them.

How it was checked

Differential fuzzing against Angular 22.3.0's lexer (types + parts, spans, errors compared one by one), plain and escaped mode:

inputs   main ≠ Angular → here   real regressions
  31k        4056 →  3704        0
 2.6k         307 →   277        0
  88k       17261 → 13611        0
 259k       59928 → 28725        0
 147k       45635 → 42425        0 (1 luck)
 196k       61136 → 56702        0 (1 luck)
  40k tag   15963 →  3827        0      ← tag / attribute shapes, mostly plain mode

End to end with e2e/compare against Angular's official compiler: 1183/1183 fixtures match, including 6 new ones for these shapes (attribute-name-ends.fixture.ts). Shapes that are compile errors in Angular (<a"b> etc.) are checked in html_parser_angular_errors_test.rs with Angular's messages and spans. cargo test --all-features, NAPI tests (623), cargo fmt --check pass; conformance snapshot unchanged.

Left for later

  • />: our TagOpenEndVoid span includes the /, Angular's covers only > (most of the 3827 left in the tag set; span only).
  • // inside a tag opens a comment in Angular 22; not supported yet.
  • <!b> is a doctype in Angular.

🤖 Generated with Claude Code

Brooooooklyn and others added 6 commits December 5, 2026 00:19
…like Angular

As Angular's `isNameEnd`, a quote and `=` now end an open tag name, and an
unquoted attribute value ends at whitespace, `>`, `<`, `/`, a quote or `=`.
An attribute name may be empty before `=`, so `<a href=x?a=b>` has
`href="x?a"` and `""="b"`, as in Angular. An empty unquoted value always
has its text token, and an interpolation may be anywhere in an unquoted
value, stopping at a name end too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Angular's `_consumePrefixAndName` throws when `prefix:` has no name after
it: `<a:>` is a text `<`, `</a:>` an error at the character after the `:`,
and `<a b:>` an incomplete tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…like Angular

Angular's `_consumeTagOpen` catches the `ParseError` of a bad entity in an
attribute value without reporting it, and keeps the text token before the
entity even when it is empty. In escapable raw text (`<title>`,
`<textarea>`), which it reads after that `try`, the error is reported and
lexing goes on as text from where the entity stopped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In an escaped-string template, Angular's cursor throws when it moves onto
a bad escape inside a tag: in the tag name, an attribute name or value, an
interpolation in a value, or past a quote or the `>`. The token being read
is lost, the tag is left as it is, and lexing goes on as text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`<a href=x?a=b>`, `<a=b>`, `<div a= =b>`, `[title]=y=z` and real-world
unquoted attributes, which now compile like Angular.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Brooooooklyn

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-04T16:55:51.368169Z 4287073 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 428707328c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Brooooooklyn
Brooooooklyn merged commit da939ac into main Dec 5, 2026
10 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/tag-name-end-like-angular branch December 5, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant