-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[DEPRECATION]Deprecate send action (RFC #335) #16744
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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...
@@ -116,6 +116,10 @@ export default Mixin.create({ | |||
`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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -271,10 +271,30 @@ moduleFor( | |||
// this.assertSelectionRange(8, 8); //NOTE: this fails in IE, the range is 0 -> 0 (TEST_SUITE=sauce) | |||
} | |||
|
|||
['@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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...
@@ -3,7 +3,6 @@ import { RENDER_HELPER } from '@ember/deprecated-features'; | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you tweak the function name here (it current is deprecateRender
)?
@@ -40,6 +41,7 @@ const transforms: Array<APluginFunc> = [ | |||
TransformInElement, | |||
AssertIfHelperWithoutArguments, | |||
AssertSplattributeExpressions, | |||
DeprecateSendAction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you wrap the "guts" of this function in if (SEND_ACTION) {
for svelting purposes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file size reduction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this AST transforms were not shipped as templates are compiled to JSON.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, how does this guard support?
{{input action='some-generic-action'}}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.