Skip to content

Commit

Permalink
fix(HtmlParser): Do not add parent element for template children
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb committed Dec 8, 2015
1 parent 9850e68 commit 4811dc6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 10 additions & 2 deletions modules/angular2/src/compiler/html_tags.ts
Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions modules/angular2/test/compiler/html_parser_spec.ts
Expand Up @@ -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]]);
Expand Down

0 comments on commit 4811dc6

Please sign in to comment.