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

Function replaceLViewInTree

packages/core/src/render3/hmr.ts:355–389  ·  view source on GitHub ↗

* Replaces one LView in the tree with another one. * @param parentLView Parent of the LView being replaced. * @param oldLView LView being replaced. * @param newLView Replacement LView to be inserted. * @param index Index at which the LView should be inserted.

(
  parentLView: LView,
  oldLView: LView,
  newLView: LView,
  index: number,
)

Source from the content-addressed store, hash-verified

353 * @param index Index at which the LView should be inserted.
354 */
355function replaceLViewInTree(
356 parentLView: LView,
357 oldLView: LView,
358 newLView: LView,
359 index: number,
360): void {
361 // Update the sibling whose `NEXT` pointer refers to the old view.
362 for (let i = HEADER_OFFSET; i < parentLView[TVIEW].bindingStartIndex; i++) {
363 const current = parentLView[i];
364
365 if ((isLView(current) || isLContainer(current)) && current[NEXT] === oldLView) {
366 current[NEXT] = newLView;
367 break;
368 }
369 }
370
371 // Set the new view as the head, if the old view was first.
372 if (parentLView[CHILD_HEAD] === oldLView) {
373 parentLView[CHILD_HEAD] = newLView;
374 }
375
376 // Set the new view as the tail, if the old view was last.
377 if (parentLView[CHILD_TAIL] === oldLView) {
378 parentLView[CHILD_TAIL] = newLView;
379 }
380
381 // Update the `NEXT` pointer to the same as the old view.
382 newLView[NEXT] = oldLView[NEXT];
383
384 // Clear out the `NEXT` of the old view.
385 oldLView[NEXT] = null;
386
387 // Insert the new LView at the correct index.
388 parentLView[index] = newLView;
389}
390
391/**
392 * Child nodes mutate the `projection` state of their parent node as they're being projected.

Callers 1

recreateFunction · 0.85

Calls 2

isLViewFunction · 0.90
isLContainerFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…