From 92a6575137172714ddcdd1ef55102d36468d4708 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 18 May 2018 08:36:35 -0700 Subject: [PATCH] Avoid skipping set of -0 when an existing +0 exists. [closes #3798] --- .internal/assignValue.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.internal/assignValue.js b/.internal/assignValue.js index f7d895fa1..42884f604 100644 --- a/.internal/assignValue.js +++ b/.internal/assignValue.js @@ -5,9 +5,7 @@ import eq from '../eq.js' const hasOwnProperty = Object.prototype.hasOwnProperty /** - * Assigns `value` to `key` of `object` if the existing value is not equivalent - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. + * Assigns `value` to `key` of `object` if the existing value is not equivalent. * * @private * @param {Object} object The object to modify. @@ -16,8 +14,12 @@ const hasOwnProperty = Object.prototype.hasOwnProperty */ function assignValue(object, key, value) { const objValue = object[key] - if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || - (value === undefined && !(key in object))) { + + if (!(hasOwnProperty.call(object, key) && eq(objValue, value))) { + if (value !== 0 || (1 / value) == (1 / objValue)) { + baseAssignValue(object, key, value) + } + } else if (value === undefined && !(key in object)) { baseAssignValue(object, key, value) } }