-
Notifications
You must be signed in to change notification settings - Fork 5
Conversation
@@ -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))); |
There was a problem hiding this comment.
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]
?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A-okay. Got it. 👌
@AdamMagaluk This looks good to me. Any objection to merging? (Asking permission, because well... you know... it's complicated. 😉) |
LGTM. Sorry for the delay @kevinswiber and @marvinroger been busy with other projects this week. I hope to give all the other PRs a review in the next few days. |
@AdamMagaluk Your "delay" was 12 hours. Go easy on yourself. I've committed far more atrocious open source crimes. 😺 |
Don't worry, moreover we don't live in the same TZ (Europe/Paris for me) so there will be delay anyway. 😉 |
Thanks! Can you make a release? |
Doing it now. |
v0.8.0 Released. |
This stays ES5 compatible and allow usage of ES6 classes. See this link for the explanation.
Basically, this allow this smoother syntax:
Both syntaxes still work with this PR.