summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2013-12-04 11:11:07 +0100
committerjmoenig <jens@moenig.org>2013-12-04 11:11:07 +0100
commitd9b9c6bad1b2435e06b8066857a2fb3d1ce03411 (patch)
treee77e4573c31d6b383b37db241d99db13990b4817
parenta845696223d13122be945f6adbaafa0415d07093 (diff)
downloadsnap-byow-d9b9c6bad1b2435e06b8066857a2fb3d1ce03411.tar.gz
snap-byow-d9b9c6bad1b2435e06b8066857a2fb3d1ce03411.zip
fixed #261 (less tolerant null-value-to-number-coercion)
-rwxr-xr-xhistory.txt1
-rw-r--r--threads.js10
2 files changed, 9 insertions, 2 deletions
diff --git a/history.txt b/history.txt
index fed4d3e..04c5949 100755
--- a/history.txt
+++ b/history.txt
@@ -2025,3 +2025,4 @@ ______
* Threads: handle text comparisons case-insensitive (again)
* Lists: harmonize equality testing and List CONTAINS testing
* French translation update, thanks, Martin!
+* Threads: fixed #261 (less tolerant null-value-to-number-coercion)
diff --git a/threads.js b/threads.js
index 727aedf..9727e18 100644
--- a/threads.js
+++ b/threads.js
@@ -98,9 +98,15 @@ function snapEquals(a, b) {
}
return false;
}
+
var x = +a,
- y = +b;
- if (isNaN(x) || isNaN(y)) {
+ y = +b,
+ specials = [true, false, '', 0];
+
+ // check for special values before coercing to numbers
+ if (isNaN(x) || isNaN(y) ||
+ [a, b].some(function (any) {return contains(specials, any) ||
+ (any.indexOf(' ') > -1); })) {
x = a;
y = b;
}