Ensure Object.isElement handles "falsy" values properly.
This commit is contained in:
parent
c01d1a26f7
commit
d88c25fd47
@ -1,3 +1,5 @@
|
||||
* Ensure Object.isElement handles "falsy" values properly. (kangax)
|
||||
|
||||
* Fix exiting test task on INT signal. (Samuel Lebeau)
|
||||
|
||||
* Fix unit test freeze in IE. (Tobie Langel)
|
||||
|
@ -129,7 +129,7 @@ Object.extend(Object, {
|
||||
},
|
||||
|
||||
isElement: function(object) {
|
||||
return object && object.nodeType == 1;
|
||||
return !!(object && object.nodeType == 1);
|
||||
},
|
||||
|
||||
isArray: function(object) {
|
||||
|
@ -207,6 +207,13 @@ new Test.Unit.Runner({
|
||||
this.assert(Object.isElement(new Element('div')));
|
||||
this.assert(Object.isElement($('testlog')));
|
||||
this.assert(!Object.isElement(document.createTextNode('bla')));
|
||||
|
||||
// falsy variables should not mess up return value type
|
||||
this.assertIdentical(false, Object.isElement(0));
|
||||
this.assertIdentical(false, Object.isElement(''));
|
||||
this.assertIdentical(false, Object.isElement(NaN));
|
||||
this.assertIdentical(false, Object.isElement(null));
|
||||
this.assertIdentical(false, Object.isElement(undefined));
|
||||
},
|
||||
|
||||
testObjectIsFunction: function() {
|
||||
|
Loading…
Reference in New Issue
Block a user