fix(ivy): support checkNoChanges on embedded views (#28644)
Before this fix our ViewRef implementation assumed that checkNoChanges can be only called on component views. In reality checkNoChanges can be also called on embedded views (ex.: when an embedded view is attached to ApplicationRef). PR Close #28644
This commit is contained in:

committed by
Miško Hevery

parent
2bf0d1a56f
commit
e5861e1c79
@ -2751,7 +2751,7 @@ function tickRootContext(rootContext: RootContext) {
|
||||
* @param component The component which the change detection should be performed on.
|
||||
*/
|
||||
export function detectChanges<T>(component: T): void {
|
||||
const view = getComponentViewByInstance(component) !;
|
||||
const view = getComponentViewByInstance(component);
|
||||
detectChangesInternal<T>(view, component);
|
||||
}
|
||||
|
||||
@ -2790,9 +2790,14 @@ export function detectChangesInRootView(lView: LView): void {
|
||||
* introduce other changes.
|
||||
*/
|
||||
export function checkNoChanges<T>(component: T): void {
|
||||
const view = getComponentViewByInstance(component);
|
||||
checkNoChangesInternal<T>(view, component);
|
||||
}
|
||||
|
||||
export function checkNoChangesInternal<T>(view: LView, context: T) {
|
||||
setCheckNoChangesMode(true);
|
||||
try {
|
||||
detectChanges(component);
|
||||
detectChangesInternal(view, context);
|
||||
} finally {
|
||||
setCheckNoChangesMode(false);
|
||||
}
|
||||
|
@ -11,9 +11,9 @@ import {ChangeDetectorRef as viewEngine_ChangeDetectorRef} from '../change_detec
|
||||
import {ViewContainerRef as viewEngine_ViewContainerRef} from '../linker/view_container_ref';
|
||||
import {EmbeddedViewRef as viewEngine_EmbeddedViewRef, InternalViewRef as viewEngine_InternalViewRef} from '../linker/view_ref';
|
||||
|
||||
import {checkNoChanges, checkNoChangesInRootView, checkView, detectChangesInRootView, detectChangesInternal, markViewDirty, storeCleanupFn, viewAttached} from './instructions';
|
||||
import {checkNoChangesInRootView, checkNoChangesInternal, detectChangesInRootView, detectChangesInternal, markViewDirty, storeCleanupFn} from './instructions';
|
||||
import {TNode, TNodeType, TViewNode} from './interfaces/node';
|
||||
import {FLAGS, HOST, LView, LViewFlags, PARENT, RENDERER_FACTORY, T_HOST} from './interfaces/view';
|
||||
import {FLAGS, HOST, LView, LViewFlags, PARENT, T_HOST} from './interfaces/view';
|
||||
import {destroyLView} from './node_manipulation';
|
||||
import {getNativeByTNode} from './util';
|
||||
|
||||
@ -252,7 +252,7 @@ export class ViewRef<T> implements viewEngine_EmbeddedViewRef<T>, viewEngine_Int
|
||||
* This is used in development mode to verify that running change detection doesn't
|
||||
* introduce other changes.
|
||||
*/
|
||||
checkNoChanges(): void { checkNoChanges(this.context); }
|
||||
checkNoChanges(): void { checkNoChangesInternal(this._lView, this.context); }
|
||||
|
||||
attachToViewContainerRef(vcRef: viewEngine_ViewContainerRef) {
|
||||
if (this._appRef) {
|
||||
|
Reference in New Issue
Block a user