Skip to content

Leading whitespace in template attributes causes incorrect source span #63157

@reduckted

Description

@reduckted

Which @angular/* package(s) are the source of the bug?

compiler

Is this a regression?

No

Description

Similar to #63069.

When a template's attributes value has leading whitespace, the source span of that value is increased by twice the length of the whitespace.

Using the repository linked below, run npm start. A template will be parsed and the location of the LiteralMap in the template's attributes will be found. It will then print the template and the location of where the LiteralMap was found.

When there is no leading whitespace, the span of the value is correct. With one leading space, the value is reported as being one characters further into the string. With two leading spaces, the value is reported as being two characters further into the string, and so on.

Please provide a link to a minimal reproduction of the bug

https://github.com/reduckted/repro-angular-compiler-whitespace

Please provide the exception or error you saw

<ng-container *ngTemplateOutlet="selector; context: { name: 'test-' + item.id, value: 42 }"/>
____________________________________________________^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^___ : 52-90

<ng-container *ngTemplateOutlet=" selector; context: { name: 'test-' + item.id, value: 42 }"/>
______________________________________________________^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^__ : 54-92

<ng-container *ngTemplateOutlet="  selector; context: { name: 'test-' + item.id, value: 42 }"/>
________________________________________________________^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^_ : 56-94

Please provide the environment you discovered this bug in (run ng version)

@angular/compiler 20.1.7

Anything else?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions