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

Calling _super in a CP has the wrong context when retrieved from an action #13230

Closed
offirgolan opened this issue Apr 1, 2016 · 7 comments
Closed
Labels

Comments

@offirgolan
Copy link

In an Ember.Object, when you call this._super in a CP, it will retrieve the parent's value of that same property. What was found is that when you fetch a CP that has a _super call in an action handler, the _super context is that of the parent's action and not of the parent's CP.

Ember Twiddle - Tested on Ember 1.13.13 to Canary

When you click the save button, the following should happen:

  1. Grab validations object which also grabs inherited validations if possible
  2. the my-component action should be called which at the end calls _super (defined in CRUD mixin)
  3. The CRUD save action should then be called

What is actually happening:

  1. Grab validations object
  2. _super in validations objects calls the CRUD mixin save action instead of inherited validations cp
  3. Do stuff in my-component save action as intended and then call _super (defined in CRUD mixin)
  4. The CRUD save action should then be called
@offirgolan
Copy link
Author

cc @stefanpenner @rwjblue

@stefanpenner
Copy link
Member

Yup, seems like a bug.

@offirgolan if you have cycles a failing test would be sweet, im going to skim the code and see what may be going sideways.

@stefanpenner
Copy link
Member

I believe the issue is, the cp has no super so it doesn't bother super wrapping it. But if it does not super wrap it, it doesn't reset the actions _super when entering the CP.

https://github.com/emberjs/ember.js/blob/master/packages/ember-metal/lib/mixin.js#L105-L107.

The above code should insert a no-op super wrapper if no super descriptor is found, rather then circuiting.

I believe this should be a pretty quick fix, but it is unlikely I will be able to look at it more closely until Sunday. If no-one else does, and if i forgot please ping me :P

@offirgolan
Copy link
Author

👍 Sweet will do. I dont have too much free time unfortunately, but if I find a spare moment, ill whip up a test. Thanks for taking this on!

@rwjblue
Copy link
Member

rwjblue commented Apr 4, 2016

Submitted #13242 with a couple tests and fix. Needs review.

@offirgolan
Copy link
Author

👌 thanks Rob

On Sunday, April 3, 2016, Robert Jackson notifications@github.com wrote:

Submitted #13242 #13242 with a
couple tests and fix. Needs review.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#13230 (comment)

Thanks,
Offir Golan

@rwjblue
Copy link
Member

rwjblue commented Apr 10, 2016

See #13242 (comment) for an update. I'm going to close this for now, and track the underlying issue in #13242 instead.

Thank you for reporting, hopefully we can get something in place to help prevent this sort of trollage in the near future.

@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
Projects
None yet
Development

No branches or pull requests

3 participants