diff --git a/packages/compiler/src/template_parser/binding_parser.ts b/packages/compiler/src/template_parser/binding_parser.ts index 3b0fa60c6d..deec96edce 100644 --- a/packages/compiler/src/template_parser/binding_parser.ts +++ b/packages/compiler/src/template_parser/binding_parser.ts @@ -145,8 +145,9 @@ export class BindingParser { binding.value ? moveParseSourceSpan(sourceSpan, binding.value.span) : undefined; targetVars.push(new ParsedVariable(key, value, bindingSpan, keySpan, valueSpan)); } else if (binding.value) { + const valueSpan = moveParseSourceSpan(sourceSpan, binding.value.ast.sourceSpan); this._parsePropertyAst( - key, binding.value, sourceSpan, undefined, targetMatchableAttrs, targetProps); + key, binding.value, sourceSpan, valueSpan, targetMatchableAttrs, targetProps); } else { targetMatchableAttrs.push([key, '']); this.parseLiteralAttr( diff --git a/packages/compiler/test/render3/r3_ast_spans_spec.ts b/packages/compiler/test/render3/r3_ast_spans_spec.ts index 2352176974..c4553a5a9d 100644 --- a/packages/compiler/test/render3/r3_ast_spans_spec.ts +++ b/packages/compiler/test/render3/r3_ast_spans_spec.ts @@ -232,8 +232,8 @@ describe('R3 AST source spans', () => { expectFromHtml('
').toEqual([ ['Template', '0:32', '0:32', '32:38'], ['TextAttribute', '5:31', ''], - ['BoundAttribute', '5:31', ''], - ['Variable', '13:22', ''], // let item + ['BoundAttribute', '5:31', '25:30'], // *ngFor="let item of items" -> items + ['Variable', '13:22', ''], // let item ['Element', '0:38', '0:32', '32:38'], ]); @@ -245,8 +245,8 @@ describe('R3 AST source spans', () => { // expectFromHtml('
').toEqual([ ['Template', '0:28', '0:28', '28:34'], - ['BoundAttribute', '5:27', ''], - ['BoundAttribute', '5:27', ''], + ['BoundAttribute', '5:27', '13:18'], // ngFor="item of items" -> item + ['BoundAttribute', '5:27', '21:26'], // ngFor="item of items" -> items ['Element', '0:34', '0:28', '28:34'], ]); }); @@ -263,8 +263,8 @@ describe('R3 AST source spans', () => { it('is correct for variables via as ...', () => { expectFromHtml('
').toEqual([ ['Template', '0:27', '0:27', '27:33'], - ['BoundAttribute', '5:26', ''], - ['Variable', '6:25', '6:10'], // ngIf="expr as local -> ngIf + ['BoundAttribute', '5:26', '12:17'], // ngIf="expr as local" -> expr + ['Variable', '6:25', '6:10'], // ngIf="expr as local -> ngIf ['Element', '0:33', '0:27', '27:33'], ]); });