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

Broken behaviour on super calls of Ember 1.13.X #13123

Closed
adrigzr opened this issue Mar 18, 2016 · 2 comments
Closed

Broken behaviour on super calls of Ember 1.13.X #13123

adrigzr opened this issue Mar 18, 2016 · 2 comments

Comments

@adrigzr
Copy link

adrigzr commented Mar 18, 2016

Hi,

Debugging a wierd behaviour on a production app I realiced that super calls are broken on all versions of Ember 1.13. Can't tell if it goes higher.

The bug is tested though this gist. Ember must be placed as minified version.

https://gist.github.com/adrigzr/66aedb0801c29db44203

When an action is called over an object and its parent has a method with the same name that gets called in the action, all the actions called in the parent method gets a wrong super call.

The gist is supposed to console log only 1 'foo' string, but it gets called twice.

I reproduce the bug using an action called refresh that calls the refresh method on the Ember.Route class. That method calls the action "willTransition" and that action gets the wrong super call.

The bug only can be reproduced on a minified version of Ember, where "sourceAvailable" variable is false when setting super methods.

Regards,

@rwjblue
Copy link
Member

rwjblue commented Mar 18, 2016

The sourceAvailable check was broken when minified until #12463 landed in 2.1.1. It basically forced all minified checks for sourceAvailable to be 'false'.

However, the providing of super should have still worked (it just would miss out on the optimization of avoiding adding a super wrapper when it isn't needed). So this bug may still manifest even on latest versions on platforms that do not support Function.prototype.toString.

@rwjblue
Copy link
Member

rwjblue commented Apr 10, 2016

OK, after re-reviewing the attached gist, it turns out this is a duplicate of #13230. What is happening is that the _super property is not being properly reset between method invocations, and calling this._super from within actions.bar is actually invoking the foo function.

I had started working on a fix in #13242, but I believe that the solution isn't quite that simple. We will likely attempt to introduce an error/warning/etc when you attempt to call _super when there is no parent class super function to invoke (this mimics the behavior of super from within ES6 classes and most other languages).

Thank you for reporting this issue, and sorry it has taken so long for me to fully understand what is going on. I'm going to close this issue, but continue tracking the problem in #13242 and #13230.

@rwjblue rwjblue closed this as completed Apr 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants