Skip to content

fix(r3): key spans cover only the binding's name, as Angular's - #615

Open
Rush wants to merge 2 commits into
voidzero-dev:mainfrom
encharm:fix/r3-key-spans
Open

Rush wants to merge 2 commits into
voidzero-dev:mainfrom
encharm:fix/r3-key-spans

Conversation

@Rush

@Rush Rush commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

The R3 transform gave every bound attribute, event and reference the whole attribute name as its key_span ([user]), where Angular's createKeySpan (r3_template_transform.ts) covers only the identifier (user):

Attribute key_span before Angular's
[user]="x" [user] user
(click)="f()" (click) click
[(value)]="v" [(value)] value
bind-prop, on-event, bindon-prop the whole name prop, event, prop
#a, ref-a, let-a the whole name a

Legacy animations drop @ and animate- as binding_parser.ts does. Interpolated attributes keep the whole name, and attr., class. and style. stay in the key, as in Angular. Template attributes and selectorless directives are covered too.

Nothing in the compiler reads key spans, so its output is unchanged; tools built on the R3 AST need them to match Angular's (a template type checker maps diagnostics on bindings through them).

key_span_tests covers bound attributes, bind-/@/animate-, interpolation, events, two-way bindings, references and variables, and template attributes, with expected values from Angular's r3_ast_spans_spec.ts. The conformance suite passes with its snapshot unchanged.

Rush added 2 commits October 22, 2026 10:13
A bound attribute's, event's, reference's or variable's key span is the
identifier without its binding syntax: `user` in `[user]`, `click` in
`(click)`, `prop` in `[(prop)]`, `bind-prop` and `bindon-prop`, `a` in
`#a`, `ref-a` and `let-a`. A legacy animation's `@` or `animate-` is not
part of it either. This follows `createKeySpan` in `parseAttribute`
(r3_template_transform.ts) and the adjustments of `parsePropertyBinding`,
`parseLiteralAttr` and `parseEvent` (binding_parser.ts), for elements and
for selectorless directives. The type checker writes these spans into its
output.
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