Skip to content
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

A Subclass with extend has an enumerable constructor #2270

Closed
jspies opened this issue Apr 18, 2012 · 3 comments
Closed

A Subclass with extend has an enumerable constructor #2270

jspies opened this issue Apr 18, 2012 · 3 comments
Labels

Comments

@jspies
Copy link

jspies commented Apr 18, 2012

Iterating over a class does not enumerate "constructor", which I would expect.

class Base
  constructor: ->

test = new Base

for name, value of test
  console.log(name)

There's no output, as expected. But when I extend the class, the constructor shows up in enumeration.

class Base
  constructor: ->

class Test extends Base

test = new Test

for name, value of test
  console.log(name)

Output is "constructor"

I'm assuming this isn't desired behavior, but I'm not sure of a workaround or fix at this point.

@michaelficarra
Copy link
Collaborator

Base.prototype still has a constructor property, it's just non-enumerable (see §13.2 step 17). We can't define a non-enumerable constructor property on the subclass's prototype in our target of least-common-denominator (IE6) JS. Marking as wontfix and frozen, since we could theoretically fix this one day if we target ES5. Thanks for the bug report, though.

@jspies
Copy link
Author

jspies commented Apr 18, 2012

Alright, I was able to work around it with

class Test extends Base
Object.defineProperty(Test.prototype, 'constructor', {enumerable:false})

Do you guys have a discussion anywhere about why you are supporting IE6?

@michaelficarra
Copy link
Collaborator

See #2008 for the most recent discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants