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

Function recreateMatchingLViews

packages/core/src/render3/hmr.ts:168–207  ·  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

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