Skip to content

[DEPRECATION]Deprecate send action (RFC #335) - #16744

Merged
rwjblue merged 1 commit into
emberjs:masterfrom
cibernox:deprecate-send-action
Jun 22, 2018
Merged

rwjblue merged 1 commit into
emberjs:masterfrom
cibernox:deprecate-send-action

Conversation

@cibernox

@cibernox cibernox commented Jun 12, 2018 •

Copy link
Copy Markdown
Contributor

Ready for review.

@rwjblue rwjblue left a comment

Copy link
Copy Markdown
Member

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...

`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, {

Copy link
Copy Markdown
Member

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).

@rwjblue

rwjblue commented Jun 12, 2018

Copy link
Copy Markdown
Member

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' }

Copy link
Copy Markdown
Contributor Author

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.

@cibernox
cibernox force-pushed the deprecate-send-action branch from 1d5687a to 456b62c Compare June 15, 2018 15:34
@cibernox cibernox changed the title [DEPRECATION][WIP]Deprecate send action (RFC #335) [DEPRECATION]Deprecate send action (RFC #335) Jun 15, 2018
@cibernox

Copy link
Copy Markdown
Contributor Author

@rwjblue I've implemented the AST deprecation and tested it. I've also wrapped the sendAction helper for svelte removal.

Points of attention:

  1. Should the AST deprecation to have the same ID as the runtime deprecation?
  2. In the file of constants for svelte, what's the version number I should use?

@cibernox

Copy link
Copy Markdown
Contributor Author

PR for the deprecation entry: ember-learn/deprecation-app#146

@cibernox
cibernox force-pushed the deprecate-send-action branch 3 times, most recently from 382ef10 to 1f28a7b Compare June 15, 2018 20:43

['@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'](

Copy link
Copy Markdown
Member

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...

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.

Copy link
Copy Markdown
Member

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 {

Copy link
Copy Markdown
Member

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)?

TransformInElement,
AssertIfHelperWithoutArguments,
AssertSplattributeExpressions,
DeprecateSendAction,

Copy link
Copy Markdown
Member

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;

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Contributor Author

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file size reduction

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

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') {

Copy link
Copy Markdown
Member

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') {

Copy link
Copy Markdown
Member

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'}}

Copy link
Copy Markdown
Contributor Author

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?

@cibernox
cibernox force-pushed the deprecate-send-action branch 4 times, most recently from b21f77b to ab4b623 Compare June 19, 2018 12:24
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.
@cibernox
cibernox force-pushed the deprecate-send-action branch from ab4b623 to 10f876d Compare June 19, 2018 12:51
@cibernox

Copy link
Copy Markdown
Contributor Author

@rwjblue can you rebuild the browserstack job? I think it's a false negative.

@rwjblue

rwjblue commented Jun 19, 2018

Copy link
Copy Markdown
Member

Done!

@cibernox

Copy link
Copy Markdown
Contributor Author

Green!

@rwjblue

rwjblue commented Jun 22, 2018

Copy link
Copy Markdown
Member

The deprecation RFC has been merged now, so this is good to go.

Thanks @cibernox!

@rwjblue
rwjblue merged commit 6f64dec into emberjs:master Jun 22, 2018
@cibernox
cibernox deleted the deprecate-send-action branch June 22, 2018 18:58
@cibernox

Copy link
Copy Markdown
Contributor Author

@rwjblue the docs also need a push 😄
ember-learn/deprecation-app#146

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants