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
Static class properties should be inherited #1900
Comments
Hum, this is pretty annoying. Why would they even specify something like that in ES6 in the first place? My main concern about this is that there is no standard way to implement this behavior in ES5.1. Neither It seems like a small thing, but so far we have successfully avoided to rely on even the slightest non-standard feature. Breaking this here, even for a "widely supported non-standard extension" such as Note that "widely supported" does not include IE < 11. So any code relying on this just can't work in IE 10 and earlier (and no, this is not bashing against IE; on the contrary, IE was the only browser to not deviate from the standard, here; everybody else is to blame). It is also unclear whether Rhino supports it. And that's even without even considering the fact that setting On the other hand, it seems we don't even have a choice, if frameworks like React start relying on this prototype chain behavior. Why would they do such a thing when there is no workaround on IE 10!? |
My mistake, I didn't realize this wasn't supported in IE10. We'll reconsider for React 0.14 final. |
Cool, they changed React not to rely on static property inheritance anymore :) So I believe we can close this on our end. Thanks React's team :-) |
I still suggest that you at least copy over static properties at class creation time. |
Without a compelling use case needing inheritance but not the ability to define static members (as React requiring us to do so would have been), a solution to this problem should be part of #1902 anyway. |
Okay, sounds great! |
In ES6 classes, static properties should be inherited. That is,
should log "5". This can be done by looping over the properties and copying, but that's subpar because updating the static properties on the superclass should update them on the subclass too. Babel sets
__proto__
to achieve this:https://github.com/babel/babel/blob/554fda00c179eea72121cafe4b90fac85c1bb244/packages/babel/src/transformation/templates/helper-inherits.js#L13
It doesn't look like the ES5 emitter makes any attempt to get the same behavior:
scala-js/tools/shared/src/main/scala/org/scalajs/core/tools/javascript/ScalaJSClassEmitter.scala
Lines 202 to 257 in bb2e2a7
This means scala-js does not work with React 0.14+ which checks for a static flag on classes extending React.Component:
http://stackoverflow.com/questions/32509891/warning-react-component-classes-must-extend-react-component-0-14-rc1
The text was updated successfully, but these errors were encountered: