Skip to content

Commit

Permalink
ES6 classes compatible method for instantiating objects
Browse files Browse the repository at this point in the history
  • Loading branch information
bschaepper committed Sep 11, 2015
1 parent 192f221 commit b7c33f1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ Registry.prototype = {

createInstanceFactory: function (constructorFunction) {
return function () {
var instance = Object.create(constructorFunction.prototype);
constructorFunction.apply(instance, arguments);
return instance;
var args = [null].concat(Array.prototype.slice.call(arguments))
return new (Function.prototype.bind.apply(constructorFunction, args));
}.bind(this);
},

Expand Down

0 comments on commit b7c33f1

Please sign in to comment.