Merge pull request #228 from fabien/fix/list-to-object

Prevent failure with null in List toObject
This commit is contained in:
Raymond Feng 2014-08-17 22:34:09 -07:00
commit e1a516be75
1 changed files with 1 additions and 1 deletions

View File

@ -75,7 +75,7 @@ List.prototype.push = function (obj) {
List.prototype.toObject = function (onlySchema, removeHidden) { List.prototype.toObject = function (onlySchema, removeHidden) {
var items = []; var items = [];
this.forEach(function (item) { this.forEach(function (item) {
if (item.toObject) { if (item && typeof item === 'object' && item.toObject) {
items.push(item.toObject(onlySchema, removeHidden)); items.push(item.toObject(onlySchema, removeHidden));
} else { } else {
items.push(item); items.push(item);