Skip to content

Commit

Permalink
fix(mp): patch diffData
Browse files Browse the repository at this point in the history
  • Loading branch information
StrivingRabbit committed Sep 27, 2022
1 parent 7a0d273 commit b2895a5
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5420,6 +5420,8 @@ Vue.version = '2.6.11';
*/
var ARRAYTYPE = '[object Array]';
var OBJECTTYPE = '[object Object]';
var NULLTYPE = '[object Null]';
var UNDEFINEDTYPE = '[object Undefined]';
// const FUNCTIONTYPE = '[object Function]'

function diff(current, pre) {
Expand Down Expand Up @@ -5453,6 +5455,16 @@ function syncKeys(current, pre) {
}
}

function nullOrUndefined(currentType, preType) {
if(
(currentType === NULLTYPE || currentType === UNDEFINEDTYPE) &&
(preType === NULLTYPE || preType === UNDEFINEDTYPE)
) {
return false
}
return true
}

function _diff(current, pre, path, result) {
if (current === pre) { return }
var rootCurrentType = type(current);
Expand All @@ -5467,7 +5479,7 @@ function _diff(current, pre, path, result) {
var currentType = type(currentValue);
var preType = type(preValue);
if (currentType != ARRAYTYPE && currentType != OBJECTTYPE) {
if (currentValue !== pre[key]) {
if (currentValue !== pre[key] && nullOrUndefined(currentType, preType)) {
setResult(result, (path == '' ? '' : path + ".") + key, currentValue);
}
} else if (currentType == ARRAYTYPE) {
Expand Down

0 comments on commit b2895a5

Please sign in to comment.