fix(HtmlParser): Do not add parent element for template children

fixes #5638
This commit is contained in:
Victor Berchet 2015-12-07 09:41:01 -08:00
parent 9850e68703
commit 3a438615c3
2 changed files with 18 additions and 2 deletions

View File

@ -304,8 +304,16 @@ export class HtmlTagDefinition {
}
requireExtraParent(currentParent: string): boolean {
return isPresent(this.requiredParents) &&
(isBlank(currentParent) || this.requiredParents[currentParent.toLowerCase()] != true);
if (isBlank(this.requiredParents)) {
return false;
}
if (isBlank(currentParent)) {
return true;
}
let lcParent = currentParent.toLowerCase();
return this.requiredParents[lcParent] != true && lcParent != 'template';
}
isClosedByChild(name: string): boolean {

View File

@ -141,6 +141,14 @@ export function main() {
]);
});
it('should not add the requiredParent when the parent is a template', () => {
expect(humanizeDom(parser.parse('<template><tr></tr></template>', 'TestComp')))
.toEqual([
[HtmlElementAst, 'template', 0],
[HtmlElementAst, 'tr', 1],
]);
});
it('should support explicit mamespace', () => {
expect(humanizeDom(parser.parse('<myns:div></myns:div>', 'TestComp')))
.toEqual([[HtmlElementAst, '@myns:div', 0]]);