Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

✨ Allow ES6 classes #7

Merged
merged 1 commit into from
Apr 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions scientist.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ exports.create = function(/* constructor, ...constructorArgs */) {
var machine;

if (constructor.prototype) {
machine = Object.create(constructor.prototype);
machine.constructor.apply(machine, constructorArgs);
machine = new (Function.prototype.bind.apply(constructor, [null].concat(constructorArgs)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marvinroger Should [null] here be [constructor.prototype]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because the first element given to bind (the context) is overwritten by the new. See http://stackoverflow.com/a/35878917

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A-okay. Got it. 👌

} else if (constructor.init) {
machine = constructor;
}
Expand Down