Skip to content

Instantly share code, notes, and snippets.

@lsmith
Created June 28, 2010 19:12
Show Gist options
  • Save lsmith/456228 to your computer and use it in GitHub Desktop.
Save lsmith/456228 to your computer and use it in GitHub Desktop.
Y.isEmpty = function (o) {
if (o != null) {
if (Y.Node) {
o = (o._node || o._nodes || o);
}
if (o.nodeType) {
o = o.childNodes;
}
if (Y.Array.test(o)) {
return !o.length;
}
if (Y.Lang.isObject(o)) {
if ('__count__' in o) {
return !o.__count__;
} else {
for (var k in o) {
// own properties are enumerated first
return !o.hasOwnProperty(k);
}
}
}
return (Y.Lang.isString(o)) ? !o.length : false;
}
return true;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment