mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
refactor(core): Remove RootViewRef<T> because it is the same as ViewRef<T> (#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 #52430
This commit is contained in:
committed by
Alex Rickabaugh
parent
a568bc5d97
commit
a3028e2340
@@ -51,7 +51,7 @@ import {computeStaticStyling} from './styling/static_styling';
|
||||
import {mergeHostAttrs, setUpAttributes} from './util/attrs_utils';
|
||||
import {debugStringifyTypeForError, stringifyForError} from './util/stringify_utils';
|
||||
import {getComponentLViewByIndex, getNativeByTNode, getTNode} from './util/view_utils';
|
||||
import {InternalViewRef, RootViewRef} from './view_ref';
|
||||
import {InternalViewRef} from './view_ref';
|
||||
|
||||
export class ComponentFactoryResolver extends AbstractComponentFactoryResolver {
|
||||
/**
|
||||
@@ -319,7 +319,11 @@ export class ComponentRef<T> extends AbstractComponentRef<T> {
|
||||
private _tNode: TElementNode|TContainerNode|TElementContainerNode) {
|
||||
super();
|
||||
this.instance = instance;
|
||||
this.hostView = this.changeDetectorRef = new RootViewRef<T>(_rootLView);
|
||||
this.hostView = this.changeDetectorRef = new InternalViewRef<T>(
|
||||
_rootLView,
|
||||
undefined, /* _cdRefInjectingView */
|
||||
false, /* notifyErrorHandler */
|
||||
);
|
||||
this.componentType = componentType;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ export class InternalViewRef<T> implements EmbeddedViewRef<T>, ChangeDetectorRef
|
||||
*
|
||||
* This may be different from `_lView` if the `_cdRefInjectingView` is an embedded view.
|
||||
*/
|
||||
private _cdRefInjectingView?: LView) {}
|
||||
private _cdRefInjectingView?: LView, private readonly notifyErrorHandler = true) {}
|
||||
|
||||
get context(): T {
|
||||
return this._lView[CONTEXT] as unknown as T;
|
||||
@@ -282,7 +282,8 @@ export class InternalViewRef<T> implements EmbeddedViewRef<T>, ChangeDetectorRef
|
||||
* See {@link ChangeDetectorRef#detach} for more information.
|
||||
*/
|
||||
detectChanges(): void {
|
||||
detectChangesInternal(this._lView[TVIEW], this._lView, this.context as unknown as {});
|
||||
detectChangesInternal(
|
||||
this._lView[TVIEW], this._lView, this.context as unknown as {}, this.notifyErrorHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -293,7 +294,8 @@ export class InternalViewRef<T> implements EmbeddedViewRef<T>, ChangeDetectorRef
|
||||
*/
|
||||
checkNoChanges(): void {
|
||||
if (ngDevMode) {
|
||||
checkNoChangesInternal(this._lView[TVIEW], this._lView, this.context as unknown as {});
|
||||
checkNoChangesInternal(
|
||||
this._lView[TVIEW], this._lView, this.context as unknown as {}, this.notifyErrorHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,29 +322,3 @@ export class InternalViewRef<T> implements EmbeddedViewRef<T>, ChangeDetectorRef
|
||||
this._appRef = appRef;
|
||||
}
|
||||
}
|
||||
|
||||
export class RootViewRef<T> extends InternalViewRef<T> {
|
||||
constructor(public _view: LView) {
|
||||
super(_view);
|
||||
}
|
||||
|
||||
override detectChanges(): void {
|
||||
const lView = this._view;
|
||||
const tView = lView[TVIEW];
|
||||
const context = lView[CONTEXT];
|
||||
detectChangesInternal(tView, lView, context, false);
|
||||
}
|
||||
|
||||
override checkNoChanges(): void {
|
||||
if (ngDevMode) {
|
||||
const lView = this._view;
|
||||
const tView = lView[TVIEW];
|
||||
const context = lView[CONTEXT];
|
||||
checkNoChangesInternal(tView, lView, context, false);
|
||||
}
|
||||
}
|
||||
|
||||
override get context(): T {
|
||||
return null!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,6 +269,9 @@
|
||||
{
|
||||
"name": "Injector"
|
||||
},
|
||||
{
|
||||
"name": "InternalViewRef"
|
||||
},
|
||||
{
|
||||
"name": "LEAVE_TOKEN_REGEX"
|
||||
},
|
||||
@@ -443,9 +446,6 @@
|
||||
{
|
||||
"name": "RendererStyleFlags2"
|
||||
},
|
||||
{
|
||||
"name": "RootViewRef"
|
||||
},
|
||||
{
|
||||
"name": "RuntimeError"
|
||||
},
|
||||
@@ -548,9 +548,6 @@
|
||||
{
|
||||
"name": "ViewEncapsulation"
|
||||
},
|
||||
{
|
||||
"name": "ViewRef"
|
||||
},
|
||||
{
|
||||
"name": "WebAnimationsDriver"
|
||||
},
|
||||
@@ -824,9 +821,6 @@
|
||||
{
|
||||
"name": "detectChangesInViewIfAttached"
|
||||
},
|
||||
{
|
||||
"name": "detectChangesInternal"
|
||||
},
|
||||
{
|
||||
"name": "diPublicInInjector"
|
||||
},
|
||||
|
||||
@@ -290,6 +290,9 @@
|
||||
{
|
||||
"name": "Injector"
|
||||
},
|
||||
{
|
||||
"name": "InternalViewRef"
|
||||
},
|
||||
{
|
||||
"name": "KeyEventsPlugin"
|
||||
},
|
||||
@@ -485,9 +488,6 @@
|
||||
{
|
||||
"name": "RootComponent"
|
||||
},
|
||||
{
|
||||
"name": "RootViewRef"
|
||||
},
|
||||
{
|
||||
"name": "RuntimeError"
|
||||
},
|
||||
@@ -602,9 +602,6 @@
|
||||
{
|
||||
"name": "ViewEncapsulation"
|
||||
},
|
||||
{
|
||||
"name": "ViewRef"
|
||||
},
|
||||
{
|
||||
"name": "WebAnimationsDriver"
|
||||
},
|
||||
@@ -887,9 +884,6 @@
|
||||
{
|
||||
"name": "detectChangesInViewIfAttached"
|
||||
},
|
||||
{
|
||||
"name": "detectChangesInternal"
|
||||
},
|
||||
{
|
||||
"name": "diPublicInInjector"
|
||||
},
|
||||
|
||||
@@ -194,6 +194,9 @@
|
||||
{
|
||||
"name": "Injector"
|
||||
},
|
||||
{
|
||||
"name": "InternalViewRef"
|
||||
},
|
||||
{
|
||||
"name": "KeyEventsPlugin"
|
||||
},
|
||||
@@ -368,9 +371,6 @@
|
||||
{
|
||||
"name": "RendererStyleFlags2"
|
||||
},
|
||||
{
|
||||
"name": "RootViewRef"
|
||||
},
|
||||
{
|
||||
"name": "RuntimeError"
|
||||
},
|
||||
@@ -458,9 +458,6 @@
|
||||
{
|
||||
"name": "ViewEncapsulation"
|
||||
},
|
||||
{
|
||||
"name": "ViewRef"
|
||||
},
|
||||
{
|
||||
"name": "ZONE_IS_STABLE_OBSERVABLE"
|
||||
},
|
||||
@@ -668,9 +665,6 @@
|
||||
{
|
||||
"name": "detectChangesInViewIfAttached"
|
||||
},
|
||||
{
|
||||
"name": "detectChangesInternal"
|
||||
},
|
||||
{
|
||||
"name": "diPublicInInjector"
|
||||
},
|
||||
|
||||
@@ -227,6 +227,9 @@
|
||||
{
|
||||
"name": "Injector"
|
||||
},
|
||||
{
|
||||
"name": "InternalViewRef"
|
||||
},
|
||||
{
|
||||
"name": "KeyEventsPlugin"
|
||||
},
|
||||
@@ -419,9 +422,6 @@
|
||||
{
|
||||
"name": "RendererStyleFlags2"
|
||||
},
|
||||
{
|
||||
"name": "RootViewRef"
|
||||
},
|
||||
{
|
||||
"name": "RuntimeError"
|
||||
},
|
||||
@@ -509,9 +509,6 @@
|
||||
{
|
||||
"name": "ViewEncapsulation"
|
||||
},
|
||||
{
|
||||
"name": "ViewRef"
|
||||
},
|
||||
{
|
||||
"name": "ZONE_IS_STABLE_OBSERVABLE"
|
||||
},
|
||||
@@ -758,9 +755,6 @@
|
||||
{
|
||||
"name": "detectChangesInViewIfAttached"
|
||||
},
|
||||
{
|
||||
"name": "detectChangesInternal"
|
||||
},
|
||||
{
|
||||
"name": "diPublicInInjector"
|
||||
},
|
||||
|
||||
@@ -272,6 +272,9 @@
|
||||
{
|
||||
"name": "Injector"
|
||||
},
|
||||
{
|
||||
"name": "InternalViewRef"
|
||||
},
|
||||
{
|
||||
"name": "IterableChangeRecord_"
|
||||
},
|
||||
@@ -506,9 +509,6 @@
|
||||
{
|
||||
"name": "RootComponent"
|
||||
},
|
||||
{
|
||||
"name": "RootViewRef"
|
||||
},
|
||||
{
|
||||
"name": "RuntimeError"
|
||||
},
|
||||
@@ -614,9 +614,6 @@
|
||||
{
|
||||
"name": "ViewEngineTemplateRef"
|
||||
},
|
||||
{
|
||||
"name": "ViewRef"
|
||||
},
|
||||
{
|
||||
"name": "ZONE_IS_STABLE_OBSERVABLE"
|
||||
},
|
||||
@@ -911,9 +908,6 @@
|
||||
{
|
||||
"name": "detectChangesInViewIfAttached"
|
||||
},
|
||||
{
|
||||
"name": "detectChangesInternal"
|
||||
},
|
||||
{
|
||||
"name": "diPublicInInjector"
|
||||
},
|
||||
|
||||
@@ -257,6 +257,9 @@
|
||||
{
|
||||
"name": "Injector"
|
||||
},
|
||||
{
|
||||
"name": "InternalViewRef"
|
||||
},
|
||||
{
|
||||
"name": "IterableChangeRecord_"
|
||||
},
|
||||
@@ -494,9 +497,6 @@
|
||||
{
|
||||
"name": "RootComponent"
|
||||
},
|
||||
{
|
||||
"name": "RootViewRef"
|
||||
},
|
||||
{
|
||||
"name": "RuntimeError"
|
||||
},
|
||||
@@ -605,9 +605,6 @@
|
||||
{
|
||||
"name": "ViewEngineTemplateRef"
|
||||
},
|
||||
{
|
||||
"name": "ViewRef"
|
||||
},
|
||||
{
|
||||
"name": "ZONE_IS_STABLE_OBSERVABLE"
|
||||
},
|
||||
@@ -881,9 +878,6 @@
|
||||
{
|
||||
"name": "detectChangesInViewIfAttached"
|
||||
},
|
||||
{
|
||||
"name": "detectChangesInternal"
|
||||
},
|
||||
{
|
||||
"name": "diPublicInInjector"
|
||||
},
|
||||
|
||||
@@ -137,6 +137,9 @@
|
||||
{
|
||||
"name": "Injector"
|
||||
},
|
||||
{
|
||||
"name": "InternalViewRef"
|
||||
},
|
||||
{
|
||||
"name": "LOCALE_ID2"
|
||||
},
|
||||
@@ -281,9 +284,6 @@
|
||||
{
|
||||
"name": "RendererFactory2"
|
||||
},
|
||||
{
|
||||
"name": "RootViewRef"
|
||||
},
|
||||
{
|
||||
"name": "RuntimeError"
|
||||
},
|
||||
@@ -350,9 +350,6 @@
|
||||
{
|
||||
"name": "ViewEncapsulation"
|
||||
},
|
||||
{
|
||||
"name": "ViewRef"
|
||||
},
|
||||
{
|
||||
"name": "ZONE_IS_STABLE_OBSERVABLE"
|
||||
},
|
||||
@@ -527,9 +524,6 @@
|
||||
{
|
||||
"name": "detectChangesInViewIfAttached"
|
||||
},
|
||||
{
|
||||
"name": "detectChangesInternal"
|
||||
},
|
||||
{
|
||||
"name": "diPublicInInjector"
|
||||
},
|
||||
|
||||
@@ -245,6 +245,9 @@
|
||||
{
|
||||
"name": "Injector"
|
||||
},
|
||||
{
|
||||
"name": "InternalViewRef"
|
||||
},
|
||||
{
|
||||
"name": "LOCALE_ID2"
|
||||
},
|
||||
@@ -428,9 +431,6 @@
|
||||
{
|
||||
"name": "RendererStyleFlags2"
|
||||
},
|
||||
{
|
||||
"name": "RootViewRef"
|
||||
},
|
||||
{
|
||||
"name": "RuntimeError"
|
||||
},
|
||||
@@ -539,9 +539,6 @@
|
||||
{
|
||||
"name": "ViewEncapsulation"
|
||||
},
|
||||
{
|
||||
"name": "ViewRef"
|
||||
},
|
||||
{
|
||||
"name": "ZONE_IS_STABLE_OBSERVABLE"
|
||||
},
|
||||
@@ -752,9 +749,6 @@
|
||||
{
|
||||
"name": "detectChangesInViewIfAttached"
|
||||
},
|
||||
{
|
||||
"name": "detectChangesInternal"
|
||||
},
|
||||
{
|
||||
"name": "diPublicInInjector"
|
||||
},
|
||||
|
||||
@@ -323,6 +323,9 @@
|
||||
{
|
||||
"name": "InnerSubscriber"
|
||||
},
|
||||
{
|
||||
"name": "InternalViewRef"
|
||||
},
|
||||
{
|
||||
"name": "ItemComponent"
|
||||
},
|
||||
@@ -629,9 +632,6 @@
|
||||
{
|
||||
"name": "ResolveStart"
|
||||
},
|
||||
{
|
||||
"name": "RootViewRef"
|
||||
},
|
||||
{
|
||||
"name": "RouteConfigLoadEnd"
|
||||
},
|
||||
@@ -845,9 +845,6 @@
|
||||
{
|
||||
"name": "ViewEngineTemplateRef"
|
||||
},
|
||||
{
|
||||
"name": "ViewRef"
|
||||
},
|
||||
{
|
||||
"name": "XSS_SECURITY_URL"
|
||||
},
|
||||
@@ -1181,9 +1178,6 @@
|
||||
{
|
||||
"name": "detectChangesInViewIfAttached"
|
||||
},
|
||||
{
|
||||
"name": "detectChangesInternal"
|
||||
},
|
||||
{
|
||||
"name": "diPublicInInjector"
|
||||
},
|
||||
|
||||
@@ -179,6 +179,9 @@
|
||||
{
|
||||
"name": "Injector"
|
||||
},
|
||||
{
|
||||
"name": "InternalViewRef"
|
||||
},
|
||||
{
|
||||
"name": "LOCALE_ID2"
|
||||
},
|
||||
@@ -332,9 +335,6 @@
|
||||
{
|
||||
"name": "RendererStyleFlags2"
|
||||
},
|
||||
{
|
||||
"name": "RootViewRef"
|
||||
},
|
||||
{
|
||||
"name": "RuntimeError"
|
||||
},
|
||||
@@ -410,9 +410,6 @@
|
||||
{
|
||||
"name": "ViewEncapsulation"
|
||||
},
|
||||
{
|
||||
"name": "ViewRef"
|
||||
},
|
||||
{
|
||||
"name": "ZONE_IS_STABLE_OBSERVABLE"
|
||||
},
|
||||
@@ -599,9 +596,6 @@
|
||||
{
|
||||
"name": "detectChangesInViewIfAttached"
|
||||
},
|
||||
{
|
||||
"name": "detectChangesInternal"
|
||||
},
|
||||
{
|
||||
"name": "diPublicInInjector"
|
||||
},
|
||||
|
||||
@@ -197,6 +197,9 @@
|
||||
{
|
||||
"name": "Injector"
|
||||
},
|
||||
{
|
||||
"name": "InternalViewRef"
|
||||
},
|
||||
{
|
||||
"name": "IterableChangeRecord_"
|
||||
},
|
||||
@@ -395,9 +398,6 @@
|
||||
{
|
||||
"name": "RendererStyleFlags2"
|
||||
},
|
||||
{
|
||||
"name": "RootViewRef"
|
||||
},
|
||||
{
|
||||
"name": "RuntimeError"
|
||||
},
|
||||
@@ -530,9 +530,6 @@
|
||||
{
|
||||
"name": "ViewEngineTemplateRef"
|
||||
},
|
||||
{
|
||||
"name": "ViewRef"
|
||||
},
|
||||
{
|
||||
"name": "ZONE_IS_STABLE_OBSERVABLE"
|
||||
},
|
||||
@@ -797,9 +794,6 @@
|
||||
{
|
||||
"name": "detectChangesInViewIfAttached"
|
||||
},
|
||||
{
|
||||
"name": "detectChangesInternal"
|
||||
},
|
||||
{
|
||||
"name": "diPublicInInjector"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user