MCPcopy Create free account
hub / github.com/angular/angular / parseIcuCase

Function parseIcuCase

packages/core/src/render3/i18n/i18n_parse.ts:741–787  ·  view source on GitHub ↗

* Parses a node, its children and its siblings, and generates the mutate & update OpCodes. *

(
  ast: I18nNode[],
  tView: TView,
  tIcu: TIcu,
  lView: LView,
  updateOpCodes: I18nUpdateOpCodes,
  parentIdx: number,
  caseName: string,
  unsafeCaseHtml: string,
  nestedIcus: IcuExpression[],
)

Source from the content-addressed store, hash-verified

739 *
740 */
741function parseIcuCase(
742 ast: I18nNode[],
743 tView: TView,
744 tIcu: TIcu,
745 lView: LView,
746 updateOpCodes: I18nUpdateOpCodes,
747 parentIdx: number,
748 caseName: string,
749 unsafeCaseHtml: string,
750 nestedIcus: IcuExpression[],
751): number {
752 const create: IcuCreateOpCodes = [] as any;
753 const remove: I18nRemoveOpCodes = [] as any;
754 const update: I18nUpdateOpCodes = [] as any;
755 if (ngDevMode) {
756 attachDebugGetter(create, icuCreateOpCodesToString);
757 attachDebugGetter(remove, i18nRemoveOpCodesToString);
758 attachDebugGetter(update, i18nUpdateOpCodesToString);
759 }
760 tIcu.cases.push(caseName);
761 tIcu.create.push(create);
762 tIcu.remove.push(remove);
763 tIcu.update.push(update);
764
765 const inertBodyHelper = getInertBodyHelper(getDocument());
766 const inertBodyElement = inertBodyHelper.getInertBodyElement(unsafeCaseHtml);
767 ngDevMode && assertDefined(inertBodyElement, 'Unable to generate inert body element');
768 const inertRootNode = (getTemplateContent(inertBodyElement!) as Element) || inertBodyElement;
769 if (inertRootNode) {
770 return walkIcuTree(
771 ast,
772 tView,
773 tIcu,
774 lView,
775 updateOpCodes,
776 create,
777 remove,
778 update,
779 inertRootNode,
780 parentIdx,
781 nestedIcus,
782 0,
783 );
784 } else {
785 return 0;
786 }
787}
788
789function walkIcuTree(
790 ast: I18nNode[],

Callers 1

icuStartFunction · 0.85

Calls 8

getInertBodyHelperFunction · 0.90
getDocumentFunction · 0.90
assertDefinedFunction · 0.90
getTemplateContentFunction · 0.90
attachDebugGetterFunction · 0.85
walkIcuTreeFunction · 0.85
pushMethod · 0.45
getInertBodyElementMethod · 0.45

Tested by

no test coverage detected