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

Function collectI18nChildren

packages/core/src/hydration/i18n.ts:95–135  ·  view source on GitHub ↗
(tView: TView)

Source from the content-addressed store, hash-verified

93}
94
95function collectI18nChildren(tView: TView): Set<number> | null {
96 const children = new Set<number>();
97
98 function collectI18nViews(node: I18nNode) {
99 children.add(node.index);
100
101 switch (node.kind) {
102 case I18nNodeKind.ELEMENT:
103 case I18nNodeKind.PLACEHOLDER: {
104 for (const childNode of node.children) {
105 collectI18nViews(childNode);
106 }
107 break;
108 }
109
110 case I18nNodeKind.ICU: {
111 for (const caseNodes of node.cases) {
112 for (const caseNode of caseNodes) {
113 collectI18nViews(caseNode);
114 }
115 }
116 break;
117 }
118 }
119 }
120
121 // Traverse through the AST of each i18n block in the LView,
122 // and collect every instruction index.
123 for (let i = HEADER_OFFSET; i < tView.bindingStartIndex; i++) {
124 const tI18n = tView.data[i] as TI18n | undefined;
125 if (!tI18n || !tI18n.ast) {
126 continue;
127 }
128
129 for (const node of tI18n.ast) {
130 collectI18nViews(node);
131 }
132 }
133
134 return children.size === 0 ? null : children;
135}
136
137/**
138 * Resulting data from serializing an i18n block.

Callers 1

getOrComputeI18nChildrenFunction · 0.85

Calls 1

collectI18nViewsFunction · 0.85

Tested by

no test coverage detected