Repository navigation
fix(parser): end tag names, attribute names and unquoted values like Angular - #760
Merged
Merged
Conversation
…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>
Member
Author
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
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.
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
<a href=x?a=b>href="x?a", then an attribute with an empty name and valuebhref="x?a=b"<div a=b=c>/<div a= =b>a="b"+""="c"/a=""+""="b"<a=b><a>with""="b"a=b<a"b>c</a><a>, text"b>ca"b<div class=a"b><div>,class="a", text"b>a"btitle={{a}}{{b}}(unquoted)interpolate2interpolate(a)*ngIf=a=b,[(ngModel)]=v=wThe 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:
End to end with
e2e/compareagainst 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 inhtml_parser_angular_errors_test.rswith Angular's messages and spans.cargo test --all-features, NAPI tests (623),cargo fmt --checkpass; conformance snapshot unchanged.Left for later
/>: ourTagOpenEndVoidspan 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