Helper only works using Object-Key syntax
Closed this issue · 10 comments
Example usages that don't work:
{{my-component onAction=(set this.boolProp true)}}
{{my-component onAction=(action (set this.boolProp true))}}
Perhaps this is the intended response and the docs just need updating.
The Object-key syntax works fine.
{{my-component onAction=(set this "boolProp" true)}}
{{my-component onAction=(action (set this "boolProp" true))}}
There are tests for this form, it's definitely supported, not a docs mistake.
This does require a template transform to run on your code, it's registered here: https://github.com/pzuraq/ember-set-helper/blob/master/index.js#L6
I can't tell at a glance that you're doing anything that should prevent that transform from being registered and running, but I'm pretty sure something about your setup is causing it, since we've tested this in vanilla addons/apps generally. I'll see if I can reproduce in a vanilla addon when I get a moment though, if you can provide a reproduction that'd really help!
@pzuraq - I think I'm hitting a similar problem. This works:
This leads to the same error as in the first post:
I'm actually not sure why any of those would work, I guess that's because of that transform you mention. But what about the second case - what's the issue with it?
@boris-petrov does something like (set this.bar 'baz')
work? If so, the transform is working, but doesn't cover the @foo
use case, and that's something we should add because yes it should make sense.
@pzuraq - yes, sorry, I should have mentioned that (set this.bar 'baz')
works while (set @foo.bar 'baz')
doesn't. That's a known issue if I understand correctly from your comment?
That was not a known issue, thanks for bringing it up. This is a separate issue than the one described by @mattgraham1995, which is caused by the transform not running at all, but we definitely should solve it.
The issue reported by @boris-petrov started hitting me on Ember 3.17. It used to work for me on Ember 3.16 and before that. I've created a test for easier reproduction: #12.
Added a fix that seems to be working for me in the same PR. @pzuraq please take a look.
It seems like #12 is now merged -- did that fix the issue for you @mattgraham1995 and/or @boris-petrov ?
@alexlafroscia - it might be fixed, yes, but @pzuraq has to release a new version from master
. I can test after that and I'll shout if it's still broken. 😄
I'm going to be merging a refactor to bring this addon inline with ember-simple-set-helper
and all of the issues with nested paths/argument paths should be fixed. I'm going to close this issue for now, but feel free to reopen if it's still an issue in the new version.