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
@ -157,10 +157,12 @@ export class BindingParser {
|
||||
this._parsePropertyAst(
|
||||
key, binding.value, sourceSpan, valueSpan, targetMatchableAttrs, targetProps);
|
||||
} else {
|
||||
targetMatchableAttrs.push([key, '']);
|
||||
targetMatchableAttrs.push([key, '' /* value */]);
|
||||
// Since this is a literal attribute with no RHS, source span should be
|
||||
// just the key span.
|
||||
this.parseLiteralAttr(
|
||||
key, null, sourceSpan, absoluteValueOffset, undefined, targetMatchableAttrs,
|
||||
targetProps);
|
||||
key, null /* value */, keySpan, absoluteValueOffset, undefined /* valueSpan */,
|
||||
targetMatchableAttrs, targetProps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user