New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed constructor property on Spinner instances #61

Closed
wants to merge 1 commit into
base: gh-pages
from

Conversation

Projects
None yet
2 participants
@mackuba

mackuba commented Mar 21, 2012

When you overwrite Spinner.prototype to define instance methods, it loses the the constructor property which is set by default to the class itself, which can be used to identify object constructors. This may break inheritance chain if the user makes a class that inherits from Spinner, e.g. using Coffeescript's class inheritance.

This is how it should work:

function Spinner() {}
=> undefined
(new Spinner).constructor
=> function Spinner() {}

This is what happens if you overwrite the prototype:

Spinner.prototype = {}
=> Object
(new Spinner).constructor
=> function Object() { [native code] }
fixed constructor property on Spinner instances
when Spinner.prototype is overwritten to define instance methods,
it loses the previously set constructor property which is used
to identify object constructors; this may break inheritance chain
if another class inherits from Spinner

@fgnass fgnass closed this in ee7b4d5 Mar 21, 2012

@mackuba

This comment has been minimized.

Show comment
Hide comment
@mackuba

mackuba Mar 21, 2012

Ok, thanks!

mackuba commented Mar 21, 2012

Ok, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment