diff --git a/packages/compiler/src/ml_parser/html_tags.ts b/packages/compiler/src/ml_parser/html_tags.ts index 0b49ab978d..f2dc36a415 100644 --- a/packages/compiler/src/ml_parser/html_tags.ts +++ b/packages/compiler/src/ml_parser/html_tags.ts @@ -12,10 +12,6 @@ export class HtmlTagDefinition implements TagDefinition { private closedByChildren: {[key: string]: boolean} = {}; closedByParent: boolean = false; - // TODO(issue/24571): remove '!'. - requiredParents !: {[key: string]: boolean}; - // TODO(issue/24571): remove '!'. - parentToAdd !: string; implicitNamespacePrefix: string|null; contentType: TagContentType; isVoid: boolean; @@ -23,12 +19,10 @@ export class HtmlTagDefinition implements TagDefinition { canSelfClose: boolean = false; constructor( - {closedByChildren, requiredParents, implicitNamespacePrefix, - contentType = TagContentType.PARSABLE_DATA, closedByParent = false, isVoid = false, - ignoreFirstLf = false}: { + {closedByChildren, implicitNamespacePrefix, contentType = TagContentType.PARSABLE_DATA, + closedByParent = false, isVoid = false, ignoreFirstLf = false}: { closedByChildren?: string[], closedByParent?: boolean, - requiredParents?: string[], implicitNamespacePrefix?: string, contentType?: TagContentType, isVoid?: boolean, @@ -39,31 +33,11 @@ export class HtmlTagDefinition implements TagDefinition { } this.isVoid = isVoid; this.closedByParent = closedByParent || isVoid; - if (requiredParents && requiredParents.length > 0) { - this.requiredParents = {}; - // The first parent is the list is automatically when none of the listed parents are present - this.parentToAdd = requiredParents[0]; - requiredParents.forEach(tagName => this.requiredParents[tagName] = true); - } this.implicitNamespacePrefix = implicitNamespacePrefix || null; this.contentType = contentType; this.ignoreFirstLf = ignoreFirstLf; } - requireExtraParent(currentParent: string): boolean { - if (!this.requiredParents) { - return false; - } - - if (!currentParent) { - return true; - } - - const lcParent = currentParent.toLowerCase(); - const isParentTemplate = lcParent === 'template' || currentParent === 'ng-template'; - return !isParentTemplate && this.requiredParents[lcParent] != true; - } - isClosedByChild(name: string): boolean { return this.isVoid || name.toLowerCase() in this.closedByChildren; } @@ -104,14 +78,10 @@ export function getHtmlTagDefinition(tagName: string): HtmlTagDefinition { 'thead': new HtmlTagDefinition({closedByChildren: ['tbody', 'tfoot']}), 'tbody': new HtmlTagDefinition({closedByChildren: ['tbody', 'tfoot'], closedByParent: true}), 'tfoot': new HtmlTagDefinition({closedByChildren: ['tbody'], closedByParent: true}), - 'tr': new HtmlTagDefinition({ - closedByChildren: ['tr'], - requiredParents: ['tbody', 'tfoot', 'thead'], - closedByParent: true - }), + 'tr': new HtmlTagDefinition({closedByChildren: ['tr'], closedByParent: true}), 'td': new HtmlTagDefinition({closedByChildren: ['td', 'th'], closedByParent: true}), 'th': new HtmlTagDefinition({closedByChildren: ['td', 'th'], closedByParent: true}), - 'col': new HtmlTagDefinition({requiredParents: ['colgroup'], isVoid: true}), + 'col': new HtmlTagDefinition({isVoid: true}), 'svg': new HtmlTagDefinition({implicitNamespacePrefix: 'svg'}), 'math': new HtmlTagDefinition({implicitNamespacePrefix: 'math'}), 'li': new HtmlTagDefinition({closedByChildren: ['li'], closedByParent: true}), diff --git a/packages/compiler/src/ml_parser/parser.ts b/packages/compiler/src/ml_parser/parser.ts index d1fe41608f..88aca6d6f3 100644 --- a/packages/compiler/src/ml_parser/parser.ts +++ b/packages/compiler/src/ml_parser/parser.ts @@ -274,15 +274,6 @@ class _TreeBuilder { this._elementStack.pop(); } - const tagDef = this.getTagDefinition(el.name); - const {parent, container} = this._getParentElementSkippingContainers(); - - if (parent && tagDef.requireExtraParent(parent.name)) { - const newParent = new html.Element( - tagDef.parentToAdd, [], [], el.sourceSpan, el.startSourceSpan, el.endSourceSpan); - this._insertBeforeContainer(parent, container, newParent); - } - this._addToParent(el); this._elementStack.push(el); } diff --git a/packages/compiler/src/ml_parser/tags.ts b/packages/compiler/src/ml_parser/tags.ts index 6428f9df45..038f4fe053 100644 --- a/packages/compiler/src/ml_parser/tags.ts +++ b/packages/compiler/src/ml_parser/tags.ts @@ -14,16 +14,12 @@ export enum TagContentType { export interface TagDefinition { closedByParent: boolean; - requiredParents: {[key: string]: boolean}; - parentToAdd: string; implicitNamespacePrefix: string|null; contentType: TagContentType; isVoid: boolean; ignoreFirstLf: boolean; canSelfClose: boolean; - requireExtraParent(currentParent: string): boolean; - isClosedByChild(name: string): boolean; } diff --git a/packages/compiler/test/ml_parser/html_parser_spec.ts b/packages/compiler/test/ml_parser/html_parser_spec.ts index 573001455b..3cc1b89353 100644 --- a/packages/compiler/test/ml_parser/html_parser_spec.ts +++ b/packages/compiler/test/ml_parser/html_parser_spec.ts @@ -113,73 +113,17 @@ import {humanizeDom, humanizeDomSourceSpans, humanizeLineColumn} from './ast_spe ]); }); - it('should add the requiredParent', () => { - expect( - humanizeDom(parser.parse( - '