fix(HtmlParser): do not add required parents to template root elements

fixes #5967
This commit is contained in:
Victor Berchet 2016-06-15 09:45:19 -07:00
parent 9ba400d7d5
commit e484c62a8d
2 changed files with 8 additions and 2 deletions

View File

@ -266,7 +266,7 @@ class TreeBuilder {
const tagDef = getHtmlTagDefinition(el.name);
const {parent, container} = this._getParentElementSkippingContainers();
if (tagDef.requireExtraParent(isPresent(parent) ? parent.name : null)) {
if (isPresent(parent) && tagDef.requireExtraParent(parent.name)) {
var newParent = new HtmlElementAst(
tagDef.parentToAdd, [], [], el.sourceSpan, el.startSourceSpan, el.endSourceSpan);
this._insertBeforeContainer(parent, container, newParent);

View File

@ -36,7 +36,6 @@ export function main() {
});
});
describe('elements', () => {
it('should parse root level elements', () => {
expect(humanizeDom(parser.parse('<div></div>', 'TestComp'))).toEqual([
@ -158,6 +157,13 @@ export function main() {
]);
});
// https://github.com/angular/angular/issues/5967
it('should not add the requiredParent to a template root element', () => {
expect(humanizeDom(parser.parse('<tr></tr>', 'TestComp'))).toEqual([
[HtmlElementAst, 'tr', 0],
]);
});
it('should support explicit mamespace', () => {
expect(humanizeDom(parser.parse('<myns:div></myns:div>', 'TestComp'))).toEqual([
[HtmlElementAst, ':myns:div', 0]