Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/compiler/src/render3/r3_ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class Element implements Node {
public endSourceSpan: ParseSourceSpan|null, public i18n?: I18nAST) {
// If the element is empty then the source span should include any closing tag
if (children.length === 0 && startSourceSpan && endSourceSpan) {
this.sourceSpan = {...sourceSpan, end: endSourceSpan.end};
this.sourceSpan = new ParseSourceSpan(sourceSpan.start, endSourceSpan.end);
}
}
visit<Result>(visitor: Visitor<Result>): Result { return visitor.visitElement(this); }
Expand Down
10 changes: 10 additions & 0 deletions packages/compiler/test/render3/r3_template_transform_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,17 @@ function expectFromR3Nodes(nodes: t.Node[]) {
return expect(humanizer.result);
}

function expectSpanFromHtml(html: string) {
const {nodes} = parse(html);
return expect(nodes[0] !.sourceSpan.toString());
}

describe('R3 template transform', () => {
describe('ParseSpan on nodes toString', () => {
it('should create valid text span on Element with adjacent start and end tags',
() => { expectSpanFromHtml('<div></div>').toBe('<div></div>'); });
});

describe('Nodes without binding', () => {
it('should parse text nodes', () => {
expectFromHtml('a').toEqual([
Expand Down