Commit 8282ce71 authored by Jérome Perrin's avatar Jérome Perrin

core/gadget_global.js: make isEmpty supports empty object

Co-authored-by: Romain Courteaud's avatarRomain Courteaud <romain@nexedi.com>
parent a683986f
......@@ -9,10 +9,14 @@
Calling isEmpty(x) is more robust than expression !x.
*/
function isEmpty(value) {
return (value === undefined ||
value === null ||
value.length === 0 ||
(typeof value === "number" && isNaN(value)));
return (
(value === undefined) ||
(value === null) ||
((typeof value === "number") ?
isNaN(value) :
(Object.keys(value).length === 0)
)
);
}
window.isEmpty = isEmpty;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment