Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(schema): make clone() work with reusing discriminator schemas
Fix #5098
  • Loading branch information
vkarpov15 committed Mar 23, 2017
1 parent 432360e commit 51b8e80
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/schema.js
Expand Up @@ -343,8 +343,11 @@ Schema.prototype.tree;
*/

Schema.prototype.clone = function() {
var s = Object.create(Schema.prototype);
utils.merge(s, this, { retainKeyOrder: true, hasOwnProperty: true });
var s = new Schema(this.obj, this.options);
// Clone the call queue
s.callQueue = this.callQueue.map(function(f) { return f; });
s.methods = utils.clone(this.methods);
s.statics = utils.clone(this.statics);
return s;
};

Expand Down

0 comments on commit 51b8e80

Please sign in to comment.