Skip to content

Commit

Permalink
Revert "refactor(core): Remove RootViewRef<T> because it is the same …
Browse files Browse the repository at this point in the history
…as ViewRef<T> (angular#52430)" (angular#52484)

This reverts commit a3028e2 as it breaks
tests in g3.

PR Close angular#52484
  • Loading branch information
alxhub committed Nov 1, 2023
1 parent 01b7935 commit cce84d2
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 11 deletions.
8 changes: 2 additions & 6 deletions packages/core/src/render3/component_ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {ViewRef} from './view_ref';
import {RootViewRef, ViewRef} from './view_ref';

export class ComponentFactoryResolver extends AbstractComponentFactoryResolver {
/**
Expand Down Expand Up @@ -319,11 +319,7 @@ export class ComponentRef<T> extends AbstractComponentRef<T> {
private _tNode: TElementNode|TContainerNode|TElementContainerNode) {
super();
this.instance = instance;
this.hostView = this.changeDetectorRef = new ViewRef<T>(
_rootLView,
undefined, /* _cdRefInjectingView */
false, /* notifyErrorHandler */
);
this.hostView = this.changeDetectorRef = new RootViewRef<T>(_rootLView);
this.componentType = componentType;
}

Expand Down
8 changes: 3 additions & 5 deletions packages/core/src/render3/view_ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class ViewRef<T> implements EmbeddedViewRef<T>, InternalViewRef, ChangeDe
*
* This may be different from `_lView` if the `_cdRefInjectingView` is an embedded view.
*/
private _cdRefInjectingView?: LView, private readonly notifyErrorHandler = true) {}
private _cdRefInjectingView?: LView) {}

get context(): T {
return this._lView[CONTEXT] as unknown as T;
Expand Down Expand Up @@ -284,8 +284,7 @@ export class ViewRef<T> implements EmbeddedViewRef<T>, InternalViewRef, ChangeDe
* See {@link ChangeDetectorRef#detach} for more information.
*/
detectChanges(): void {
detectChangesInternal(
this._lView[TVIEW], this._lView, this.context as unknown as {}, this.notifyErrorHandler);
detectChangesInternal(this._lView[TVIEW], this._lView, this.context as unknown as {});
}

/**
Expand All @@ -296,8 +295,7 @@ export class ViewRef<T> implements EmbeddedViewRef<T>, InternalViewRef, ChangeDe
*/
checkNoChanges(): void {
if (ngDevMode) {
checkNoChangesInternal(
this._lView[TVIEW], this._lView, this.context as unknown as {}, this.notifyErrorHandler);
checkNoChangesInternal(this._lView[TVIEW], this._lView, this.context as unknown as {});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,9 @@
{
"name": "RendererStyleFlags2"
},
{
"name": "RootViewRef"
},
{
"name": "RuntimeError"
},
Expand Down Expand Up @@ -821,6 +824,9 @@
{
"name": "detectChangesInViewIfAttached"
},
{
"name": "detectChangesInternal"
},
{
"name": "diPublicInInjector"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,9 @@
{
"name": "RootComponent"
},
{
"name": "RootViewRef"
},
{
"name": "RuntimeError"
},
Expand Down Expand Up @@ -884,6 +887,9 @@
{
"name": "detectChangesInViewIfAttached"
},
{
"name": "detectChangesInternal"
},
{
"name": "diPublicInInjector"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@
{
"name": "RendererStyleFlags2"
},
{
"name": "RootViewRef"
},
{
"name": "RuntimeError"
},
Expand Down Expand Up @@ -665,6 +668,9 @@
{
"name": "detectChangesInViewIfAttached"
},
{
"name": "detectChangesInternal"
},
{
"name": "diPublicInInjector"
},
Expand Down
6 changes: 6 additions & 0 deletions packages/core/test/bundling/defer/bundle.golden_symbols.json
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@
{
"name": "RendererStyleFlags2"
},
{
"name": "RootViewRef"
},
{
"name": "RuntimeError"
},
Expand Down Expand Up @@ -755,6 +758,9 @@
{
"name": "detectChangesInViewIfAttached"
},
{
"name": "detectChangesInternal"
},
{
"name": "diPublicInInjector"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,9 @@
{
"name": "RootComponent"
},
{
"name": "RootViewRef"
},
{
"name": "RuntimeError"
},
Expand Down Expand Up @@ -908,6 +911,9 @@
{
"name": "detectChangesInViewIfAttached"
},
{
"name": "detectChangesInternal"
},
{
"name": "diPublicInInjector"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@
{
"name": "RootComponent"
},
{
"name": "RootViewRef"
},
{
"name": "RuntimeError"
},
Expand Down Expand Up @@ -878,6 +881,9 @@
{
"name": "detectChangesInViewIfAttached"
},
{
"name": "detectChangesInternal"
},
{
"name": "diPublicInInjector"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@
{
"name": "RendererFactory2"
},
{
"name": "RootViewRef"
},
{
"name": "RuntimeError"
},
Expand Down Expand Up @@ -524,6 +527,9 @@
{
"name": "detectChangesInViewIfAttached"
},
{
"name": "detectChangesInternal"
},
{
"name": "diPublicInInjector"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,9 @@
{
"name": "RendererStyleFlags2"
},
{
"name": "RootViewRef"
},
{
"name": "RuntimeError"
},
Expand Down Expand Up @@ -749,6 +752,9 @@
{
"name": "detectChangesInViewIfAttached"
},
{
"name": "detectChangesInternal"
},
{
"name": "diPublicInInjector"
},
Expand Down
6 changes: 6 additions & 0 deletions packages/core/test/bundling/router/bundle.golden_symbols.json
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,9 @@
{
"name": "ResolveStart"
},
{
"name": "RootViewRef"
},
{
"name": "RouteConfigLoadEnd"
},
Expand Down Expand Up @@ -1178,6 +1181,9 @@
{
"name": "detectChangesInViewIfAttached"
},
{
"name": "detectChangesInternal"
},
{
"name": "diPublicInInjector"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@
{
"name": "RendererStyleFlags2"
},
{
"name": "RootViewRef"
},
{
"name": "RuntimeError"
},
Expand Down Expand Up @@ -596,6 +599,9 @@
{
"name": "detectChangesInViewIfAttached"
},
{
"name": "detectChangesInternal"
},
{
"name": "diPublicInInjector"
},
Expand Down
6 changes: 6 additions & 0 deletions packages/core/test/bundling/todo/bundle.golden_symbols.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,9 @@
{
"name": "RendererStyleFlags2"
},
{
"name": "RootViewRef"
},
{
"name": "RuntimeError"
},
Expand Down Expand Up @@ -794,6 +797,9 @@
{
"name": "detectChangesInViewIfAttached"
},
{
"name": "detectChangesInternal"
},
{
"name": "diPublicInInjector"
},
Expand Down

0 comments on commit cce84d2

Please sign in to comment.