Repository navigation
[DEPRECATION]Deprecate send action (RFC #335) - #16744
Conversation
rwjblue
left a comment
There was a problem hiding this comment.
Looking good! I left an inline comment RE: including more identifiable info in the deprecation message, and I'd like to see the sendAction support code be wrapped for svelting as part of this PR.
The svelte wrapping stuff is pretty new, but should hopefully be easy to add. I'll dig up an example...
| `Attempted to call .sendAction() with the action '${action}' on the destroyed object '${this}'.`, | ||
| !this.isDestroying && !this.isDestroyed | ||
| ); | ||
| deprecate('Component#sendAction is deprecated. Please use closure actions instead.', false, { |
There was a problem hiding this comment.
We should include this somewhere in the deprecation message (to help track down where the deprecation is coming from).
|
See #16745 for an example of the work needed to svelte... |
| deprecate( | ||
| `Passing actions to components as strings (like {{input ${eventName}="${actionName}"}}) is deprecated. Please use closure actions instead ({{input ${eventName}=(action "${actionName}")}})`, | ||
| false, | ||
| { id: 'ember-input.send-action', until: '4.0.0' } |
There was a problem hiding this comment.
Note to self: Use the same id than in the sendAction deprecation even if the text is different, as in it's essence it's the same feature.
1d5687a to
456b62c
Compare
|
@rwjblue I've implemented the AST deprecation and tested it. I've also wrapped the Points of attention:
|
|
PR for the deprecation entry: ember-learn/deprecation-app#146 |
382ef10 to
1f28a7b
Compare
|
|
||
| ['@test sends an action with `{{input enter="foo"}}` when <enter> is pressed'](assert) { | ||
| assert.expect(1); | ||
| ['@test sends an action with `{{input enter="foo"}}` when <enter> is pressed with deprecation']( |
There was a problem hiding this comment.
Can we tweak the tests that we now consider deprecated to have [DEPRECATED] in the test title (instead of in this case with deprecation)?
It will make future removal much easier...
| import { AST, ASTPlugin, ASTPluginEnvironment } from '@glimmer/syntax'; | ||
| import calculateLocationDisplay from '../system/calculate-location-display'; | ||
|
|
||
| // Remove after 3.4 once _ENABLE_RENDER_SUPPORT flag is no longer needed. |
There was a problem hiding this comment.
Hmm, I think this comment is still valid...
| 'key-down', | ||
| ]; | ||
|
|
||
| export default function deprecateRender(env: ASTPluginEnvironment): ASTPlugin | undefined { |
There was a problem hiding this comment.
Can you tweak the function name here (it current is deprecateRender)?
| TransformInElement, | ||
| AssertIfHelperWithoutArguments, | ||
| AssertSplattributeExpressions, | ||
| DeprecateSendAction, |
There was a problem hiding this comment.
Similar to the RENDER_HELPER usage in this file, can you move this down into a conditional? That will allow us to strip all of the plugin code when an app says they are compliant with 3.5 (aka svelte)...
| ]; | ||
|
|
||
| export default function deprecateRender(env: ASTPluginEnvironment): ASTPlugin | undefined { | ||
| let { moduleName } = env.meta; |
There was a problem hiding this comment.
Can you wrap the "guts" of this function in if (SEND_ACTION) { for svelting purposes?
There was a problem hiding this comment.
If in packages/ember-template-compiler/lib/plugins/index.ts I only conditionally push the transform, what's the point of wrapping the "guts" yet again on the same condition?
There was a problem hiding this comment.
I thought this AST transforms were not shipped as templates are compiled to JSON.
There was a problem hiding this comment.
you are correct, they are not shipped for a default app, but it is still "a thing" to ship the template compiler at runtime so that you can compile dynamic templates
| let value = get(view, 'value'); | ||
|
|
||
| view.sendAction(eventName, value); | ||
| if (typeof actionName === 'string') { |
There was a problem hiding this comment.
Can you add SEND_ACTION to this conditional?
So it would become:
if (SEND_ACTION && typeof actionName === 'string') {There was a problem hiding this comment.
Also, how does this guard support?
There was a problem hiding this comment.
What does {{input action='some-generic-action'}} do?
b21f77b to
ab4b623
Compare
This also implicitly deprecated passing actions to the built-in inputs like `{{input enter="foo"}},
instead users must do `{{input enter=(action "foo")}}`.
There is a build-time deprecation that uses AST visitors to output precise information of file
and line the offending code is.
There is also a runtime-deprecation for cases that the AST deprecation can't catch.
ab4b623 to
10f876d
Compare
|
@rwjblue can you rebuild the browserstack job? I think it's a false negative. |
|
Done! |
|
Green! |
|
The deprecation RFC has been merged now, so this is good to go. Thanks @cibernox! |
|
@rwjblue the docs also need a push 😄 |
Ready for review.