fix: isNaN 会导致 store 不停更新 (#2222)

This commit is contained in:
liaoxuezhi 2021-07-05 22:56:55 +08:00 committed by GitHub
parent a46b37588d
commit d484bd16ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
import isPlainObject from 'lodash/isPlainObject';
import isEqual from 'lodash/isEqual';
import isNaN from 'lodash/isNaN';
import uniq from 'lodash/uniq';
import {Schema, PlainObject, FunctionPropertyNames} from '../types';
import {evalExpression} from './tpl';
@ -313,6 +314,8 @@ export function isObjectShallowModified(
ignoreUndefined
)
);
} else if (isNaN(prev) && isNaN(next)) {
return false;
} else if (
null == prev ||
null == next ||
@ -338,9 +341,7 @@ export function isObjectShallowModified(
for (let i: number = keys.length - 1; i >= 0; i--) {
let key = keys[i];
if (
strictMode
? next[key] !== prev[key]
: isObjectShallowModified(next[key], prev[key], false, ignoreUndefined)
isObjectShallowModified(next[key], prev[key], strictMode, ignoreUndefined)
) {
return true;
}