From dad82668379d0c481775264a9201873dc1f8e459 Mon Sep 17 00:00:00 2001 From: Fabien Franzen Date: Mon, 18 Aug 2014 07:28:33 +0200 Subject: [PATCH] Prevent failure with null in List toObject --- lib/list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/list.js b/lib/list.js index 4c4158eb..27c2a534 100644 --- a/lib/list.js +++ b/lib/list.js @@ -75,7 +75,7 @@ List.prototype.push = function (obj) { List.prototype.toObject = function (onlySchema, removeHidden) { var items = []; this.forEach(function (item) { - if (item.toObject) { + if (item && typeof item === 'object' && item.toObject) { items.push(item.toObject(onlySchema, removeHidden)); } else { items.push(item);