MCPcopy Index your code
hub / github.com/angular/angular / locateOrCreateNodeImpl

Function locateOrCreateNodeImpl

packages/core/src/render3/i18n/i18n_apply.ts:148–187  ·  view source on GitHub ↗
(
  lView: LView,
  index: number,
  textOrName: string,
  nodeType: typeof Node.COMMENT_NODE | typeof Node.TEXT_NODE | typeof Node.ELEMENT_NODE,
)

Source from the content-addressed store, hash-verified

146};
147
148function locateOrCreateNodeImpl(
149 lView: LView,
150 index: number,
151 textOrName: string,
152 nodeType: typeof Node.COMMENT_NODE | typeof Node.TEXT_NODE | typeof Node.ELEMENT_NODE,
153) {
154 const hydrationInfo = lView[HYDRATION];
155 const noOffsetIndex = index - HEADER_OFFSET;
156 const isNodeCreationMode =
157 !isI18nHydrationSupportEnabled() ||
158 !hydrationInfo ||
159 isInSkipHydrationBlock() ||
160 isDisconnectedNode(hydrationInfo, noOffsetIndex);
161
162 lastNodeWasCreated(isNodeCreationMode);
163 if (isNodeCreationMode) {
164 return createNodeWithoutHydration(lView, textOrName, nodeType);
165 }
166
167 const native = locateI18nRNodeByIndex(hydrationInfo!, noOffsetIndex) as RNode;
168
169 // TODO: Improve error handling
170 //
171 // Other hydration paths use validateMatchingNode() in order to provide
172 // detailed information in development mode about the expected DOM.
173 // However, not every node in an i18n block has a TNode. Instead, we
174 // need to be able to use the AST to generate a similar message.
175 ngDevMode && assertDefined(native, 'expected native element');
176 ngDevMode && assertEqual((native as Node).nodeType, nodeType, 'expected matching nodeType');
177 ngDevMode &&
178 nodeType === Node.ELEMENT_NODE &&
179 assertEqual(
180 (native as HTMLElement).tagName.toLowerCase(),
181 textOrName.toLowerCase(),
182 'expecting matching tagName',
183 );
184 ngDevMode && markRNodeAsClaimedByHydration(native);
185
186 return native;
187}
188
189export function enableLocateOrCreateI18nNodeImpl() {
190 _locateOrCreateNode = locateOrCreateNodeImpl;

Callers

nothing calls this directly

Calls 9

isInSkipHydrationBlockFunction · 0.90
isDisconnectedNodeFunction · 0.90
lastNodeWasCreatedFunction · 0.90
locateI18nRNodeByIndexFunction · 0.90
assertDefinedFunction · 0.90
assertEqualFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…