diff --git a/src/Angular.js b/src/Angular.js index fef4278ff2b2..d64bcf445d0d 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -987,8 +987,7 @@ function copy(source, destination, maxDepth) { } -// eslint-disable-next-line no-self-compare -function simpleCompare(a, b) { return a === b || (a !== a && b !== b); } +function simpleCompare(a, b) { return a === b || (isNumberNaN(a) && isNumberNaN(b)); } /** @@ -1057,8 +1056,7 @@ function simpleCompare(a, b) { return a === b || (a !== a && b !== b); } function equals(o1, o2) { if (o1 === o2) return true; if (o1 === null || o2 === null) return false; - // eslint-disable-next-line no-self-compare - if (o1 !== o1 && o2 !== o2) return true; // NaN === NaN + if (isNumberNaN(o1) && isNumberNaN(o2)) return true; // NaN === NaN var t1 = typeof o1, t2 = typeof o2, length, key, keySet; if (t1 === t2 && t1 === 'object') { if (isArray(o1)) { diff --git a/src/ng/directive/ngModel.js b/src/ng/directive/ngModel.js index 5d73c33ceb28..1450977abe49 100644 --- a/src/ng/directive/ngModel.js +++ b/src/ng/directive/ngModel.js @@ -368,8 +368,7 @@ NgModelController.prototype = { * @returns {boolean} True if `value` is "empty". */ $isEmpty: function(value) { - // eslint-disable-next-line no-self-compare - return isUndefined(value) || value === '' || value === null || value !== value; + return isUndefined(value) || value === '' || value === null || isNumberNaN(value); }, $$updateEmptyClasses: function(value) { @@ -1088,8 +1087,7 @@ function setupModelWatcher(ctrl) { // case where the model is changed in the ngChange function or the model setter if (modelValue !== ctrl.$modelValue && // checks for NaN is needed to allow setting the model to NaN when there's an asyncValidator - // eslint-disable-next-line no-self-compare - (ctrl.$modelValue === ctrl.$modelValue || modelValue === modelValue) + !(isNumberNaN(ctrl.$modelValue) && isNumberNaN(modelValue)) ) { ctrl.$$setModelValue(modelValue); } diff --git a/src/ng/parse.js b/src/ng/parse.js index 91a1b363e6c4..ebd437484673 100644 --- a/src/ng/parse.js +++ b/src/ng/parse.js @@ -1843,9 +1843,8 @@ function $ParseProvider() { // fall-through to the primitive equality check } - //Primitive or NaN - // eslint-disable-next-line no-self-compare - return newValue === oldValueOfValue || (newValue !== newValue && oldValueOfValue !== oldValueOfValue); + // Primitive or NaN + return newValue === oldValueOfValue || (isNumberNaN(newValue) && isNumberNaN(oldValueOfValue)); } function inputsWatchDelegate(scope, listener, objectEquality, parsedExpression, prettyPrintExpression) { diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index e145c5102611..530457cfdc29 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -635,8 +635,7 @@ function $RootScopeProvider() { oldItem = oldValue[i]; newItem = newValue[i]; - // eslint-disable-next-line no-self-compare - bothNaN = (oldItem !== oldItem) && (newItem !== newItem); + bothNaN = isNumberNaN(oldItem) && isNumberNaN(newItem); if (!bothNaN && (oldItem !== newItem)) { changeDetected++; oldValue[i] = newItem; @@ -658,8 +657,7 @@ function $RootScopeProvider() { oldItem = oldValue[key]; if (key in oldValue) { - // eslint-disable-next-line no-self-compare - bothNaN = (oldItem !== oldItem) && (newItem !== newItem); + bothNaN = isNumberNaN(oldItem) && isNumberNaN(newItem); if (!bothNaN && (oldItem !== newItem)) { changeDetected++; oldValue[key] = newItem;