Skip to content

Commit b6c141b

Browse files
crisbetothePunderWoman
authored andcommitted
refactor(compiler): remove container blocks config
Removes the ability to specify container blocks when creating an i18n parser. We were only passing in `switch` and it likely won't change.
1 parent 7ddf4a6 commit b6c141b

File tree

6 files changed

+2
-20
lines changed

6 files changed

+2
-20
lines changed

packages/compiler/src/i18n/extractor_merger.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import * as html from '../ml_parser/ast';
10-
import {DEFAULT_CONTAINER_BLOCKS} from '../ml_parser/defaults';
1110
import {ParseTreeResult} from '../ml_parser/parser';
1211
import {TokenType} from '../ml_parser/tokens';
1312
import {ParseError} from '../parse_util';
@@ -285,7 +284,6 @@ class _Visitor implements html.Visitor {
285284
this._messages = [];
286285
this._inImplicitNode = false;
287286
this._createI18nMessage = createI18nMessageFactory(
288-
DEFAULT_CONTAINER_BLOCKS,
289287
// When dropping significant whitespace we need to retain whitespace tokens or
290288
// else we won't be able to reuse source spans because empty tokens would be
291289
// removed and cause a mismatch.

packages/compiler/src/i18n/i18n_parser.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,10 @@ export interface I18nMessageFactory {
4141
* Returns a function converting html nodes to an i18n Message
4242
*/
4343
export function createI18nMessageFactory(
44-
containerBlocks: Set<string>,
4544
retainEmptyTokens: boolean,
4645
preserveExpressionWhitespace: boolean,
4746
): I18nMessageFactory {
48-
const visitor = new _I18nVisitor(
49-
_expParser,
50-
containerBlocks,
51-
retainEmptyTokens,
52-
preserveExpressionWhitespace,
53-
);
47+
const visitor = new _I18nVisitor(_expParser, retainEmptyTokens, preserveExpressionWhitespace);
5448
return (nodes, meaning, description, customId, visitNodeFn) =>
5549
visitor.toI18nMessage(nodes, meaning, description, customId, visitNodeFn);
5650
}
@@ -71,7 +65,6 @@ function noopVisitNodeFn(_html: html.Node, i18n: i18n.Node): i18n.Node {
7165
class _I18nVisitor implements html.Visitor {
7266
constructor(
7367
private _expressionParser: ExpressionParser,
74-
private _containerBlocks: Set<string>,
7568
private readonly _retainEmptyTokens: boolean,
7669
private readonly _preserveExpressionWhitespace: boolean,
7770
) {}
@@ -183,7 +176,7 @@ class _I18nVisitor implements html.Visitor {
183176
visitBlock(block: html.Block, context: I18nMessageVisitorContext) {
184177
const children = html.visitAll(this, block.children, context);
185178

186-
if (this._containerBlocks.has(block.name)) {
179+
if (block.name === 'switch') {
187180
return new i18n.Container(children, block.sourceSpan);
188181
}
189182

packages/compiler/src/ml_parser/defaults.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,3 @@ export const DEFAULT_INTERPOLATION_CONFIG: InterpolationConfig = new Interpolati
3131
'{{',
3232
'}}',
3333
);
34-
35-
export const DEFAULT_CONTAINER_BLOCKS = new Set(['switch']);

packages/compiler/src/render3/view/i18n/meta.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {computeDecimalDigest, computeDigest, decimalDigest} from '../../../i18n/
1111
import * as i18n from '../../../i18n/i18n_ast';
1212
import {createI18nMessageFactory, VisitNodeFn} from '../../../i18n/i18n_parser';
1313
import * as html from '../../../ml_parser/ast';
14-
import {DEFAULT_CONTAINER_BLOCKS} from '../../../ml_parser/defaults';
1514
import {ParseTreeResult} from '../../../ml_parser/parser';
1615
import * as o from '../../../output/output_ast';
1716
import {isTrustedTypesSink} from '../../../schema/trusted_types_sinks';
@@ -63,7 +62,6 @@ export class I18nMetaVisitor implements html.Visitor {
6362
constructor(
6463
private keepI18nAttrs = false,
6564
private enableI18nLegacyMessageIdFormat = false,
66-
private containerBlocks: Set<string> = DEFAULT_CONTAINER_BLOCKS,
6765
private readonly preserveSignificantWhitespace: boolean = true,
6866

6967
// When dropping significant whitespace we need to retain empty tokens or
@@ -82,7 +80,6 @@ export class I18nMetaVisitor implements html.Visitor {
8280
): i18n.Message {
8381
const {meaning, description, customId} = this._parseMetadata(meta);
8482
const createI18nMessage = createI18nMessageFactory(
85-
this.containerBlocks,
8683
this.retainEmptyTokens,
8784
/* preserveExpressionWhitespace */ this.preserveSignificantWhitespace,
8885
);

packages/compiler/src/render3/view/template.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ export function parseTemplate(
189189
const i18nMetaVisitor = new I18nMetaVisitor(
190190
/* keepI18nAttrs */ !preserveWhitespaces,
191191
enableI18nLegacyMessageIdFormat,
192-
/* containerBlocks */ undefined,
193192
options.preserveSignificantWhitespace,
194193
retainEmptyTokens,
195194
);
@@ -246,7 +245,6 @@ export function parseTemplate(
246245
new I18nMetaVisitor(
247246
/* keepI18nAttrs */ false,
248247
/* enableI18nLegacyMessageIdFormat */ undefined,
249-
/* containerBlocks */ undefined,
250248
/* preserveSignificantWhitespace */ true,
251249
retainEmptyTokens,
252250
),

packages/compiler/test/i18n/i18n_ast_spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88

99
import {createI18nMessageFactory} from '../../src/i18n/i18n_parser';
1010
import {Node} from '../../src/ml_parser/ast';
11-
import {DEFAULT_CONTAINER_BLOCKS} from '../../src/ml_parser/defaults';
1211
import {HtmlParser} from '../../src/ml_parser/html_parser';
1312

1413
describe('Message', () => {
1514
const messageFactory = createI18nMessageFactory(
16-
DEFAULT_CONTAINER_BLOCKS,
1715
/* retainEmptyTokens */ false,
1816
/* preserveExpressionWhitespace */ true,
1917
);

0 commit comments

Comments
 (0)