X Tutup
Skip to content

Commit 194dc7d

Browse files
jeffbcrossvsavkin
authored andcommitted
feat(renderer): use a comment instead of an element when stamping out template>` elements
Originally authored by @tbosch, this reverts the revert commit e274ff8. Closes #4805
1 parent 79399e1 commit 194dc7d

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

modules/angular2/src/platform/dom/debug/debug_element_view_listener.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var _allViewsById = new Map<number, AppView>();
1919
var _nextId = 0;
2020

2121
function _setElementId(element, indices: number[]) {
22-
if (isPresent(element)) {
22+
if (isPresent(element) && DOM.isElementNode(element)) {
2323
DOM.setData(element, NG_ID_PROPERTY, indices.join(NG_ID_SEPARATOR));
2424
}
2525
}

modules/angular2/test/core/linker/integration_spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,19 @@ export function main() {
476476
});
477477
}));
478478

479+
it('should use a comment while stamping out `<template>` elements.',
480+
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
481+
tcb.overrideView(MyComp, new ViewMetadata({template: '<template></template>'}))
482+
483+
.createAsync(MyComp)
484+
.then((fixture) => {
485+
var childNodesOfWrapper = DOM.childNodes(fixture.debugElement.nativeElement);
486+
expect(childNodesOfWrapper.length).toBe(1);
487+
expect(DOM.isCommentNode(childNodesOfWrapper[0])).toBe(true);
488+
async.done();
489+
});
490+
}));
491+
479492
it('should support template directives via `template` attribute.',
480493
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
481494
tcb.overrideView(

modules/benchmarks/e2e_test/naive_infinite_scroll_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('ng2 naive infinite scroll benchmark', function() {
99
it('should not throw errors', function() {
1010
browser.get(URL);
1111
var expectedRowCount = 18;
12-
var expectedCellsPerRow = 28;
12+
var expectedCellsPerRow = 27;
1313
var allScrollItems = 'scroll-app #testArea scroll-item';
1414
var cells = `${ allScrollItems } .row *`;
1515
var stageButtons = `${ allScrollItems } .row stage-buttons button`;

0 commit comments

Comments
 (0)
X Tutup