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

Function recreateMatchingLViews

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

* Finds all LViews matching a specific component definition and recreates them. * @param importMeta `import.meta` information. * @param id HMR ID of the component. * @param oldDef Component definition to search for. * @param rootLView View from which to start the search.

(
  importMeta: ImportMetaExtended | null,
  id: string | null,
  newDef: ComponentDef<unknown>,
  oldDef: ComponentDef<unknown>,
  rootLView: LView,
)

Source from the content-addressed store, hash-verified

162 * @param rootLView View from which to start the search.
163 */
164function recreateMatchingLViews(
165 importMeta: ImportMetaExtended | null,
166 id: string | null,
167 newDef: ComponentDef<unknown>,
168 oldDef: ComponentDef<unknown>,
169 rootLView: LView,
170): void {
171 ngDevMode &&
172 assertDefined(
173 oldDef.tView,
174 'Expected a component definition that has been instantiated at least once',
175 );
176
177 const tView = rootLView[TVIEW];
178
179 // Use `tView` to match the LView since `instanceof` can
180 // produce false positives when using inheritance.
181 if (tView === oldDef.tView) {
182 ngDevMode && assertComponentDef(oldDef.type);
183 recreateLView(importMeta, id, newDef, oldDef, rootLView);
184 return;
185 }
186
187 for (let i = HEADER_OFFSET; i < tView.bindingStartIndex; i++) {
188 const current = rootLView[i];
189
190 if (isLContainer(current)) {
191 // The host can be an LView if a component is injecting `ViewContainerRef`.
192 if (isLView(current[HOST])) {
193 recreateMatchingLViews(importMeta, id, newDef, oldDef, current[HOST]);
194 }
195
196 for (let j = CONTAINER_HEADER_OFFSET; j < current.length; j++) {
197 recreateMatchingLViews(importMeta, id, newDef, oldDef, current[j]);
198 }
199 } else if (isLView(current)) {
200 recreateMatchingLViews(importMeta, id, newDef, oldDef, current);
201 }
202 }
203}
204
205/**
206 * Removes any cached renderers from the factory for the provided type.

Callers 1

ɵɵreplaceMetadataFunction · 0.85

Calls 5

assertDefinedFunction · 0.90
assertComponentDefFunction · 0.90
isLContainerFunction · 0.90
isLViewFunction · 0.90
recreateLViewFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…