From 3d80a2ec33ee473c3c75011ba04e2df2a3bafcd8 Mon Sep 17 00:00:00 2001 From: llevkin Date: Fri, 12 Dec 2014 11:16:20 +0300 Subject: [PATCH] Proper check for null'ish values instead of falsyness in _json.set --- way.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/way.js b/way.js index f79fdde..6e04744 100644 --- a/way.js +++ b/way.js @@ -1333,8 +1333,8 @@ if (json == undefined) return _json.exit("set", "missing", "json", json); if (selector == undefined) return _json.exit("set", "missing", "selector", selector); if (!_w.isString(selector)) return _json.exit("set", "noString", "selector", selector); - return value ? deepJSON(json, selector, value) : _json.remove(json, selector); - // return deepJSON(json, selector, value); // Now removes the property if the value is empty. Maybe should keep it instead? + // Proper check for null'ish values instead of falsyness + return (value === undefined || value === null || (typeof value === 'number' && isNaN(value))) ? _json.remove(json, selector) : deepJSON(json, selector, value); };