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

Function locateRNodeByPath

packages/core/src/hydration/node_lookup_utils.ts:275–289  ·  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

273 * a starting point node info).
274 */
275function locateRNodeByPath(path: string, lView: LView): RNode {
276 const [referenceNode, ...navigationInstructions] = decompressNodeLocation(path);
277 let ref: Element;
278 if (referenceNode === REFERENCE_NODE_HOST) {
279 ref = lView[DECLARATION_COMPONENT_VIEW][HOST] as unknown as Element;
280 } else if (referenceNode === REFERENCE_NODE_BODY) {
281 ref = ɵɵresolveBody(
282 lView[DECLARATION_COMPONENT_VIEW][HOST] as RElement & {ownerDocument: Document},
283 ) as Element;
284 } else {
285 const parentElementId = Number(referenceNode);
286 ref = unwrapRNode((lView as any)[parentElementId + HEADER_OFFSET]) as Element;
287 }
288 return navigateToNode(ref, navigationInstructions);
289}
290
291/**
292 * 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