_.isBoolean should return true for boolean object wrappers.

This commit is contained in:
Kit Cambridge
2011-09-05 15:51:09 -06:00
parent 54245bc679
commit 4fa97eb2fa
2 changed files with 5 additions and 5 deletions

View File

@@ -318,14 +318,14 @@ $(document).ready(function() {
parent.iElement = document.createElement('div');\
parent.iArguments = (function(){ return arguments; })(1, 2, 3);\
parent.iArray = [1, 2, 3];\
parent.iString = 'hello';\
parent.iNumber = 100;\
parent.iString = new String('hello');\
parent.iNumber = new Number(100);\
parent.iFunction = (function(){});\
parent.iDate = new Date();\
parent.iRegExp = /hi/;\
parent.iNaN = NaN;\
parent.iNull = null;\
parent.iBoolean = false;\
parent.iBoolean = new Boolean(false);\
parent.iUndefined = undefined;\
</script>"
);

View File

@@ -614,7 +614,7 @@
var isNumberA = _.isNumber(a), isNumberB = _.isNumber(b);
if (isNumberA || isNumberB) return isNumberA && isNumberB && +a == +b;
// Compare boolean objects by value. The value of `true` is 1; the value of `false` is 0.
var isBooleanA = toString.call(a) == '[object Boolean]', isBooleanB = toString.call(b) == '[object Boolean]';
var isBooleanA = _.isBoolean(a), isBooleanB = _.isBoolean(b);
if (isBooleanA || isBooleanB) return isBooleanA && isBooleanB && +a == +b;
// Compare dates by their millisecond values.
var isDateA = _.isDate(a), isDateB = _.isDate(b);
@@ -738,7 +738,7 @@
// Is a given value a boolean?
_.isBoolean = function(obj) {
return obj === true || obj === false;
return obj === true || obj === false || typeof obj == 'object' && toString.call(obj) == '[object Boolean]';
};
// Is a given value a date?