Skip to content

Commit

Permalink
[FEATURE modernized-built-in-components] Deprecate input actions as s…
Browse files Browse the repository at this point in the history
…trings

Tracking issue: #19270
Get tests passing for no actions passed to inputs as strings deprecation
  • Loading branch information
eramod committed Feb 9, 2021
1 parent c32d3c5 commit 7f432a2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
26 changes: 12 additions & 14 deletions packages/@ember/-internals/glimmer/lib/components/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -927,20 +927,18 @@ if (EMBER_MODERNIZED_BUILT_IN_COMPONENTS) {
const actionName = this.arg(type);

if (typeof actionName === 'string') {
// TODO: eagerly issue a deprecation for this as well (need to fix tests)
//
// deprecate(
// `Passing actions to components as strings (like \`<${this.constructor} @${type}="${actionName}" />\`) is deprecated. ` +
// `Please use closure actions instead (\`<${this.constructor} @${type}={{action "${actionName}"}} />\`).`,
// false,
// {
// id: 'ember-component.send-action',
// for: 'ember-source',
// since: {},
// until: '4.0.0',
// url: 'https://emberjs.com/deprecations/v3.x#toc_ember-component-send-action',
// }
// );
deprecate(
`Passing actions to components as strings (like \`<${this.constructor} @${type}="${actionName}" />\`) is deprecated. ` +
`Please use closure actions instead (\`<${this.constructor} @${type}={{action "${actionName}"}} />\`).`,
false,
{
id: 'ember-component.send-action',
for: 'ember-source',
since: {},
until: '4.0.0',
url: 'https://emberjs.com/deprecations/v3.x#toc_ember-component-send-action',
}
);

const { caller } = this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,11 @@ moduleFor(
},
},
});
}, 'Passing actions to components as strings (like `<Input @key-press="foo" />`) is deprecated. Please use closure actions instead (`<Input @key-press={{action "foo"}} />`). (\'-top-level\' @ L1:C0) ');
}, /Passing actions to components as strings \(like `({{input key-press="foo"}}|<Input @key-press="foo" \/>)`\) is deprecated\./);

expectDeprecation(() => {
this.triggerEvent('keypress', { key: 'A' });
}, 'Passing actions to components as strings (like `<Input @key-press="foo" />`) is deprecated. Please use closure actions instead (`<Input @key-press={{action "foo"}} />`).');
}, /Passing actions to components as strings \(like `({{input key-press="foo"}}|<Input @key-press="foo" \/>)`\) is deprecated\./);
}

['@test sends an action with `<Input @key-press={{action "foo"}} />` is pressed'](assert) {
Expand Down Expand Up @@ -765,7 +765,7 @@ moduleFor(
},
},
});
}, 'Passing actions to components as strings (like `<Input @key-down="foo" />`) is deprecated. Please use closure actions instead (`<Input @key-down={{action "foo"}} />`). (\'-top-level\' @ L1:C0) ');
}, /Passing actions to components as strings \(like `({{input key-down="foo"}}|<Input @key-down="foo" \/>)`\) is deprecated\./);

expectDeprecation(() => {
this.triggerEvent('keydown', { key: 'A' });
Expand Down Expand Up @@ -811,7 +811,7 @@ moduleFor(
},
},
});
}, 'Passing actions to components as strings (like `<Input @key-up="foo" />`) is deprecated. Please use closure actions instead (`<Input @key-up={{action "foo"}} />`). (\'-top-level\' @ L1:C0) ');
}, /Passing actions to components as strings \(like `({{input key-up="foo"}}|<Input @key-up="foo" \/>)`\) is deprecated\./);

expectDeprecation(() => {
this.triggerEvent('keyup', { key: 'A' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,11 @@ moduleFor(
},
},
});
}, 'Passing actions to components as strings (like `{{input key-press="foo"}}`) is deprecated. Please use closure actions instead (`{{input key-press=(action "foo")}}`). (\'-top-level\' @ L1:C0) ');
}, /Passing actions to components as strings \(like `({{input key-press="foo"}}|<Input @key-press="foo" \/>)`\) is deprecated\./);

expectDeprecation(() => {
this.triggerEvent('keypress', { key: 'A' });
}, 'Passing actions to components as strings (like `<Input @key-press="foo" />`) is deprecated. Please use closure actions instead (`<Input @key-press={{action "foo"}} />`).');
}, /Passing actions to components as strings \(like `({{input key-press="foo"}}|<Input @key-press="foo" \/>)`\) is deprecated\./);
}

['@test sends an action with `{{input key-press=(action "foo")}}` is pressed'](assert) {
Expand Down Expand Up @@ -595,7 +595,7 @@ moduleFor(
},
},
});
}, 'Passing actions to components as strings (like `{{input key-down="foo"}}`) is deprecated. Please use closure actions instead (`{{input key-down=(action "foo")}}`). (\'-top-level\' @ L1:C0) ');
}, /Passing actions to components as strings \(like `({{input key-down="foo"}}|<Input @key-down="foo" \/>)`\) is deprecated\./);

expectDeprecation(() => {
this.triggerEvent('keydown', { key: 'A' });
Expand Down Expand Up @@ -641,7 +641,7 @@ moduleFor(
},
},
});
}, 'Passing actions to components as strings (like `{{input key-up="foo"}}`) is deprecated. Please use closure actions instead (`{{input key-up=(action "foo")}}`). (\'-top-level\' @ L1:C0) ');
}, /Passing actions to components as strings \(like `({{input key-up="foo"}}|<Input @key-up="foo" \/>)`\) is deprecated\./);

expectDeprecation(() => {
this.triggerEvent('keyup', { key: 'A' });
Expand Down

0 comments on commit 7f432a2

Please sign in to comment.