fix(compiler): fixes a bug with top level template directives.

This commit is contained in:
Rado Kirov 2015-01-22 10:26:37 -08:00
parent b4338b623c
commit 5c4238cd41
2 changed files with 13 additions and 1 deletions

View File

@ -72,7 +72,7 @@ export class ViewSplitter extends CompileStep {
}
_addParentElement(currentElement, newParentElement) {
DOM.parentElement(currentElement).insertBefore(newParentElement, currentElement);
DOM.insertBefore(currentElement, newParentElement);
DOM.appendChild(newParentElement, currentElement);
}

View File

@ -59,6 +59,18 @@ export function main() {
expect(results[2].isViewRoot).toBe(true);
});
it('should work with top-level template node', () => {
var rootElement = DOM.createTemplate('<div template>x</div>');
var originalChild = rootElement.content.childNodes[0];
var results = createPipeline().process(rootElement);
expect(results[0].element).toBe(rootElement);
expect(results[0].isViewRoot).toBe(true);
expect(results[2].isViewRoot).toBe(true);
expect(DOM.getOuterHTML(results[0].element)).toEqual('<template><template></template></template>');
expect(results[2].element).toBe(originalChild);
});
it('should add property bindings from the template attribute', () => {
var rootElement = el('<div><div template="prop:expr"></div></div>');
var results = createPipeline().process(rootElement);