refactor(core): remove unused i18n placeholder for projection (#39172)

Runtime i18n logic doesn't distinguish `<ng-content>` tag placeholders and regular element tag
placeholders in i18n messages, so there is no need to have a special marker for projection-based
placeholders and element markers can be used instead.

PR Close #39172
This commit is contained in:
Andrew Kushnir 2020-10-07 16:21:36 -07:00 committed by Alex Rickabaugh
parent f6dfd2ffed
commit 9186ad84ae
3 changed files with 8 additions and 11 deletions

View File

@ -15,7 +15,6 @@ import {assembleBoundTextPlaceholders, getSeqNumberGenerator, updatePlaceholderM
enum TagType {
ELEMENT,
TEMPLATE,
PROJECTION
}
/**
@ -105,10 +104,12 @@ export class I18nContext {
this.appendTag(TagType.ELEMENT, node as i18n.TagPlaceholder, index, closed);
}
appendProjection(node: i18n.I18nMeta, index: number) {
// add open and close tags at the same time,
// since we process projected content separately
this.appendTag(TagType.PROJECTION, node as i18n.TagPlaceholder, index, false);
this.appendTag(TagType.PROJECTION, node as i18n.TagPlaceholder, index, true);
// Add open and close tags at the same time, since `<ng-content>` has no content,
// so when we come across `<ng-content>` we can register both open and close tags.
// Note: runtime i18n logic doesn't distinguish `<ng-content>` tag placeholders and
// regular element tag placeholders, so we generate element placeholders for both types.
this.appendTag(TagType.ELEMENT, node as i18n.TagPlaceholder, index, false);
this.appendTag(TagType.ELEMENT, node as i18n.TagPlaceholder, index, true);
}
/**
@ -215,9 +216,6 @@ function serializePlaceholderValue(value: any): string {
case TagType.TEMPLATE:
return template(value, value.closed);
case TagType.PROJECTION:
return projection(value, value.closed);
default:
return value;
}

View File

@ -39,7 +39,7 @@ const ICU_BLOCK_REGEXP = /^\s*(<28>\d+:?\d*<2A>)\s*,\s*(select|plural)\s*,/;
const MARKER = `<EFBFBD>`;
const SUBTEMPLATE_REGEXP = /<2F>\/?\*(\d+:\d+)<29>/gi;
const PH_REGEXP = /<2F>(\/?[#*!]\d+):?\d*<2A>/gi;
const PH_REGEXP = /<2F>(\/?[#*]\d+):?\d*<2A>/gi;
/**
* Angular Dart introduced &ngsp; as a placeholder for non-removable space, see:
@ -120,7 +120,7 @@ export function i18nStartFirstCreatePass(
// At this point value is something like: '/#1:2' (originally coming from '<27>/#1:2<>')
const isClosing = value.charCodeAt(0) === CharCode.SLASH;
const type = value.charCodeAt(isClosing ? 1 : 0);
ngDevMode && assertOneOf(type, CharCode.STAR, CharCode.HASH, CharCode.EXCLAMATION);
ngDevMode && assertOneOf(type, CharCode.STAR, CharCode.HASH);
const index = HEADER_OFFSET + Number.parseInt(value.substring((isClosing ? 2 : 1)));
if (isClosing) {
existingTNodeStack.shift();

View File

@ -12,7 +12,6 @@
export const enum CharCode {
UPPER_CASE = ~32, // & with this will make the char uppercase
SPACE = 32, // " "
EXCLAMATION = 33, // "!"
DOUBLE_QUOTE = 34, // "\""
HASH = 35, // "#"
SINGLE_QUOTE = 39, // "'"