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 authored and chancancode committed Feb 25, 2021
1 parent a7f48db commit 1f403db
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 @@ -603,11 +603,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 @@ -759,7 +759,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 @@ -805,7 +805,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 @@ -438,11 +438,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 @@ -594,7 +594,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 @@ -640,7 +640,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 1f403db

Please sign in to comment.