From 356da9c9f62df28703d7681dc3c6e2aee8c30fa6 Mon Sep 17 00:00:00 2001 From: Alex Rickabaugh Date: Wed, 1 Nov 2023 21:09:37 -0700 Subject: [PATCH] refactor(core): add a flag for whether we skip logic in checkNoChanges (#52488) This can be used to patch different behavior in g3. PR Close #52488 --- .../src/render3/instructions/change_detection.ts | 3 ++- .../render3/instructions/change_detection_flags.ts | 12 ++++++++++++ .../test/bundling/defer/bundle.golden_symbols.json | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 packages/core/src/render3/instructions/change_detection_flags.ts diff --git a/packages/core/src/render3/instructions/change_detection.ts b/packages/core/src/render3/instructions/change_detection.ts index ccdbd4a15ab..621653e0520 100644 --- a/packages/core/src/render3/instructions/change_detection.ts +++ b/packages/core/src/render3/instructions/change_detection.ts @@ -18,6 +18,7 @@ import {enterView, isInCheckNoChangesMode, leaveView, setBindingIndex, setIsInCh import {getFirstLContainer, getNextLContainer} from '../util/view_traversal_utils'; import {getComponentLViewByIndex, isCreationMode, markAncestorsForTraversal, markViewForRefresh, resetPreOrderHookFlags, viewAttachedToChangeDetector} from '../util/view_utils'; +import {RUN_IN_CHECK_NO_CHANGES_ANYWAY} from './change_detection_flags'; import {executeTemplate, executeViewQueryFn, handleError, processHostBindingOpCodes, refreshContentQueries} from './shared'; /** @@ -369,7 +370,7 @@ function detectChangesInView(lView: LView, mode: ChangeDetectionMode) { // it gives an opportunity for `OnPush` components to be marked `Dirty` before the // CheckNoChanges pass. We don't want existing errors that are hidden by the current // CheckNoChanges bug to surface when making unrelated changes. - !isInCheckNoChangesPass) || + (!isInCheckNoChangesPass || RUN_IN_CHECK_NO_CHANGES_ANYWAY)) || flags & LViewFlags.RefreshView) { refreshView(tView, lView, tView.template, lView[CONTEXT]); } else if (flags & LViewFlags.HasChildViewsToRefresh) { diff --git a/packages/core/src/render3/instructions/change_detection_flags.ts b/packages/core/src/render3/instructions/change_detection_flags.ts new file mode 100644 index 00000000000..5078227706c --- /dev/null +++ b/packages/core/src/render3/instructions/change_detection_flags.ts @@ -0,0 +1,12 @@ +/** + * @license + * Copyright Google LLC All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +/** + * Whether we should skip specific logic in checkNoChanges mode. + */ +export const RUN_IN_CHECK_NO_CHANGES_ANYWAY = false; diff --git a/packages/core/test/bundling/defer/bundle.golden_symbols.json b/packages/core/test/bundling/defer/bundle.golden_symbols.json index 686a3be5804..fc3dbab8d77 100644 --- a/packages/core/test/bundling/defer/bundle.golden_symbols.json +++ b/packages/core/test/bundling/defer/bundle.golden_symbols.json @@ -1100,6 +1100,9 @@ { "name": "init_change_detection3" }, + { + "name": "init_change_detection_flags" + }, { "name": "init_change_detection_utils" },