Skip to content

Commit

Permalink
Check if the child object exists, but isn't an object
Browse files Browse the repository at this point in the history
  • Loading branch information
tgriesser committed May 23, 2012
1 parent cc7db2f commit c3d370a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/deep-model.js
Expand Up @@ -85,8 +85,8 @@
if (i === n - 1) {
options.unset ? delete result[field] : result[field] = val;
} else {
//Create the child object if it doesn't exist
if (typeof result[field] === 'undefined') {
//Create the child object if it doesn't exist, or isn't an object
if (typeof result[field] === 'undefined' || ! _.isObject(result[field])) {
result[field] = {};
}

Expand Down

0 comments on commit c3d370a

Please sign in to comment.