Skip to content

Commit

Permalink
Fix extended model interface
Browse files Browse the repository at this point in the history
`elements` are preserved or defaulted to `[]`
`relations` are preserved or defaulted to `[]`
`metadata` are preserved or defaulted to `{}`

Closes #1
  • Loading branch information
B3rn475 committed Nov 13, 2017
1 parent 123979b commit f860b36
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/extender.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ function createModel(options) {
function Model(json) {
if (!(this instanceof Model)) { return new Model(json); }

this.elements = json.elements.slice();
this.relations = json.relations.slice();
this.elements = (json.elements || []).slice();
this.relations = (json.relations || []).slice();
this.metadata = json.metadata || {};

var self = this,
element = createElementsLookup(this.elements),
Expand Down

0 comments on commit f860b36

Please sign in to comment.