From 602f22c58ba514e8c6436c82ea66f80c2f973d86 Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Mon, 3 Feb 2014 21:56:59 -0800 Subject: [PATCH] Consider both null and Nan undefined For the purpose of determining whether a meaningful value exists to propagate. --- observers.js | 2 +- operators.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/observers.js b/observers.js index 09434b2..2d08534 100644 --- a/observers.js +++ b/observers.js @@ -326,7 +326,7 @@ exports.makeDefinedObserver = makeDefinedObserver; function makeDefinedObserver(observeValue) { return function observeDefault(emit, scope) { return observeValue(autoCancelPrevious(function replaceValue(value) { - return emit(value != null); + return emit(Operators.defined(value)); }), scope); }; } diff --git a/operators.js b/operators.js index 058dfb0..c836872 100644 --- a/operators.js +++ b/operators.js @@ -111,7 +111,9 @@ exports.or = function (a, b) { }; exports.defined = function (value) { - return value != null; + // value != null eliminates null and undefined + // value === value eliminates NaN + return value != null && value === value; }; // "startsWith", "endsWith", and "contains" are overridden in