jquery core: Simplifying isEmptyObject() and adding tests.
This commit is contained in:
parent
991d039b62
commit
a38a5cd531
2 changed files with 13 additions and 3 deletions
|
@ -292,9 +292,9 @@ jQuery.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
isEmptyObject: function( obj ) {
|
isEmptyObject: function( obj ) {
|
||||||
var name = "";
|
for(var name in obj)
|
||||||
for(name in obj) break;
|
return false;
|
||||||
return !name;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
// check if an element is in a (or is an) XML document
|
// check if an element is in a (or is an) XML document
|
||||||
|
|
|
@ -599,3 +599,13 @@ test("jQuery.makeArray", function(){
|
||||||
|
|
||||||
ok( jQuery.makeArray(document.getElementById('form')).length >= 13, "Pass makeArray a form (treat as elements)" );
|
ok( jQuery.makeArray(document.getElementById('form')).length >= 13, "Pass makeArray a form (treat as elements)" );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("jQuery.isEmptyObject", function(){
|
||||||
|
expect(2);
|
||||||
|
|
||||||
|
equals(true, jQuery.isEmptyObject({}), "isEmptyObject on empty object literal" );
|
||||||
|
equals(false, jQuery.isEmptyObject({a:1}), "isEmptyObject on non-empty object literal" );
|
||||||
|
|
||||||
|
// What about this ?
|
||||||
|
// equals(true, jQuery.isEmptyObject(null), "isEmptyObject on null" );
|
||||||
|
});
|
Loading…
Reference in a new issue