(tView: TView, index: number, values: string[])
| 371 | * See `i18nAttributes` above. |
| 372 | */ |
| 373 | export function i18nAttributesFirstPass(tView: TView, index: number, values: string[]) { |
| 374 | const previousElement = getCurrentTNode()!; |
| 375 | const previousElementIndex = previousElement.index; |
| 376 | const updateOpCodes: I18nUpdateOpCodes = [] as any; |
| 377 | if (ngDevMode) { |
| 378 | attachDebugGetter(updateOpCodes, i18nUpdateOpCodesToString); |
| 379 | } |
| 380 | if (tView.firstCreatePass && tView.data[index] === null) { |
| 381 | for (let i = 0; i < values.length; i += 2) { |
| 382 | const attrName = values[i]; |
| 383 | const message = values[i + 1]; |
| 384 | |
| 385 | if (message !== '') { |
| 386 | // Check if attribute value contains an ICU and throw an error if that's the case. |
| 387 | // ICUs in element attributes are not supported. |
| 388 | // Note: we intentionally retain the error here by not using `ngDevMode`, because |
| 389 | // the `value` can change based on the locale and users aren't guaranteed to hit |
| 390 | // an invalid string while they're developing. |
| 391 | if (ICU_REGEXP.test(message)) { |
| 392 | throw new Error( |
| 393 | `ICU expressions are not supported in attributes. Message: "${message}".`, |
| 394 | ); |
| 395 | } |
| 396 | |
| 397 | // i18n attributes that hit this code path are guaranteed to have bindings, because |
| 398 | // the compiler treats static i18n attributes as regular attribute bindings. |
| 399 | // Since this may not be the first i18n attribute on this element we need to pass in how |
| 400 | // many previous bindings there have already been. |
| 401 | const tagName = previousElement.namespace |
| 402 | ? `:${previousElement.namespace}:${previousElement.value}` |
| 403 | : previousElement.value; |
| 404 | generateBindingUpdateOpCodes( |
| 405 | updateOpCodes, |
| 406 | message, |
| 407 | previousElementIndex, |
| 408 | attrName, |
| 409 | countBindings(updateOpCodes), |
| 410 | i18nResolveSanitizer(attrName, tagName), |
| 411 | ); |
| 412 | } |
| 413 | } |
| 414 | tView.data[index] = updateOpCodes; |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | /** |
| 419 | * Generate the OpCodes to update the bindings of a string. |
no test coverage detected