[Bugfix Beta] Fix for auto-mut wrapping of closure actions.#13996
Merged
krisselden merged 2 commits intomasterfrom Sep 29, 2016
Merged
[Bugfix Beta] Fix for auto-mut wrapping of closure actions.#13996krisselden merged 2 commits intomasterfrom
krisselden merged 2 commits intomasterfrom
Conversation
homu
added a commit
to DockYard/ember-route-action-helper
that referenced
this pull request
Aug 2, 2016
Add ember-alpha to try config. Tests are passing (with the tweak to avoid using `this.attrs` in the acceptance test). I have reported the issue that passing an action through a middle layer doesn't properly prevent mut-wrapping in `this.attrs` as was done in HTMLBars with a failing test in emberjs/ember.js#13996.
Member
|
Something seems fishy here, why is any new code accessing |
Member
|
Ah it's in the test, carry on |
rwjblue
commented
Sep 29, 2016
|
|
||
| if (ref[UPDATE]) { | ||
| if (typeof value === 'function') { | ||
| attrs[name] = value; |
Member
Author
There was a problem hiding this comment.
This would prevent passing a class down to a child component. Given the following setup (we should add a test for this):
{{! parent component }}
export default Ember.Component.extend({
init() {
this._super();
this.klass = Ember.Object.extend();
}
});// foo-bar component
export default Ember.Component.extend({
actions: {
updateKlass(newKlass) {
this.attrs.klass.update(newKlass);
}
}
});| let value = attrs[name]; | ||
|
|
||
| if (ref[UPDATE]) { | ||
| if (typeof value === 'function') { |
Member
Author
There was a problem hiding this comment.
In prior versions (1.13 - 2.8) we use a symbol stamped on the generated action function that we used as an identifier that this is an action.
Assuming we do the same here (this would alleviate the concern about intentionally passing down a class / function that is intended to be two way bound), this would look something like:
if (typeof value === 'function' && value[ACTION]) {
attrs[name] = value;
} else if (ref[UPDATE]) {
// ...snip...
}Given the following:
```hbs
{{x-foo derp=(action 'herk')}}
```
```hbs
{{! app/templates/components/x-foo.hbs }}
{{x-bar derp=derp}}
```
```js
export default Component.extend({
didInsertElement() {
this.get('derp')();
m }
});
```
An error is triggered with the following output:
```
TypeError: this.attrs.derp is not a function
at Class.fireAction (http://localhost:7200/ember-tests.js:21306:46)
at http://localhost:7200/ember-tests.js:21344:24
at Object.run (http://localhost:7200/ember.debug.js:294:25)
at Object.run [as default] (http://localhost:7200/ember.debug.js:19515:27)
at _class2.runTask (http://localhost:7200/ember-tests.js:32041:34)
at _class2.testActionClosureDoesNotGetAutoMutWrapped [as @test action closure does not get auto-mut wrapped] (http://localhost:7200/ember-tests.js:21343:12)
at Object.<anonymous> (http://localhost:7200/ember-tests.js:31691:31)
at runTest (http://localhost:7200/qunit/qunit.js:843:28)
at Object.run (http://localhost:7200/qunit/qunit.js:828:4)
at http://localhost:7200/qunit/qunit.js:970:11
```
86276f9 to
0a94359
Compare
0a94359 to
05fd916
Compare
This was referenced Sep 29, 2016
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Given the following:
An error is triggered with the following output: