Fix issue where Object#isString and Object#isNumber return false for String and Number "wrapper" objects. [#375 state:resolved]
This commit is contained in:
parent
c493d09b7b
commit
07506e648b
@ -1,3 +1,5 @@
|
||||
* Fix issue where Object#isString and Object#isNumber return false for String and Number "wrapper" objects. (atrepp, Samuel Lebeau, Andrew Dupont)
|
||||
|
||||
* Set document.loaded = true before firing dom:loaded custom event. (Andrew Dupont)
|
||||
|
||||
* Allow Element#store to accept an object containing several key/value pairs. (ZenCocoon, Andrew Dupont)
|
||||
|
@ -83,11 +83,11 @@
|
||||
}
|
||||
|
||||
function isString(object) {
|
||||
return typeof object === "string";
|
||||
return typeof (object && object.valueOf()) === "string";
|
||||
}
|
||||
|
||||
function isNumber(object) {
|
||||
return typeof object === "number";
|
||||
return typeof (object && object.valueOf()) === "number";
|
||||
}
|
||||
|
||||
function isUndefined(object) {
|
||||
|
@ -129,6 +129,7 @@ new Test.Unit.Runner({
|
||||
testObjectIsString: function() {
|
||||
this.assert(!Object.isString(function() { }));
|
||||
this.assert(Object.isString("a string"));
|
||||
this.assert(Object.isString(new String("a string")));
|
||||
this.assert(!Object.isString(0));
|
||||
this.assert(!Object.isString([]));
|
||||
this.assert(!Object.isString({}));
|
||||
@ -139,7 +140,10 @@ new Test.Unit.Runner({
|
||||
testObjectIsNumber: function() {
|
||||
this.assert(Object.isNumber(0));
|
||||
this.assert(Object.isNumber(1.0));
|
||||
this.assert(Object.isNumber(new Number(0)));
|
||||
this.assert(Object.isNumber(new Number(1.0)));
|
||||
this.assert(!Object.isNumber(function() { }));
|
||||
this.assert(!Object.isNumber({ test: function() { return 3 } }));
|
||||
this.assert(!Object.isNumber("a string"));
|
||||
this.assert(!Object.isNumber([]));
|
||||
this.assert(!Object.isNumber({}));
|
||||
|
Loading…
Reference in New Issue
Block a user