fix(ivy): use devModeEqual in no change mode (#25252)
To avoid the unfamous error `Expression has changed after it was checked.` PR Close #25252
This commit is contained in:

committed by
Kara Erickson

parent
1fb7111da1
commit
b38931b484
@ -2739,7 +2739,7 @@ export function bindingUpdated(value: any): boolean {
|
||||
|
||||
if (bindingIndex >= viewData.length) {
|
||||
viewData[viewData[BINDING_INDEX]++] = value;
|
||||
} else if (isDifferent(viewData[bindingIndex], value)) {
|
||||
} else if (isDifferent(viewData[bindingIndex], value, checkNoChangesMode)) {
|
||||
throwErrorIfNoChangesMode(creationMode, checkNoChangesMode, viewData[bindingIndex], value);
|
||||
viewData[viewData[BINDING_INDEX]++] = value;
|
||||
} else {
|
||||
|
@ -5,15 +5,20 @@
|
||||
* 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
|
||||
*/
|
||||
import {devModeEqual} from '../change_detection/change_detection';
|
||||
import {assertLessThan} from './assert';
|
||||
import {LElementNode} from './interfaces/node';
|
||||
import {HEADER_OFFSET, LViewData} from './interfaces/view';
|
||||
|
||||
|
||||
/**
|
||||
* Must use this method for CD (instead of === ) since NaN !== NaN
|
||||
*/
|
||||
export function isDifferent(a: any, b: any): boolean {
|
||||
* Returns wether the values are different from a change detection stand point.
|
||||
*
|
||||
* Constraints are relaxed in checkNoChanges mode. See `devModeEqual` for details.
|
||||
*/
|
||||
export function isDifferent(a: any, b: any, checkNoChangesMode: boolean): boolean {
|
||||
if (ngDevMode && checkNoChangesMode) {
|
||||
return !devModeEqual(a, b);
|
||||
}
|
||||
// NaN is the only value that is not equal to itself so the first
|
||||
// test checks if both a and b are not NaN
|
||||
return !(a !== a && b !== b) && a !== b;
|
||||
|
Reference in New Issue
Block a user