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

Function locateRNodeByPath

packages/core/src/hydration/node_lookup_utils.ts:274–288  ·  view source on GitHub ↗

* Locates an RNode given a set of navigation instructions (which also contains * a starting point node info).

(path: string, lView: LView)

Source from the content-addressed store, hash-verified

272 * a starting point node info).
273 */
274function locateRNodeByPath(path: string, lView: LView): RNode {
275 const [referenceNode, ...navigationInstructions] = decompressNodeLocation(path);
276 let ref: Element;
277 if (referenceNode === REFERENCE_NODE_HOST) {
278 ref = lView[DECLARATION_COMPONENT_VIEW][HOST] as unknown as Element;
279 } else if (referenceNode === REFERENCE_NODE_BODY) {
280 ref = ɵɵresolveBody(
281 lView[DECLARATION_COMPONENT_VIEW][HOST] as RElement & {ownerDocument: Document},
282 ) as Element;
283 } else {
284 const parentElementId = Number(referenceNode);
285 ref = unwrapRNode((lView as any)[parentElementId + HEADER_OFFSET]) as Element;
286 }
287 return navigateToNode(ref, navigationInstructions);
288}
289
290/**
291 * Generate a list of DOM navigation operations to get from node `start` to node `finish`.

Callers 2

tryLocateRNodeByPathFunction · 0.85
locateNextRNodeFunction · 0.85

Calls 4

decompressNodeLocationFunction · 0.90
ɵɵresolveBodyFunction · 0.90
unwrapRNodeFunction · 0.90
navigateToNodeFunction · 0.85

Tested by

no test coverage detected