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

Function collectI18nChildren

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

Source from the content-addressed store, hash-verified

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

Callers 1

getOrComputeI18nChildrenFunction · 0.85

Calls 1

collectI18nViewsFunction · 0.85

Tested by

no test coverage detected