1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import '../../util/ng_dev_mode';
|
---|
9 | import '../../util/ng_i18n_closure_mode';
|
---|
10 | import { getTemplateContent, SRCSET_ATTRS, URI_ATTRS, VALID_ATTRS, VALID_ELEMENTS } from '../../sanitization/html_sanitizer';
|
---|
11 | import { getInertBodyHelper } from '../../sanitization/inert_body';
|
---|
12 | import { _sanitizeUrl, sanitizeSrcset } from '../../sanitization/url_sanitizer';
|
---|
13 | import { assertDefined, assertEqual, assertGreaterThanOrEqual, assertOneOf, assertString } from '../../util/assert';
|
---|
14 | import { loadIcuContainerVisitor } from '../instructions/i18n_icu_container_visitor';
|
---|
15 | import { allocExpando, createTNodeAtIndex } from '../instructions/shared';
|
---|
16 | import { getDocument } from '../interfaces/document';
|
---|
17 | import { ELEMENT_MARKER, I18nCreateOpCode, ICU_MARKER } from '../interfaces/i18n';
|
---|
18 | import { HEADER_OFFSET } from '../interfaces/view';
|
---|
19 | import { getCurrentParentTNode, getCurrentTNode, setCurrentTNode } from '../state';
|
---|
20 | import { attachDebugGetter } from '../util/debug_utils';
|
---|
21 | import { i18nCreateOpCodesToString, i18nRemoveOpCodesToString, i18nUpdateOpCodesToString, icuCreateOpCodesToString } from './i18n_debug';
|
---|
22 | import { addTNodeAndUpdateInsertBeforeIndex } from './i18n_insert_before_index';
|
---|
23 | import { ensureIcuContainerVisitorLoaded } from './i18n_tree_shaking';
|
---|
24 | import { createTNodePlaceholder, icuCreateOpCode, setTIcu, setTNodeInsertBeforeIndex } from './i18n_util';
|
---|
25 | const BINDING_REGEXP = /�(\d+):?\d*�/gi;
|
---|
26 | const ICU_REGEXP = /({\s*�\d+:?\d*�\s*,\s*\S{6}\s*,[\s\S]*})/gi;
|
---|
27 | const NESTED_ICU = /�(\d+)�/;
|
---|
28 | const ICU_BLOCK_REGEXP = /^\s*(�\d+:?\d*�)\s*,\s*(select|plural)\s*,/;
|
---|
29 | const MARKER = `�`;
|
---|
30 | const SUBTEMPLATE_REGEXP = /�\/?\*(\d+:\d+)�/gi;
|
---|
31 | const PH_REGEXP = /�(\/?[#*]\d+):?\d*�/gi;
|
---|
32 | /**
|
---|
33 | * Angular Dart introduced &ngsp; as a placeholder for non-removable space, see:
|
---|
34 | * https://github.com/dart-lang/angular/blob/0bb611387d29d65b5af7f9d2515ab571fd3fbee4/_tests/test/compiler/preserve_whitespace_test.dart#L25-L32
|
---|
35 | * In Angular Dart &ngsp; is converted to the 0xE500 PUA (Private Use Areas) unicode character
|
---|
36 | * and later on replaced by a space. We are re-implementing the same idea here, since translations
|
---|
37 | * might contain this special character.
|
---|
38 | */
|
---|
39 | const NGSP_UNICODE_REGEXP = /\uE500/g;
|
---|
40 | function replaceNgsp(value) {
|
---|
41 | return value.replace(NGSP_UNICODE_REGEXP, ' ');
|
---|
42 | }
|
---|
43 | /**
|
---|
44 | * Create dynamic nodes from i18n translation block.
|
---|
45 | *
|
---|
46 | * - Text nodes are created synchronously
|
---|
47 | * - TNodes are linked into tree lazily
|
---|
48 | *
|
---|
49 | * @param tView Current `TView`
|
---|
50 | * @parentTNodeIndex index to the parent TNode of this i18n block
|
---|
51 | * @param lView Current `LView`
|
---|
52 | * @param index Index of `ɵɵi18nStart` instruction.
|
---|
53 | * @param message Message to translate.
|
---|
54 | * @param subTemplateIndex Index into the sub template of message translation. (ie in case of
|
---|
55 | * `ngIf`) (-1 otherwise)
|
---|
56 | */
|
---|
57 | export function i18nStartFirstCreatePass(tView, parentTNodeIndex, lView, index, message, subTemplateIndex) {
|
---|
58 | const rootTNode = getCurrentParentTNode();
|
---|
59 | const createOpCodes = [];
|
---|
60 | const updateOpCodes = [];
|
---|
61 | const existingTNodeStack = [[]];
|
---|
62 | if (ngDevMode) {
|
---|
63 | attachDebugGetter(createOpCodes, i18nCreateOpCodesToString);
|
---|
64 | attachDebugGetter(updateOpCodes, i18nUpdateOpCodesToString);
|
---|
65 | }
|
---|
66 | message = getTranslationForTemplate(message, subTemplateIndex);
|
---|
67 | const msgParts = replaceNgsp(message).split(PH_REGEXP);
|
---|
68 | for (let i = 0; i < msgParts.length; i++) {
|
---|
69 | let value = msgParts[i];
|
---|
70 | if ((i & 1) === 0) {
|
---|
71 | // Even indexes are text (including bindings & ICU expressions)
|
---|
72 | const parts = i18nParseTextIntoPartsAndICU(value);
|
---|
73 | for (let j = 0; j < parts.length; j++) {
|
---|
74 | let part = parts[j];
|
---|
75 | if ((j & 1) === 0) {
|
---|
76 | // `j` is odd therefore `part` is string
|
---|
77 | const text = part;
|
---|
78 | ngDevMode && assertString(text, 'Parsed ICU part should be string');
|
---|
79 | if (text !== '') {
|
---|
80 | i18nStartFirstCreatePassProcessTextNode(tView, rootTNode, existingTNodeStack[0], createOpCodes, updateOpCodes, lView, text);
|
---|
81 | }
|
---|
82 | }
|
---|
83 | else {
|
---|
84 | // `j` is Even therefor `part` is an `ICUExpression`
|
---|
85 | const icuExpression = part;
|
---|
86 | // Verify that ICU expression has the right shape. Translations might contain invalid
|
---|
87 | // constructions (while original messages were correct), so ICU parsing at runtime may
|
---|
88 | // not succeed (thus `icuExpression` remains a string).
|
---|
89 | // Note: we intentionally retain the error here by not using `ngDevMode`, because
|
---|
90 | // the value can change based on the locale and users aren't guaranteed to hit
|
---|
91 | // an invalid string while they're developing.
|
---|
92 | if (typeof icuExpression !== 'object') {
|
---|
93 | throw new Error(`Unable to parse ICU expression in "${message}" message.`);
|
---|
94 | }
|
---|
95 | const icuContainerTNode = createTNodeAndAddOpCode(tView, rootTNode, existingTNodeStack[0], lView, createOpCodes, ngDevMode ? `ICU ${index}:${icuExpression.mainBinding}` : '', true);
|
---|
96 | const icuNodeIndex = icuContainerTNode.index;
|
---|
97 | ngDevMode &&
|
---|
98 | assertGreaterThanOrEqual(icuNodeIndex, HEADER_OFFSET, 'Index must be in absolute LView offset');
|
---|
99 | icuStart(tView, lView, updateOpCodes, parentTNodeIndex, icuExpression, icuNodeIndex);
|
---|
100 | }
|
---|
101 | }
|
---|
102 | }
|
---|
103 | else {
|
---|
104 | // Odd indexes are placeholders (elements and sub-templates)
|
---|
105 | // At this point value is something like: '/#1:2' (originally coming from '�/#1:2�')
|
---|
106 | const isClosing = value.charCodeAt(0) === 47 /* SLASH */;
|
---|
107 | const type = value.charCodeAt(isClosing ? 1 : 0);
|
---|
108 | ngDevMode && assertOneOf(type, 42 /* STAR */, 35 /* HASH */);
|
---|
109 | const index = HEADER_OFFSET + Number.parseInt(value.substring((isClosing ? 2 : 1)));
|
---|
110 | if (isClosing) {
|
---|
111 | existingTNodeStack.shift();
|
---|
112 | setCurrentTNode(getCurrentParentTNode(), false);
|
---|
113 | }
|
---|
114 | else {
|
---|
115 | const tNode = createTNodePlaceholder(tView, existingTNodeStack[0], index);
|
---|
116 | existingTNodeStack.unshift([]);
|
---|
117 | setCurrentTNode(tNode, true);
|
---|
118 | }
|
---|
119 | }
|
---|
120 | }
|
---|
121 | tView.data[index] = {
|
---|
122 | create: createOpCodes,
|
---|
123 | update: updateOpCodes,
|
---|
124 | };
|
---|
125 | }
|
---|
126 | /**
|
---|
127 | * Allocate space in i18n Range add create OpCode instruction to crete a text or comment node.
|
---|
128 | *
|
---|
129 | * @param tView Current `TView` needed to allocate space in i18n range.
|
---|
130 | * @param rootTNode Root `TNode` of the i18n block. This node determines if the new TNode will be
|
---|
131 | * added as part of the `i18nStart` instruction or as part of the `TNode.insertBeforeIndex`.
|
---|
132 | * @param existingTNodes internal state for `addTNodeAndUpdateInsertBeforeIndex`.
|
---|
133 | * @param lView Current `LView` needed to allocate space in i18n range.
|
---|
134 | * @param createOpCodes Array storing `I18nCreateOpCodes` where new opCodes will be added.
|
---|
135 | * @param text Text to be added when the `Text` or `Comment` node will be created.
|
---|
136 | * @param isICU true if a `Comment` node for ICU (instead of `Text`) node should be created.
|
---|
137 | */
|
---|
138 | function createTNodeAndAddOpCode(tView, rootTNode, existingTNodes, lView, createOpCodes, text, isICU) {
|
---|
139 | const i18nNodeIdx = allocExpando(tView, lView, 1, null);
|
---|
140 | let opCode = i18nNodeIdx << I18nCreateOpCode.SHIFT;
|
---|
141 | let parentTNode = getCurrentParentTNode();
|
---|
142 | if (rootTNode === parentTNode) {
|
---|
143 | // FIXME(misko): A null `parentTNode` should represent when we fall of the `LView` boundary.
|
---|
144 | // (there is no parent), but in some circumstances (because we are inconsistent about how we set
|
---|
145 | // `previousOrParentTNode`) it could point to `rootTNode` So this is a work around.
|
---|
146 | parentTNode = null;
|
---|
147 | }
|
---|
148 | if (parentTNode === null) {
|
---|
149 | // If we don't have a parent that means that we can eagerly add nodes.
|
---|
150 | // If we have a parent than these nodes can't be added now (as the parent has not been created
|
---|
151 | // yet) and instead the `parentTNode` is responsible for adding it. See
|
---|
152 | // `TNode.insertBeforeIndex`
|
---|
153 | opCode |= I18nCreateOpCode.APPEND_EAGERLY;
|
---|
154 | }
|
---|
155 | if (isICU) {
|
---|
156 | opCode |= I18nCreateOpCode.COMMENT;
|
---|
157 | ensureIcuContainerVisitorLoaded(loadIcuContainerVisitor);
|
---|
158 | }
|
---|
159 | createOpCodes.push(opCode, text === null ? '' : text);
|
---|
160 | // We store `{{?}}` so that when looking at debug `TNodeType.template` we can see where the
|
---|
161 | // bindings are.
|
---|
162 | const tNode = createTNodeAtIndex(tView, i18nNodeIdx, isICU ? 32 /* Icu */ : 1 /* Text */, text === null ? (ngDevMode ? '{{?}}' : '') : text, null);
|
---|
163 | addTNodeAndUpdateInsertBeforeIndex(existingTNodes, tNode);
|
---|
164 | const tNodeIdx = tNode.index;
|
---|
165 | setCurrentTNode(tNode, false /* Text nodes are self closing */);
|
---|
166 | if (parentTNode !== null && rootTNode !== parentTNode) {
|
---|
167 | // We are a child of deeper node (rather than a direct child of `i18nStart` instruction.)
|
---|
168 | // We have to make sure to add ourselves to the parent.
|
---|
169 | setTNodeInsertBeforeIndex(parentTNode, tNodeIdx);
|
---|
170 | }
|
---|
171 | return tNode;
|
---|
172 | }
|
---|
173 | /**
|
---|
174 | * Processes text node in i18n block.
|
---|
175 | *
|
---|
176 | * Text nodes can have:
|
---|
177 | * - Create instruction in `createOpCodes` for creating the text node.
|
---|
178 | * - Allocate spec for text node in i18n range of `LView`
|
---|
179 | * - If contains binding:
|
---|
180 | * - bindings => allocate space in i18n range of `LView` to store the binding value.
|
---|
181 | * - populate `updateOpCodes` with update instructions.
|
---|
182 | *
|
---|
183 | * @param tView Current `TView`
|
---|
184 | * @param rootTNode Root `TNode` of the i18n block. This node determines if the new TNode will
|
---|
185 | * be added as part of the `i18nStart` instruction or as part of the
|
---|
186 | * `TNode.insertBeforeIndex`.
|
---|
187 | * @param existingTNodes internal state for `addTNodeAndUpdateInsertBeforeIndex`.
|
---|
188 | * @param createOpCodes Location where the creation OpCodes will be stored.
|
---|
189 | * @param lView Current `LView`
|
---|
190 | * @param text The translated text (which may contain binding)
|
---|
191 | */
|
---|
192 | function i18nStartFirstCreatePassProcessTextNode(tView, rootTNode, existingTNodes, createOpCodes, updateOpCodes, lView, text) {
|
---|
193 | const hasBinding = text.match(BINDING_REGEXP);
|
---|
194 | const tNode = createTNodeAndAddOpCode(tView, rootTNode, existingTNodes, lView, createOpCodes, hasBinding ? null : text, false);
|
---|
195 | if (hasBinding) {
|
---|
196 | generateBindingUpdateOpCodes(updateOpCodes, text, tNode.index, null, 0, null);
|
---|
197 | }
|
---|
198 | }
|
---|
199 | /**
|
---|
200 | * See `i18nAttributes` above.
|
---|
201 | */
|
---|
202 | export function i18nAttributesFirstPass(tView, index, values) {
|
---|
203 | const previousElement = getCurrentTNode();
|
---|
204 | const previousElementIndex = previousElement.index;
|
---|
205 | const updateOpCodes = [];
|
---|
206 | if (ngDevMode) {
|
---|
207 | attachDebugGetter(updateOpCodes, i18nUpdateOpCodesToString);
|
---|
208 | }
|
---|
209 | if (tView.firstCreatePass && tView.data[index] === null) {
|
---|
210 | for (let i = 0; i < values.length; i += 2) {
|
---|
211 | const attrName = values[i];
|
---|
212 | const message = values[i + 1];
|
---|
213 | if (message !== '') {
|
---|
214 | // Check if attribute value contains an ICU and throw an error if that's the case.
|
---|
215 | // ICUs in element attributes are not supported.
|
---|
216 | // Note: we intentionally retain the error here by not using `ngDevMode`, because
|
---|
217 | // the `value` can change based on the locale and users aren't guaranteed to hit
|
---|
218 | // an invalid string while they're developing.
|
---|
219 | if (ICU_REGEXP.test(message)) {
|
---|
220 | throw new Error(`ICU expressions are not supported in attributes. Message: "${message}".`);
|
---|
221 | }
|
---|
222 | // i18n attributes that hit this code path are guaranteed to have bindings, because
|
---|
223 | // the compiler treats static i18n attributes as regular attribute bindings.
|
---|
224 | // Since this may not be the first i18n attribute on this element we need to pass in how
|
---|
225 | // many previous bindings there have already been.
|
---|
226 | generateBindingUpdateOpCodes(updateOpCodes, message, previousElementIndex, attrName, countBindings(updateOpCodes), null);
|
---|
227 | }
|
---|
228 | }
|
---|
229 | tView.data[index] = updateOpCodes;
|
---|
230 | }
|
---|
231 | }
|
---|
232 | /**
|
---|
233 | * Generate the OpCodes to update the bindings of a string.
|
---|
234 | *
|
---|
235 | * @param updateOpCodes Place where the update opcodes will be stored.
|
---|
236 | * @param str The string containing the bindings.
|
---|
237 | * @param destinationNode Index of the destination node which will receive the binding.
|
---|
238 | * @param attrName Name of the attribute, if the string belongs to an attribute.
|
---|
239 | * @param sanitizeFn Sanitization function used to sanitize the string after update, if necessary.
|
---|
240 | * @param bindingStart The lView index of the next expression that can be bound via an opCode.
|
---|
241 | * @returns The mask value for these bindings
|
---|
242 | */
|
---|
243 | function generateBindingUpdateOpCodes(updateOpCodes, str, destinationNode, attrName, bindingStart, sanitizeFn) {
|
---|
244 | ngDevMode &&
|
---|
245 | assertGreaterThanOrEqual(destinationNode, HEADER_OFFSET, 'Index must be in absolute LView offset');
|
---|
246 | const maskIndex = updateOpCodes.length; // Location of mask
|
---|
247 | const sizeIndex = maskIndex + 1; // location of size for skipping
|
---|
248 | updateOpCodes.push(null, null); // Alloc space for mask and size
|
---|
249 | const startIndex = maskIndex + 2; // location of first allocation.
|
---|
250 | if (ngDevMode) {
|
---|
251 | attachDebugGetter(updateOpCodes, i18nUpdateOpCodesToString);
|
---|
252 | }
|
---|
253 | const textParts = str.split(BINDING_REGEXP);
|
---|
254 | let mask = 0;
|
---|
255 | for (let j = 0; j < textParts.length; j++) {
|
---|
256 | const textValue = textParts[j];
|
---|
257 | if (j & 1) {
|
---|
258 | // Odd indexes are bindings
|
---|
259 | const bindingIndex = bindingStart + parseInt(textValue, 10);
|
---|
260 | updateOpCodes.push(-1 - bindingIndex);
|
---|
261 | mask = mask | toMaskBit(bindingIndex);
|
---|
262 | }
|
---|
263 | else if (textValue !== '') {
|
---|
264 | // Even indexes are text
|
---|
265 | updateOpCodes.push(textValue);
|
---|
266 | }
|
---|
267 | }
|
---|
268 | updateOpCodes.push(destinationNode << 2 /* SHIFT_REF */ |
|
---|
269 | (attrName ? 1 /* Attr */ : 0 /* Text */));
|
---|
270 | if (attrName) {
|
---|
271 | updateOpCodes.push(attrName, sanitizeFn);
|
---|
272 | }
|
---|
273 | updateOpCodes[maskIndex] = mask;
|
---|
274 | updateOpCodes[sizeIndex] = updateOpCodes.length - startIndex;
|
---|
275 | return mask;
|
---|
276 | }
|
---|
277 | /**
|
---|
278 | * Count the number of bindings in the given `opCodes`.
|
---|
279 | *
|
---|
280 | * It could be possible to speed this up, by passing the number of bindings found back from
|
---|
281 | * `generateBindingUpdateOpCodes()` to `i18nAttributesFirstPass()` but this would then require more
|
---|
282 | * complexity in the code and/or transient objects to be created.
|
---|
283 | *
|
---|
284 | * Since this function is only called once when the template is instantiated, is trivial in the
|
---|
285 | * first instance (since `opCodes` will be an empty array), and it is not common for elements to
|
---|
286 | * contain multiple i18n bound attributes, it seems like this is a reasonable compromise.
|
---|
287 | */
|
---|
288 | function countBindings(opCodes) {
|
---|
289 | let count = 0;
|
---|
290 | for (let i = 0; i < opCodes.length; i++) {
|
---|
291 | const opCode = opCodes[i];
|
---|
292 | // Bindings are negative numbers.
|
---|
293 | if (typeof opCode === 'number' && opCode < 0) {
|
---|
294 | count++;
|
---|
295 | }
|
---|
296 | }
|
---|
297 | return count;
|
---|
298 | }
|
---|
299 | /**
|
---|
300 | * Convert binding index to mask bit.
|
---|
301 | *
|
---|
302 | * Each index represents a single bit on the bit-mask. Because bit-mask only has 32 bits, we make
|
---|
303 | * the 32nd bit share all masks for all bindings higher than 32. Since it is extremely rare to
|
---|
304 | * have more than 32 bindings this will be hit very rarely. The downside of hitting this corner
|
---|
305 | * case is that we will execute binding code more often than necessary. (penalty of performance)
|
---|
306 | */
|
---|
307 | function toMaskBit(bindingIndex) {
|
---|
308 | return 1 << Math.min(bindingIndex, 31);
|
---|
309 | }
|
---|
310 | export function isRootTemplateMessage(subTemplateIndex) {
|
---|
311 | return subTemplateIndex === -1;
|
---|
312 | }
|
---|
313 | /**
|
---|
314 | * Removes everything inside the sub-templates of a message.
|
---|
315 | */
|
---|
316 | function removeInnerTemplateTranslation(message) {
|
---|
317 | let match;
|
---|
318 | let res = '';
|
---|
319 | let index = 0;
|
---|
320 | let inTemplate = false;
|
---|
321 | let tagMatched;
|
---|
322 | while ((match = SUBTEMPLATE_REGEXP.exec(message)) !== null) {
|
---|
323 | if (!inTemplate) {
|
---|
324 | res += message.substring(index, match.index + match[0].length);
|
---|
325 | tagMatched = match[1];
|
---|
326 | inTemplate = true;
|
---|
327 | }
|
---|
328 | else {
|
---|
329 | if (match[0] === `${MARKER}/*${tagMatched}${MARKER}`) {
|
---|
330 | index = match.index;
|
---|
331 | inTemplate = false;
|
---|
332 | }
|
---|
333 | }
|
---|
334 | }
|
---|
335 | ngDevMode &&
|
---|
336 | assertEqual(inTemplate, false, `Tag mismatch: unable to find the end of the sub-template in the translation "${message}"`);
|
---|
337 | res += message.substr(index);
|
---|
338 | return res;
|
---|
339 | }
|
---|
340 | /**
|
---|
341 | * Extracts a part of a message and removes the rest.
|
---|
342 | *
|
---|
343 | * This method is used for extracting a part of the message associated with a template. A
|
---|
344 | * translated message can span multiple templates.
|
---|
345 | *
|
---|
346 | * Example:
|
---|
347 | * ```
|
---|
348 | * <div i18n>Translate <span *ngIf>me</span>!</div>
|
---|
349 | * ```
|
---|
350 | *
|
---|
351 | * @param message The message to crop
|
---|
352 | * @param subTemplateIndex Index of the sub-template to extract. If undefined it returns the
|
---|
353 | * external template and removes all sub-templates.
|
---|
354 | */
|
---|
355 | export function getTranslationForTemplate(message, subTemplateIndex) {
|
---|
356 | if (isRootTemplateMessage(subTemplateIndex)) {
|
---|
357 | // We want the root template message, ignore all sub-templates
|
---|
358 | return removeInnerTemplateTranslation(message);
|
---|
359 | }
|
---|
360 | else {
|
---|
361 | // We want a specific sub-template
|
---|
362 | const start = message.indexOf(`:${subTemplateIndex}${MARKER}`) + 2 + subTemplateIndex.toString().length;
|
---|
363 | const end = message.search(new RegExp(`${MARKER}\\/\\*\\d+:${subTemplateIndex}${MARKER}`));
|
---|
364 | return removeInnerTemplateTranslation(message.substring(start, end));
|
---|
365 | }
|
---|
366 | }
|
---|
367 | /**
|
---|
368 | * Generate the OpCodes for ICU expressions.
|
---|
369 | *
|
---|
370 | * @param icuExpression
|
---|
371 | * @param index Index where the anchor is stored and an optional `TIcuContainerNode`
|
---|
372 | * - `lView[anchorIdx]` points to a `Comment` node representing the anchor for the ICU.
|
---|
373 | * - `tView.data[anchorIdx]` points to the `TIcuContainerNode` if ICU is root (`null` otherwise)
|
---|
374 | */
|
---|
375 | export function icuStart(tView, lView, updateOpCodes, parentIdx, icuExpression, anchorIdx) {
|
---|
376 | ngDevMode && assertDefined(icuExpression, 'ICU expression must be defined');
|
---|
377 | let bindingMask = 0;
|
---|
378 | const tIcu = {
|
---|
379 | type: icuExpression.type,
|
---|
380 | currentCaseLViewIndex: allocExpando(tView, lView, 1, null),
|
---|
381 | anchorIdx,
|
---|
382 | cases: [],
|
---|
383 | create: [],
|
---|
384 | remove: [],
|
---|
385 | update: []
|
---|
386 | };
|
---|
387 | addUpdateIcuSwitch(updateOpCodes, icuExpression, anchorIdx);
|
---|
388 | setTIcu(tView, anchorIdx, tIcu);
|
---|
389 | const values = icuExpression.values;
|
---|
390 | for (let i = 0; i < values.length; i++) {
|
---|
391 | // Each value is an array of strings & other ICU expressions
|
---|
392 | const valueArr = values[i];
|
---|
393 | const nestedIcus = [];
|
---|
394 | for (let j = 0; j < valueArr.length; j++) {
|
---|
395 | const value = valueArr[j];
|
---|
396 | if (typeof value !== 'string') {
|
---|
397 | // It is an nested ICU expression
|
---|
398 | const icuIndex = nestedIcus.push(value) - 1;
|
---|
399 | // Replace nested ICU expression by a comment node
|
---|
400 | valueArr[j] = `<!--�${icuIndex}�-->`;
|
---|
401 | }
|
---|
402 | }
|
---|
403 | bindingMask = parseIcuCase(tView, tIcu, lView, updateOpCodes, parentIdx, icuExpression.cases[i], valueArr.join(''), nestedIcus) |
|
---|
404 | bindingMask;
|
---|
405 | }
|
---|
406 | if (bindingMask) {
|
---|
407 | addUpdateIcuUpdate(updateOpCodes, bindingMask, anchorIdx);
|
---|
408 | }
|
---|
409 | }
|
---|
410 | /**
|
---|
411 | * Parses text containing an ICU expression and produces a JSON object for it.
|
---|
412 | * Original code from closure library, modified for Angular.
|
---|
413 | *
|
---|
414 | * @param pattern Text containing an ICU expression that needs to be parsed.
|
---|
415 | *
|
---|
416 | */
|
---|
417 | export function parseICUBlock(pattern) {
|
---|
418 | const cases = [];
|
---|
419 | const values = [];
|
---|
420 | let icuType = 1 /* plural */;
|
---|
421 | let mainBinding = 0;
|
---|
422 | pattern = pattern.replace(ICU_BLOCK_REGEXP, function (str, binding, type) {
|
---|
423 | if (type === 'select') {
|
---|
424 | icuType = 0 /* select */;
|
---|
425 | }
|
---|
426 | else {
|
---|
427 | icuType = 1 /* plural */;
|
---|
428 | }
|
---|
429 | mainBinding = parseInt(binding.substr(1), 10);
|
---|
430 | return '';
|
---|
431 | });
|
---|
432 | const parts = i18nParseTextIntoPartsAndICU(pattern);
|
---|
433 | // Looking for (key block)+ sequence. One of the keys has to be "other".
|
---|
434 | for (let pos = 0; pos < parts.length;) {
|
---|
435 | let key = parts[pos++].trim();
|
---|
436 | if (icuType === 1 /* plural */) {
|
---|
437 | // Key can be "=x", we just want "x"
|
---|
438 | key = key.replace(/\s*(?:=)?(\w+)\s*/, '$1');
|
---|
439 | }
|
---|
440 | if (key.length) {
|
---|
441 | cases.push(key);
|
---|
442 | }
|
---|
443 | const blocks = i18nParseTextIntoPartsAndICU(parts[pos++]);
|
---|
444 | if (cases.length > values.length) {
|
---|
445 | values.push(blocks);
|
---|
446 | }
|
---|
447 | }
|
---|
448 | // TODO(ocombe): support ICU expressions in attributes, see #21615
|
---|
449 | return { type: icuType, mainBinding: mainBinding, cases, values };
|
---|
450 | }
|
---|
451 | /**
|
---|
452 | * Breaks pattern into strings and top level {...} blocks.
|
---|
453 | * Can be used to break a message into text and ICU expressions, or to break an ICU expression
|
---|
454 | * into keys and cases. Original code from closure library, modified for Angular.
|
---|
455 | *
|
---|
456 | * @param pattern (sub)Pattern to be broken.
|
---|
457 | * @returns An `Array<string|IcuExpression>` where:
|
---|
458 | * - odd positions: `string` => text between ICU expressions
|
---|
459 | * - even positions: `ICUExpression` => ICU expression parsed into `ICUExpression` record.
|
---|
460 | */
|
---|
461 | export function i18nParseTextIntoPartsAndICU(pattern) {
|
---|
462 | if (!pattern) {
|
---|
463 | return [];
|
---|
464 | }
|
---|
465 | let prevPos = 0;
|
---|
466 | const braceStack = [];
|
---|
467 | const results = [];
|
---|
468 | const braces = /[{}]/g;
|
---|
469 | // lastIndex doesn't get set to 0 so we have to.
|
---|
470 | braces.lastIndex = 0;
|
---|
471 | let match;
|
---|
472 | while (match = braces.exec(pattern)) {
|
---|
473 | const pos = match.index;
|
---|
474 | if (match[0] == '}') {
|
---|
475 | braceStack.pop();
|
---|
476 | if (braceStack.length == 0) {
|
---|
477 | // End of the block.
|
---|
478 | const block = pattern.substring(prevPos, pos);
|
---|
479 | if (ICU_BLOCK_REGEXP.test(block)) {
|
---|
480 | results.push(parseICUBlock(block));
|
---|
481 | }
|
---|
482 | else {
|
---|
483 | results.push(block);
|
---|
484 | }
|
---|
485 | prevPos = pos + 1;
|
---|
486 | }
|
---|
487 | }
|
---|
488 | else {
|
---|
489 | if (braceStack.length == 0) {
|
---|
490 | const substring = pattern.substring(prevPos, pos);
|
---|
491 | results.push(substring);
|
---|
492 | prevPos = pos + 1;
|
---|
493 | }
|
---|
494 | braceStack.push('{');
|
---|
495 | }
|
---|
496 | }
|
---|
497 | const substring = pattern.substring(prevPos);
|
---|
498 | results.push(substring);
|
---|
499 | return results;
|
---|
500 | }
|
---|
501 | /**
|
---|
502 | * Parses a node, its children and its siblings, and generates the mutate & update OpCodes.
|
---|
503 | *
|
---|
504 | */
|
---|
505 | export function parseIcuCase(tView, tIcu, lView, updateOpCodes, parentIdx, caseName, unsafeCaseHtml, nestedIcus) {
|
---|
506 | const create = [];
|
---|
507 | const remove = [];
|
---|
508 | const update = [];
|
---|
509 | if (ngDevMode) {
|
---|
510 | attachDebugGetter(create, icuCreateOpCodesToString);
|
---|
511 | attachDebugGetter(remove, i18nRemoveOpCodesToString);
|
---|
512 | attachDebugGetter(update, i18nUpdateOpCodesToString);
|
---|
513 | }
|
---|
514 | tIcu.cases.push(caseName);
|
---|
515 | tIcu.create.push(create);
|
---|
516 | tIcu.remove.push(remove);
|
---|
517 | tIcu.update.push(update);
|
---|
518 | const inertBodyHelper = getInertBodyHelper(getDocument());
|
---|
519 | const inertBodyElement = inertBodyHelper.getInertBodyElement(unsafeCaseHtml);
|
---|
520 | ngDevMode && assertDefined(inertBodyElement, 'Unable to generate inert body element');
|
---|
521 | const inertRootNode = getTemplateContent(inertBodyElement) || inertBodyElement;
|
---|
522 | if (inertRootNode) {
|
---|
523 | return walkIcuTree(tView, tIcu, lView, updateOpCodes, create, remove, update, inertRootNode, parentIdx, nestedIcus, 0);
|
---|
524 | }
|
---|
525 | else {
|
---|
526 | return 0;
|
---|
527 | }
|
---|
528 | }
|
---|
529 | function walkIcuTree(tView, tIcu, lView, sharedUpdateOpCodes, create, remove, update, parentNode, parentIdx, nestedIcus, depth) {
|
---|
530 | let bindingMask = 0;
|
---|
531 | let currentNode = parentNode.firstChild;
|
---|
532 | while (currentNode) {
|
---|
533 | const newIndex = allocExpando(tView, lView, 1, null);
|
---|
534 | switch (currentNode.nodeType) {
|
---|
535 | case Node.ELEMENT_NODE:
|
---|
536 | const element = currentNode;
|
---|
537 | const tagName = element.tagName.toLowerCase();
|
---|
538 | if (VALID_ELEMENTS.hasOwnProperty(tagName)) {
|
---|
539 | addCreateNodeAndAppend(create, ELEMENT_MARKER, tagName, parentIdx, newIndex);
|
---|
540 | tView.data[newIndex] = tagName;
|
---|
541 | const elAttrs = element.attributes;
|
---|
542 | for (let i = 0; i < elAttrs.length; i++) {
|
---|
543 | const attr = elAttrs.item(i);
|
---|
544 | const lowerAttrName = attr.name.toLowerCase();
|
---|
545 | const hasBinding = !!attr.value.match(BINDING_REGEXP);
|
---|
546 | // we assume the input string is safe, unless it's using a binding
|
---|
547 | if (hasBinding) {
|
---|
548 | if (VALID_ATTRS.hasOwnProperty(lowerAttrName)) {
|
---|
549 | if (URI_ATTRS[lowerAttrName]) {
|
---|
550 | generateBindingUpdateOpCodes(update, attr.value, newIndex, attr.name, 0, _sanitizeUrl);
|
---|
551 | }
|
---|
552 | else if (SRCSET_ATTRS[lowerAttrName]) {
|
---|
553 | generateBindingUpdateOpCodes(update, attr.value, newIndex, attr.name, 0, sanitizeSrcset);
|
---|
554 | }
|
---|
555 | else {
|
---|
556 | generateBindingUpdateOpCodes(update, attr.value, newIndex, attr.name, 0, null);
|
---|
557 | }
|
---|
558 | }
|
---|
559 | else {
|
---|
560 | ngDevMode &&
|
---|
561 | console.warn(`WARNING: ignoring unsafe attribute value ` +
|
---|
562 | `${lowerAttrName} on element ${tagName} ` +
|
---|
563 | `(see https://g.co/ng/security#xss)`);
|
---|
564 | }
|
---|
565 | }
|
---|
566 | else {
|
---|
567 | addCreateAttribute(create, newIndex, attr);
|
---|
568 | }
|
---|
569 | }
|
---|
570 | // Parse the children of this node (if any)
|
---|
571 | bindingMask = walkIcuTree(tView, tIcu, lView, sharedUpdateOpCodes, create, remove, update, currentNode, newIndex, nestedIcus, depth + 1) |
|
---|
572 | bindingMask;
|
---|
573 | addRemoveNode(remove, newIndex, depth);
|
---|
574 | }
|
---|
575 | break;
|
---|
576 | case Node.TEXT_NODE:
|
---|
577 | const value = currentNode.textContent || '';
|
---|
578 | const hasBinding = value.match(BINDING_REGEXP);
|
---|
579 | addCreateNodeAndAppend(create, null, hasBinding ? '' : value, parentIdx, newIndex);
|
---|
580 | addRemoveNode(remove, newIndex, depth);
|
---|
581 | if (hasBinding) {
|
---|
582 | bindingMask =
|
---|
583 | generateBindingUpdateOpCodes(update, value, newIndex, null, 0, null) | bindingMask;
|
---|
584 | }
|
---|
585 | break;
|
---|
586 | case Node.COMMENT_NODE:
|
---|
587 | // Check if the comment node is a placeholder for a nested ICU
|
---|
588 | const isNestedIcu = NESTED_ICU.exec(currentNode.textContent || '');
|
---|
589 | if (isNestedIcu) {
|
---|
590 | const nestedIcuIndex = parseInt(isNestedIcu[1], 10);
|
---|
591 | const icuExpression = nestedIcus[nestedIcuIndex];
|
---|
592 | // Create the comment node that will anchor the ICU expression
|
---|
593 | addCreateNodeAndAppend(create, ICU_MARKER, ngDevMode ? `nested ICU ${nestedIcuIndex}` : '', parentIdx, newIndex);
|
---|
594 | icuStart(tView, lView, sharedUpdateOpCodes, parentIdx, icuExpression, newIndex);
|
---|
595 | addRemoveNestedIcu(remove, newIndex, depth);
|
---|
596 | }
|
---|
597 | break;
|
---|
598 | }
|
---|
599 | currentNode = currentNode.nextSibling;
|
---|
600 | }
|
---|
601 | return bindingMask;
|
---|
602 | }
|
---|
603 | function addRemoveNode(remove, index, depth) {
|
---|
604 | if (depth === 0) {
|
---|
605 | remove.push(index);
|
---|
606 | }
|
---|
607 | }
|
---|
608 | function addRemoveNestedIcu(remove, index, depth) {
|
---|
609 | if (depth === 0) {
|
---|
610 | remove.push(~index); // remove ICU at `index`
|
---|
611 | remove.push(index); // remove ICU comment at `index`
|
---|
612 | }
|
---|
613 | }
|
---|
614 | function addUpdateIcuSwitch(update, icuExpression, index) {
|
---|
615 | update.push(toMaskBit(icuExpression.mainBinding), 2, -1 - icuExpression.mainBinding, index << 2 /* SHIFT_REF */ | 2 /* IcuSwitch */);
|
---|
616 | }
|
---|
617 | function addUpdateIcuUpdate(update, bindingMask, index) {
|
---|
618 | update.push(bindingMask, 1, index << 2 /* SHIFT_REF */ | 3 /* IcuUpdate */);
|
---|
619 | }
|
---|
620 | function addCreateNodeAndAppend(create, marker, text, appendToParentIdx, createAtIdx) {
|
---|
621 | if (marker !== null) {
|
---|
622 | create.push(marker);
|
---|
623 | }
|
---|
624 | create.push(text, createAtIdx, icuCreateOpCode(0 /* AppendChild */, appendToParentIdx, createAtIdx));
|
---|
625 | }
|
---|
626 | function addCreateAttribute(create, newIndex, attr) {
|
---|
627 | create.push(newIndex << 1 /* SHIFT_REF */ | 1 /* Attr */, attr.name, attr.value);
|
---|
628 | }
|
---|
629 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaTE4bl9wYXJzZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvcmUvc3JjL3JlbmRlcjMvaTE4bi9pMThuX3BhcnNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUNILE9BQU8sd0JBQXdCLENBQUM7QUFDaEMsT0FBTyxpQ0FBaUMsQ0FBQztBQUV6QyxPQUFPLEVBQUMsa0JBQWtCLEVBQUUsWUFBWSxFQUFFLFNBQVMsRUFBRSxXQUFXLEVBQUUsY0FBYyxFQUFDLE1BQU0s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pZiAoU1JDU0VUX0FUVFJTW2xvd2VyQXR0ck5hbWVdKSB7XG4gICAgICAgICAgICAgICAgICBnZW5lcmF0ZUJpbmRpbmdVcGRhdGVPcENvZGVzKFxuICAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZSwgYXR0ci52YWx1ZSwgbmV3SW5kZXgsIGF0dHIubmFtZSwgMCwgc2FuaXRpemVTcmNzZXQpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICBnZW5lcmF0ZUJpbmRpbmdVcGRhdGVPcENvZGVzKHVwZGF0ZSwgYXR0ci52YWx1ZSwgbmV3SW5kZXgsIGF0dHIubmFtZSwgMCwgbnVsbCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIG5nRGV2TW9kZSAmJlxuICAgICAgICAgICAgICAgICAgICBjb25zb2xlLndhcm4oXG4gICAgICAgICAgICAgICAgICAgICAgICBgV0FSTklORzogaWdub3JpbmcgdW5zYWZlIGF0dHJpYnV0ZSB2YWx1ZSBgICtcbiAgICAgICAgICAgICAgICAgICAgICAgIGAke2xvd2VyQXR0ck5hbWV9IG9uIGVsZW1lbnQgJHt0YWdOYW1lfSBgICtcbiAgICAgICAgICAgICAgICAgICAgICAgIGAoc2VlIGh0dHBzOi8vZy5jby9uZy9zZWN1cml0eSN4c3MpYCk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIGFkZENyZWF0ZUF0dHJpYnV0ZShjcmVhdGUsIG5ld0luZGV4LCBhdHRyKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgLy8gUGFyc2UgdGhlIGNoaWxkcmVuIG9mIHRoaXMgbm9kZSAoaWYgYW55KVxuICAgICAgICAgIGJpbmRpbmdNYXNrID0gd2Fsa0ljdVRyZWUoXG4gICAgICAgICAgICAgICAgICAgICAgICAgICA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