fix(compiler): source span for microsyntax text att should be key span (#38766)
In a microsyntax expressions, some attributes are not bound after desugaring. For example, ```html <div *ngFor="let item of items"> </div> ``` gets desugared to ```html <ng-template ngFor let-items [ngForOf]="items"> </ngtemplate> ``` In this case, `ngFor` should be a literal attribute with no RHS value. Therefore, its source span should be just the `keySpan` and not the source span of the original template node. This allows language service to precisely pinpoint different spans in a microsyntax to provide accurate information. PR Close #38766
This commit is contained in:

committed by
Andrew Kushnir

parent
19598b47ca
commit
8f349b2375
@ -487,8 +487,9 @@ describe('findNodeAtPosition for microsyntax expression', () => {
|
||||
// <ng-template ngFor let-item [ngForOf]="items">
|
||||
expect(errors).toBe(null);
|
||||
const node = findNodeAtPosition(nodes, position);
|
||||
// TODO: this is currently wrong because it should point to ngFor text
|
||||
// attribute instead of ngForOf bound attribute
|
||||
expect(isTemplateNode(node!)).toBeTrue();
|
||||
expect(node).toBeInstanceOf(t.TextAttribute);
|
||||
expect((node as t.TextAttribute).name).toBe('ngFor');
|
||||
});
|
||||
|
||||
it('should locate not let keyword', () => {
|
||||
|
Reference in New Issue
Block a user