Merge pull request #228 from fabien/fix/list-to-object
Prevent failure with null in List toObject
This commit is contained in:
commit
e1a516be75
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue