Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(renderer): use a comment instead of an element when stamping out…
Browse files Browse the repository at this point in the history
… `<template>` elements

Closes angular#4805
tbosch committed Nov 10, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 64bd963 commit f81fc44
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ var _allViewsById = new Map<number, AppView>();
var _nextId = 0;

function _setElementId(element, indices: number[]) {
if (isPresent(element)) {
if (isPresent(element) && DOM.isElementNode(element)) {
DOM.setData(element, NG_ID_PROPERTY, indices.join(NG_ID_SEPARATOR));
}
}
4 changes: 1 addition & 3 deletions modules/angular2/src/core/render/dom/dom_renderer.ts
Original file line number Diff line number Diff line change
@@ -194,9 +194,7 @@ export abstract class DomRenderer extends Renderer implements NodeFactory<Node>

dehydrateView(viewRef: RenderViewRef) { resolveInternalDomView(viewRef).dehydrate(); }

createTemplateAnchor(attrNameAndValues: string[]): Node {
return this.createElement('script', attrNameAndValues);
}
createTemplateAnchor(attrNameAndValues: string[]): Node { return DOM.createComment('template'); }
abstract createElement(name: string, attrNameAndValues: string[]): Node;
abstract mergeElement(existing: Node, attrNameAndValues: string[]);
abstract createShadowRoot(host: Node, templateId: string): Node;
13 changes: 13 additions & 0 deletions modules/angular2/test/core/linker/integration_spec.ts
Original file line number Diff line number Diff line change
@@ -475,6 +475,19 @@ export function main() {
});
}));

it('should use a comment while stamping out `<template>` elements.',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new ViewMetadata({template: '<template></template>'}))

.createAsync(MyComp)
.then((fixture) => {
var childNodesOfWrapper = DOM.childNodes(fixture.debugElement.nativeElement);
expect(childNodesOfWrapper.length).toBe(1);
expect(DOM.isCommentNode(childNodesOfWrapper[0])).toBe(true);
async.done();
});
}));

it('should support template directives via `template` attribute.',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(

0 comments on commit f81fc44

Please sign in to comment.