fix(reactivity): account for NaN in value change checks (#361)
This commit is contained in:
@@ -2,7 +2,7 @@ import { reactive, readonly, toRaw } from './reactive'
|
||||
import { OperationTypes } from './operations'
|
||||
import { track, trigger } from './effect'
|
||||
import { LOCKED } from './lock'
|
||||
import { isObject, hasOwn, isSymbol } from '@vue/shared'
|
||||
import { isObject, hasOwn, isSymbol, hasChanged } from '@vue/shared'
|
||||
import { isRef } from './ref'
|
||||
|
||||
const builtInSymbols = new Set(
|
||||
@@ -52,13 +52,13 @@ function set(
|
||||
const extraInfo = { oldValue, newValue: value }
|
||||
if (!hadKey) {
|
||||
trigger(target, OperationTypes.ADD, key, extraInfo)
|
||||
} else if (value !== oldValue) {
|
||||
} else if (hasChanged(value, oldValue)) {
|
||||
trigger(target, OperationTypes.SET, key, extraInfo)
|
||||
}
|
||||
} else {
|
||||
if (!hadKey) {
|
||||
trigger(target, OperationTypes.ADD, key)
|
||||
} else if (value !== oldValue) {
|
||||
} else if (hasChanged(value, oldValue)) {
|
||||
trigger(target, OperationTypes.SET, key)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { toRaw, reactive, readonly } from './reactive'
|
||||
import { track, trigger } from './effect'
|
||||
import { OperationTypes } from './operations'
|
||||
import { LOCKED } from './lock'
|
||||
import { isObject, capitalize, hasOwn } from '@vue/shared'
|
||||
import { isObject, capitalize, hasOwn, hasChanged } from '@vue/shared'
|
||||
|
||||
export type CollectionTypes = IterableCollections | WeakCollections
|
||||
|
||||
@@ -73,13 +73,13 @@ function set(this: MapTypes, key: unknown, value: unknown) {
|
||||
const extraInfo = { oldValue, newValue: value }
|
||||
if (!hadKey) {
|
||||
trigger(target, OperationTypes.ADD, key, extraInfo)
|
||||
} else if (value !== oldValue) {
|
||||
} else if (hasChanged(value, oldValue)) {
|
||||
trigger(target, OperationTypes.SET, key, extraInfo)
|
||||
}
|
||||
} else {
|
||||
if (!hadKey) {
|
||||
trigger(target, OperationTypes.ADD, key)
|
||||
} else if (value !== oldValue) {
|
||||
} else if (hasChanged(value, oldValue)) {
|
||||
trigger(target, OperationTypes.SET, key)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user