( ast: I18nNode[], tView: TView, tIcu: TIcu, lView: LView, sharedUpdateOpCodes: I18nUpdateOpCodes, create: IcuCreateOpCodes, remove: I18nRemoveOpCodes, update: I18nUpdateOpCodes, parentNode: Element, parentIdx: number, nestedIcus: IcuExpression[], depth: number, )
| 798 | } |
| 799 | |
| 800 | function walkIcuTree( |
| 801 | ast: I18nNode[], |
| 802 | tView: TView, |
| 803 | tIcu: TIcu, |
| 804 | lView: LView, |
| 805 | sharedUpdateOpCodes: I18nUpdateOpCodes, |
| 806 | create: IcuCreateOpCodes, |
| 807 | remove: I18nRemoveOpCodes, |
| 808 | update: I18nUpdateOpCodes, |
| 809 | parentNode: Element, |
| 810 | parentIdx: number, |
| 811 | nestedIcus: IcuExpression[], |
| 812 | depth: number, |
| 813 | ): number { |
| 814 | let bindingMask = 0; |
| 815 | let currentNode = getFirstChild(parentNode); |
| 816 | while (currentNode) { |
| 817 | const newIndex = allocExpando(tView, lView, 1, null); |
| 818 | switch (currentNode.nodeType) { |
| 819 | case Node.ELEMENT_NODE: |
| 820 | const element = currentNode as Element; |
| 821 | const tagName = getNodeName(element).toLowerCase(); |
| 822 | if (Object.hasOwn(VALID_ELEMENTS, tagName)) { |
| 823 | addCreateNodeAndAppend(create, ELEMENT_MARKER, tagName, parentIdx, newIndex); |
| 824 | tView.data[newIndex] = tagName; |
| 825 | const elAttrs = element.attributes; |
| 826 | for (let i = 0; i < elAttrs.length; i++) { |
| 827 | const attr = elAttrs.item(i)!; |
| 828 | if (ngDevMode && isBindingLikeAttributeName(attr.name)) { |
| 829 | // Directives and bindings are not supported inside ICU expressions, since ICU |
| 830 | // content is processed at runtime as plain HTML. Such attributes are dropped |
| 831 | // below as unknown attributes; explain why instead of reporting them as unsafe. |
| 832 | console.warn( |
| 833 | formatRuntimeError( |
| 834 | RuntimeErrorCode.INVALID_I18N_STRUCTURE, |
| 835 | `ICU expressions cannot contain bindings or structural directives. ` + |
| 836 | `The attribute "${attr.name}" on the <${tagName}> element inside an ICU ` + |
| 837 | `expression is not supported and will be ignored. ` + |
| 838 | `Only static attributes are allowed inside ICU cases.`, |
| 839 | ), |
| 840 | ); |
| 841 | continue; |
| 842 | } |
| 843 | const lowerAttrName = attr.name.toLowerCase(); |
| 844 | const hasBinding = !!attr.value.match(BINDING_REGEXP); |
| 845 | const namespaceUri = element.namespaceURI; |
| 846 | const namespace = namespaceUri && NAMESPACE_URIS[namespaceUri]; |
| 847 | const tagNameWithNamespace = namespace ? `:${namespace}:${tagName}` : tagName; |
| 848 | |
| 849 | if (hasBinding) { |
| 850 | if (Object.hasOwn(VALID_ATTRS, lowerAttrName)) { |
| 851 | generateBindingUpdateOpCodes( |
| 852 | update, |
| 853 | attr.value, |
| 854 | newIndex, |
| 855 | attr.name, |
| 856 | 0, |
| 857 | i18nResolveSanitizer(lowerAttrName, tagNameWithNamespace), |
no test coverage detected