feat(compiler): Propagate value span of ExpressionBinding to ParsedProperty (#36133)
This commit propagates the correct value span in an ExpressionBinding of a microsyntax expression to ParsedProperty, which in turn porpagates the span to the template ASTs (both VE and Ivy). PR Close #36133
This commit is contained in:
parent
912692137a
commit
d714b95fb9
@ -145,8 +145,9 @@ export class BindingParser {
|
|||||||
binding.value ? moveParseSourceSpan(sourceSpan, binding.value.span) : undefined;
|
binding.value ? moveParseSourceSpan(sourceSpan, binding.value.span) : undefined;
|
||||||
targetVars.push(new ParsedVariable(key, value, bindingSpan, keySpan, valueSpan));
|
targetVars.push(new ParsedVariable(key, value, bindingSpan, keySpan, valueSpan));
|
||||||
} else if (binding.value) {
|
} else if (binding.value) {
|
||||||
|
const valueSpan = moveParseSourceSpan(sourceSpan, binding.value.ast.sourceSpan);
|
||||||
this._parsePropertyAst(
|
this._parsePropertyAst(
|
||||||
key, binding.value, sourceSpan, undefined, targetMatchableAttrs, targetProps);
|
key, binding.value, sourceSpan, valueSpan, targetMatchableAttrs, targetProps);
|
||||||
} else {
|
} else {
|
||||||
targetMatchableAttrs.push([key, '']);
|
targetMatchableAttrs.push([key, '']);
|
||||||
this.parseLiteralAttr(
|
this.parseLiteralAttr(
|
||||||
|
@ -232,8 +232,8 @@ describe('R3 AST source spans', () => {
|
|||||||
expectFromHtml('<div *ngFor="let item of items"></div>').toEqual([
|
expectFromHtml('<div *ngFor="let item of items"></div>').toEqual([
|
||||||
['Template', '0:32', '0:32', '32:38'],
|
['Template', '0:32', '0:32', '32:38'],
|
||||||
['TextAttribute', '5:31', '<empty>'],
|
['TextAttribute', '5:31', '<empty>'],
|
||||||
['BoundAttribute', '5:31', '<empty>'],
|
['BoundAttribute', '5:31', '25:30'], // *ngFor="let item of items" -> items
|
||||||
['Variable', '13:22', '<empty>'], // let item
|
['Variable', '13:22', '<empty>'], // let item
|
||||||
['Element', '0:38', '0:32', '32:38'],
|
['Element', '0:38', '0:32', '32:38'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -245,8 +245,8 @@ describe('R3 AST source spans', () => {
|
|||||||
// </ng-template>
|
// </ng-template>
|
||||||
expectFromHtml('<div *ngFor="item of items"></div>').toEqual([
|
expectFromHtml('<div *ngFor="item of items"></div>').toEqual([
|
||||||
['Template', '0:28', '0:28', '28:34'],
|
['Template', '0:28', '0:28', '28:34'],
|
||||||
['BoundAttribute', '5:27', '<empty>'],
|
['BoundAttribute', '5:27', '13:18'], // ngFor="item of items" -> item
|
||||||
['BoundAttribute', '5:27', '<empty>'],
|
['BoundAttribute', '5:27', '21:26'], // ngFor="item of items" -> items
|
||||||
['Element', '0:34', '0:28', '28:34'],
|
['Element', '0:34', '0:28', '28:34'],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
@ -263,8 +263,8 @@ describe('R3 AST source spans', () => {
|
|||||||
it('is correct for variables via as ...', () => {
|
it('is correct for variables via as ...', () => {
|
||||||
expectFromHtml('<div *ngIf="expr as local"></div>').toEqual([
|
expectFromHtml('<div *ngIf="expr as local"></div>').toEqual([
|
||||||
['Template', '0:27', '0:27', '27:33'],
|
['Template', '0:27', '0:27', '27:33'],
|
||||||
['BoundAttribute', '5:26', '<empty>'],
|
['BoundAttribute', '5:26', '12:17'], // ngIf="expr as local" -> expr
|
||||||
['Variable', '6:25', '6:10'], // ngIf="expr as local -> ngIf
|
['Variable', '6:25', '6:10'], // ngIf="expr as local -> ngIf
|
||||||
['Element', '0:33', '0:27', '27:33'],
|
['Element', '0:33', '0:27', '27:33'],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user