From 1dccdf0497eb12b421ee46a95ac5cee7869ebcba Mon Sep 17 00:00:00 2001 From: Louis Chatriot Date: Mon, 17 Jun 2013 21:50:03 +0200 Subject: [PATCH] Fixed bug that raised an error for a null value --- lib/model.js | 2 +- package.json | 2 +- test/model.test.js | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/model.js b/lib/model.js index 29b4161..22896bd 100644 --- a/lib/model.js +++ b/lib/model.js @@ -44,7 +44,7 @@ function checkObject (obj) { }); } - if (typeof obj === 'object') { + if (typeof obj === 'object' && obj !== null) { Object.keys(obj).forEach(function (k) { checkKey(k, obj[k]); checkObject(obj[k]); diff --git a/package.json b/package.json index 4f088dc..b826b5f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nedb", - "version": "0.7.3", + "version": "0.7.4", "author": { "name": "tldr.io", "email": "hello@tldr.io" diff --git a/test/model.test.js b/test/model.test.js index e1d243b..30903f4 100644 --- a/test/model.test.js +++ b/test/model.test.js @@ -159,6 +159,12 @@ describe('Model', function () { // Recursive behaviour testing done in the above test on $ signs }); + it('Properties with a null value dont trigger an error', function () { + var obj = { prop: null }; + + model.checkObject(obj); + }); + }); // ==== End of 'Object checking' ==== //