Skip to content

Commit a3028e2

Browse files
atscottalxhub
authored andcommitted
refactor(core): Remove RootViewRef<T> because it is the same as ViewRef<T> (angular#52430)
`RootViewRef<T>` extends `ViewRef<T>` and overrides 3 methods with behavior that is identical to `ViewRef<T>`. This commit removes `RootViewRef<T>` because it is not needed. PR Close angular#52430
1 parent a568bc5 commit a3028e2

File tree

13 files changed

+44
-130
lines changed

13 files changed

+44
-130
lines changed

packages/core/src/render3/component_ref.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import {computeStaticStyling} from './styling/static_styling';
5151
import {mergeHostAttrs, setUpAttributes} from './util/attrs_utils';
5252
import {debugStringifyTypeForError, stringifyForError} from './util/stringify_utils';
5353
import {getComponentLViewByIndex, getNativeByTNode, getTNode} from './util/view_utils';
54-
import {InternalViewRef, RootViewRef} from './view_ref';
54+
import {InternalViewRef} from './view_ref';
5555

5656
export class ComponentFactoryResolver extends AbstractComponentFactoryResolver {
5757
/**
@@ -319,7 +319,11 @@ export class ComponentRef<T> extends AbstractComponentRef<T> {
319319
private _tNode: TElementNode|TContainerNode|TElementContainerNode) {
320320
super();
321321
this.instance = instance;
322-
this.hostView = this.changeDetectorRef = new RootViewRef<T>(_rootLView);
322+
this.hostView = this.changeDetectorRef = new InternalViewRef<T>(
323+
_rootLView,
324+
undefined, /* _cdRefInjectingView */
325+
false, /* notifyErrorHandler */
326+
);
323327
this.componentType = componentType;
324328
}
325329

packages/core/src/render3/view_ref.ts

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class InternalViewRef<T> implements EmbeddedViewRef<T>, ChangeDetectorRef
5555
*
5656
* This may be different from `_lView` if the `_cdRefInjectingView` is an embedded view.
5757
*/
58-
private _cdRefInjectingView?: LView) {}
58+
private _cdRefInjectingView?: LView, private readonly notifyErrorHandler = true) {}
5959

6060
get context(): T {
6161
return this._lView[CONTEXT] as unknown as T;
@@ -282,7 +282,8 @@ export class InternalViewRef<T> implements EmbeddedViewRef<T>, ChangeDetectorRef
282282
* See {@link ChangeDetectorRef#detach} for more information.
283283
*/
284284
detectChanges(): void {
285-
detectChangesInternal(this._lView[TVIEW], this._lView, this.context as unknown as {});
285+
detectChangesInternal(
286+
this._lView[TVIEW], this._lView, this.context as unknown as {}, this.notifyErrorHandler);
286287
}
287288

288289
/**
@@ -293,7 +294,8 @@ export class InternalViewRef<T> implements EmbeddedViewRef<T>, ChangeDetectorRef
293294
*/
294295
checkNoChanges(): void {
295296
if (ngDevMode) {
296-
checkNoChangesInternal(this._lView[TVIEW], this._lView, this.context as unknown as {});
297+
checkNoChangesInternal(
298+
this._lView[TVIEW], this._lView, this.context as unknown as {}, this.notifyErrorHandler);
297299
}
298300
}
299301

@@ -320,29 +322,3 @@ export class InternalViewRef<T> implements EmbeddedViewRef<T>, ChangeDetectorRef
320322
this._appRef = appRef;
321323
}
322324
}
323-
324-
export class RootViewRef<T> extends InternalViewRef<T> {
325-
constructor(public _view: LView) {
326-
super(_view);
327-
}
328-
329-
override detectChanges(): void {
330-
const lView = this._view;
331-
const tView = lView[TVIEW];
332-
const context = lView[CONTEXT];
333-
detectChangesInternal(tView, lView, context, false);
334-
}
335-
336-
override checkNoChanges(): void {
337-
if (ngDevMode) {
338-
const lView = this._view;
339-
const tView = lView[TVIEW];
340-
const context = lView[CONTEXT];
341-
checkNoChangesInternal(tView, lView, context, false);
342-
}
343-
}
344-
345-
override get context(): T {
346-
return null!;
347-
}
348-
}

packages/core/test/bundling/animations-standalone/bundle.golden_symbols.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@
269269
{
270270
"name": "Injector"
271271
},
272+
{
273+
"name": "InternalViewRef"
274+
},
272275
{
273276
"name": "LEAVE_TOKEN_REGEX"
274277
},
@@ -443,9 +446,6 @@
443446
{
444447
"name": "RendererStyleFlags2"
445448
},
446-
{
447-
"name": "RootViewRef"
448-
},
449449
{
450450
"name": "RuntimeError"
451451
},
@@ -548,9 +548,6 @@
548548
{
549549
"name": "ViewEncapsulation"
550550
},
551-
{
552-
"name": "ViewRef"
553-
},
554551
{
555552
"name": "WebAnimationsDriver"
556553
},
@@ -824,9 +821,6 @@
824821
{
825822
"name": "detectChangesInViewIfAttached"
826823
},
827-
{
828-
"name": "detectChangesInternal"
829-
},
830824
{
831825
"name": "diPublicInInjector"
832826
},

packages/core/test/bundling/animations/bundle.golden_symbols.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@
290290
{
291291
"name": "Injector"
292292
},
293+
{
294+
"name": "InternalViewRef"
295+
},
293296
{
294297
"name": "KeyEventsPlugin"
295298
},
@@ -485,9 +488,6 @@
485488
{
486489
"name": "RootComponent"
487490
},
488-
{
489-
"name": "RootViewRef"
490-
},
491491
{
492492
"name": "RuntimeError"
493493
},
@@ -602,9 +602,6 @@
602602
{
603603
"name": "ViewEncapsulation"
604604
},
605-
{
606-
"name": "ViewRef"
607-
},
608605
{
609606
"name": "WebAnimationsDriver"
610607
},
@@ -887,9 +884,6 @@
887884
{
888885
"name": "detectChangesInViewIfAttached"
889886
},
890-
{
891-
"name": "detectChangesInternal"
892-
},
893887
{
894888
"name": "diPublicInInjector"
895889
},

packages/core/test/bundling/cyclic_import/bundle.golden_symbols.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@
194194
{
195195
"name": "Injector"
196196
},
197+
{
198+
"name": "InternalViewRef"
199+
},
197200
{
198201
"name": "KeyEventsPlugin"
199202
},
@@ -368,9 +371,6 @@
368371
{
369372
"name": "RendererStyleFlags2"
370373
},
371-
{
372-
"name": "RootViewRef"
373-
},
374374
{
375375
"name": "RuntimeError"
376376
},
@@ -458,9 +458,6 @@
458458
{
459459
"name": "ViewEncapsulation"
460460
},
461-
{
462-
"name": "ViewRef"
463-
},
464461
{
465462
"name": "ZONE_IS_STABLE_OBSERVABLE"
466463
},
@@ -668,9 +665,6 @@
668665
{
669666
"name": "detectChangesInViewIfAttached"
670667
},
671-
{
672-
"name": "detectChangesInternal"
673-
},
674668
{
675669
"name": "diPublicInInjector"
676670
},

packages/core/test/bundling/defer/bundle.golden_symbols.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@
227227
{
228228
"name": "Injector"
229229
},
230+
{
231+
"name": "InternalViewRef"
232+
},
230233
{
231234
"name": "KeyEventsPlugin"
232235
},
@@ -419,9 +422,6 @@
419422
{
420423
"name": "RendererStyleFlags2"
421424
},
422-
{
423-
"name": "RootViewRef"
424-
},
425425
{
426426
"name": "RuntimeError"
427427
},
@@ -509,9 +509,6 @@
509509
{
510510
"name": "ViewEncapsulation"
511511
},
512-
{
513-
"name": "ViewRef"
514-
},
515512
{
516513
"name": "ZONE_IS_STABLE_OBSERVABLE"
517514
},
@@ -758,9 +755,6 @@
758755
{
759756
"name": "detectChangesInViewIfAttached"
760757
},
761-
{
762-
"name": "detectChangesInternal"
763-
},
764758
{
765759
"name": "diPublicInInjector"
766760
},

packages/core/test/bundling/forms_reactive/bundle.golden_symbols.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@
272272
{
273273
"name": "Injector"
274274
},
275+
{
276+
"name": "InternalViewRef"
277+
},
275278
{
276279
"name": "IterableChangeRecord_"
277280
},
@@ -506,9 +509,6 @@
506509
{
507510
"name": "RootComponent"
508511
},
509-
{
510-
"name": "RootViewRef"
511-
},
512512
{
513513
"name": "RuntimeError"
514514
},
@@ -614,9 +614,6 @@
614614
{
615615
"name": "ViewEngineTemplateRef"
616616
},
617-
{
618-
"name": "ViewRef"
619-
},
620617
{
621618
"name": "ZONE_IS_STABLE_OBSERVABLE"
622619
},
@@ -911,9 +908,6 @@
911908
{
912909
"name": "detectChangesInViewIfAttached"
913910
},
914-
{
915-
"name": "detectChangesInternal"
916-
},
917911
{
918912
"name": "diPublicInInjector"
919913
},

packages/core/test/bundling/forms_template_driven/bundle.golden_symbols.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@
257257
{
258258
"name": "Injector"
259259
},
260+
{
261+
"name": "InternalViewRef"
262+
},
260263
{
261264
"name": "IterableChangeRecord_"
262265
},
@@ -494,9 +497,6 @@
494497
{
495498
"name": "RootComponent"
496499
},
497-
{
498-
"name": "RootViewRef"
499-
},
500500
{
501501
"name": "RuntimeError"
502502
},
@@ -605,9 +605,6 @@
605605
{
606606
"name": "ViewEngineTemplateRef"
607607
},
608-
{
609-
"name": "ViewRef"
610-
},
611608
{
612609
"name": "ZONE_IS_STABLE_OBSERVABLE"
613610
},
@@ -881,9 +878,6 @@
881878
{
882879
"name": "detectChangesInViewIfAttached"
883880
},
884-
{
885-
"name": "detectChangesInternal"
886-
},
887881
{
888882
"name": "diPublicInInjector"
889883
},

packages/core/test/bundling/hello_world/bundle.golden_symbols.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@
137137
{
138138
"name": "Injector"
139139
},
140+
{
141+
"name": "InternalViewRef"
142+
},
140143
{
141144
"name": "LOCALE_ID2"
142145
},
@@ -281,9 +284,6 @@
281284
{
282285
"name": "RendererFactory2"
283286
},
284-
{
285-
"name": "RootViewRef"
286-
},
287287
{
288288
"name": "RuntimeError"
289289
},
@@ -350,9 +350,6 @@
350350
{
351351
"name": "ViewEncapsulation"
352352
},
353-
{
354-
"name": "ViewRef"
355-
},
356353
{
357354
"name": "ZONE_IS_STABLE_OBSERVABLE"
358355
},
@@ -527,9 +524,6 @@
527524
{
528525
"name": "detectChangesInViewIfAttached"
529526
},
530-
{
531-
"name": "detectChangesInternal"
532-
},
533527
{
534528
"name": "diPublicInInjector"
535529
},

0 commit comments

Comments
 (0)