From 6ee606e3e26feea09f7c5b1c9396a67ab8bb6f0f Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 3 Feb 2013 21:43:17 -0800 Subject: [PATCH] Fix failing unit test in older IE. Former-commit-id: 2de10b6bc3b9720a14fba86d9fe2638b30a7d0ef --- build.js | 3 +++ lodash.js | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/build.js b/build.js index 2250ad28e..cbfcba81d 100755 --- a/build.js +++ b/build.js @@ -1732,6 +1732,9 @@ " (!b || (otherType != 'function' && otherType != 'object'))) {", ' return false;', ' }', + ' if (a == null || b == null) {', + ' return a === b;', + ' }', ' var className = toString.call(a),', ' otherClass = toString.call(b);', '', diff --git a/lodash.js b/lodash.js index c0b86b0df..7861b9810 100644 --- a/lodash.js +++ b/lodash.js @@ -1461,6 +1461,11 @@ (!b || (otherType != 'function' && otherType != 'object'))) { return false; } + // exit early for `null` and `undefined`, avoiding ES3's Function#call behavior + // http://es5.github.com/#x15.3.4.4 + if (a == null || b == null) { + return a === b; + } // compare [[Class]] names var className = toString.call(a), otherClass = toString.call(b);