diff --git a/packages/compiler/src/i18n/extractor_merger.ts b/packages/compiler/src/i18n/extractor_merger.ts index d753c71fa14..e8e7693cdad 100644 --- a/packages/compiler/src/i18n/extractor_merger.ts +++ b/packages/compiler/src/i18n/extractor_merger.ts @@ -7,7 +7,6 @@ */ import * as html from '../ml_parser/ast'; -import {DEFAULT_CONTAINER_BLOCKS} from '../ml_parser/defaults'; import {ParseTreeResult} from '../ml_parser/parser'; import {TokenType} from '../ml_parser/tokens'; import {ParseError} from '../parse_util'; @@ -285,7 +284,6 @@ class _Visitor implements html.Visitor { this._messages = []; this._inImplicitNode = false; this._createI18nMessage = createI18nMessageFactory( - DEFAULT_CONTAINER_BLOCKS, // When dropping significant whitespace we need to retain whitespace tokens or // else we won't be able to reuse source spans because empty tokens would be // removed and cause a mismatch. diff --git a/packages/compiler/src/i18n/i18n_parser.ts b/packages/compiler/src/i18n/i18n_parser.ts index b1b07301689..6847181312b 100644 --- a/packages/compiler/src/i18n/i18n_parser.ts +++ b/packages/compiler/src/i18n/i18n_parser.ts @@ -41,16 +41,10 @@ export interface I18nMessageFactory { * Returns a function converting html nodes to an i18n Message */ export function createI18nMessageFactory( - containerBlocks: Set, retainEmptyTokens: boolean, preserveExpressionWhitespace: boolean, ): I18nMessageFactory { - const visitor = new _I18nVisitor( - _expParser, - containerBlocks, - retainEmptyTokens, - preserveExpressionWhitespace, - ); + const visitor = new _I18nVisitor(_expParser, retainEmptyTokens, preserveExpressionWhitespace); return (nodes, meaning, description, customId, visitNodeFn) => visitor.toI18nMessage(nodes, meaning, description, customId, visitNodeFn); } @@ -71,7 +65,6 @@ function noopVisitNodeFn(_html: html.Node, i18n: i18n.Node): i18n.Node { class _I18nVisitor implements html.Visitor { constructor( private _expressionParser: ExpressionParser, - private _containerBlocks: Set, private readonly _retainEmptyTokens: boolean, private readonly _preserveExpressionWhitespace: boolean, ) {} @@ -183,7 +176,7 @@ class _I18nVisitor implements html.Visitor { visitBlock(block: html.Block, context: I18nMessageVisitorContext) { const children = html.visitAll(this, block.children, context); - if (this._containerBlocks.has(block.name)) { + if (block.name === 'switch') { return new i18n.Container(children, block.sourceSpan); } diff --git a/packages/compiler/src/ml_parser/defaults.ts b/packages/compiler/src/ml_parser/defaults.ts index 90e30e55d2a..bfec7dcda2c 100644 --- a/packages/compiler/src/ml_parser/defaults.ts +++ b/packages/compiler/src/ml_parser/defaults.ts @@ -31,5 +31,3 @@ export const DEFAULT_INTERPOLATION_CONFIG: InterpolationConfig = new Interpolati '{{', '}}', ); - -export const DEFAULT_CONTAINER_BLOCKS = new Set(['switch']); diff --git a/packages/compiler/src/render3/view/i18n/meta.ts b/packages/compiler/src/render3/view/i18n/meta.ts index 00007d2ff4c..f5071b3f8fc 100644 --- a/packages/compiler/src/render3/view/i18n/meta.ts +++ b/packages/compiler/src/render3/view/i18n/meta.ts @@ -11,7 +11,6 @@ import {computeDecimalDigest, computeDigest, decimalDigest} from '../../../i18n/ import * as i18n from '../../../i18n/i18n_ast'; import {createI18nMessageFactory, VisitNodeFn} from '../../../i18n/i18n_parser'; import * as html from '../../../ml_parser/ast'; -import {DEFAULT_CONTAINER_BLOCKS} from '../../../ml_parser/defaults'; import {ParseTreeResult} from '../../../ml_parser/parser'; import * as o from '../../../output/output_ast'; import {isTrustedTypesSink} from '../../../schema/trusted_types_sinks'; @@ -63,7 +62,6 @@ export class I18nMetaVisitor implements html.Visitor { constructor( private keepI18nAttrs = false, private enableI18nLegacyMessageIdFormat = false, - private containerBlocks: Set = DEFAULT_CONTAINER_BLOCKS, private readonly preserveSignificantWhitespace: boolean = true, // When dropping significant whitespace we need to retain empty tokens or @@ -82,7 +80,6 @@ export class I18nMetaVisitor implements html.Visitor { ): i18n.Message { const {meaning, description, customId} = this._parseMetadata(meta); const createI18nMessage = createI18nMessageFactory( - this.containerBlocks, this.retainEmptyTokens, /* preserveExpressionWhitespace */ this.preserveSignificantWhitespace, ); diff --git a/packages/compiler/src/render3/view/template.ts b/packages/compiler/src/render3/view/template.ts index 8fa6121b201..28dedea8816 100644 --- a/packages/compiler/src/render3/view/template.ts +++ b/packages/compiler/src/render3/view/template.ts @@ -189,7 +189,6 @@ export function parseTemplate( const i18nMetaVisitor = new I18nMetaVisitor( /* keepI18nAttrs */ !preserveWhitespaces, enableI18nLegacyMessageIdFormat, - /* containerBlocks */ undefined, options.preserveSignificantWhitespace, retainEmptyTokens, ); @@ -246,7 +245,6 @@ export function parseTemplate( new I18nMetaVisitor( /* keepI18nAttrs */ false, /* enableI18nLegacyMessageIdFormat */ undefined, - /* containerBlocks */ undefined, /* preserveSignificantWhitespace */ true, retainEmptyTokens, ), diff --git a/packages/compiler/test/i18n/i18n_ast_spec.ts b/packages/compiler/test/i18n/i18n_ast_spec.ts index 537b4e5b008..db336ac4b59 100644 --- a/packages/compiler/test/i18n/i18n_ast_spec.ts +++ b/packages/compiler/test/i18n/i18n_ast_spec.ts @@ -8,12 +8,10 @@ import {createI18nMessageFactory} from '../../src/i18n/i18n_parser'; import {Node} from '../../src/ml_parser/ast'; -import {DEFAULT_CONTAINER_BLOCKS} from '../../src/ml_parser/defaults'; import {HtmlParser} from '../../src/ml_parser/html_parser'; describe('Message', () => { const messageFactory = createI18nMessageFactory( - DEFAULT_CONTAINER_BLOCKS, /* retainEmptyTokens */ false, /* preserveExpressionWhitespace */ true, );