Skip to content

Commit

Permalink
[FEATURE modernized-built-in-components] Deprecate TargetActionSupport
Browse files Browse the repository at this point in the history
Implements emberjs/rfcs#720

Part of #19270
  • Loading branch information
chancancode committed Feb 25, 2021
1 parent 1f403db commit d854377
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 32 deletions.
3 changes: 1 addition & 2 deletions packages/@ember/-internals/views/lib/mixins/text_support.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/

import { get, set, Mixin } from '@ember/-internals/metal';
import { TargetActionSupport } from '@ember/-internals/runtime';
import { deprecate } from '@ember/debug';
import { SEND_ACTION } from '@ember/deprecated-features';
import { MUTABLE_CELL } from '@ember/-internals/views';
Expand Down Expand Up @@ -113,7 +112,7 @@ const KEY_EVENTS = {
@extends Mixin
@private
*/
export default Mixin.create(TargetActionSupport, {
export default Mixin.create({
value: '',

attributeBindings: [
Expand Down
51 changes: 30 additions & 21 deletions packages/ember/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,6 @@ Ember.NativeArray = NativeArray;
Ember.Copyable = Copyable;
Ember.MutableEnumerable = MutableEnumerable;
Ember.MutableArray = MutableArray;
Ember.TargetActionSupport = TargetActionSupport;
Ember.Evented = Evented;
Ember.PromiseProxyMixin = PromiseProxyMixin;
Ember.Observable = Observable;
Expand Down Expand Up @@ -586,28 +585,37 @@ Helper.helper = helper;
Ember.Helper = Helper;
if (EMBER_MODERNIZED_BUILT_IN_COMPONENTS) {
[
['Checkbox', '@ember/component/checkbox', Checkbox],
['TextField', '@ember/component/text-field', TextField],
['TextArea', '@ember/component/text-area', TextArea],
['LinkComponent', '@ember/routing/link-component', LinkComponent],
['TextSupport', '@ember/-internals/views', views.TextSupport],
].forEach(([name, path, value]) => {
['Checkbox', '@ember/component/checkbox', Checkbox, true],
['TextField', '@ember/component/text-field', TextField, true],
['TextArea', '@ember/component/text-area', TextArea, true],
['LinkComponent', '@ember/routing/link-component', LinkComponent, true],
['TextSupport', null, views.TextSupport, false],
['TargetActionSupport', null, TargetActionSupport, false],
].forEach(([name, path, value, availableInLegacyAddon]) => {
Object.defineProperty(Ember, name, {
get() {
deprecate(
`Using Ember.${name} or importing from '${path}' has been deprecated, install the ` +
`\`ember-legacy-built-in-components\` addon and use \`import { ${name} } from ` +
`'ember-legacy-built-in-components';\` instead`,
false,
{
id: 'ember.legacy-built-in-components',
until: '4.0.0',
for: 'ember-source',
since: {
// TODO: update this when enabling the feature
},
}
);
let message = `Using Ember.${name}`;

if (path !== null) {
message += ` or importing from '${path}'`;
}

message += ` is deprecated.`;

if (availableInLegacyAddon) {
message +=
` Install the \`ember-legacy-built-in-components\` addon and use ` +
`\`import { ${name} } from 'ember-legacy-built-in-components';\` instead.`;
}

deprecate(message, false, {
id: 'ember.built-in-components.legacy-import',
until: '4.0.0',
for: 'ember-source',
since: {
// TODO: update this when enabling the feature
},
});

return value;
},
Expand All @@ -625,6 +633,7 @@ if (EMBER_MODERNIZED_BUILT_IN_COMPONENTS) {
Ember.TextArea = TextArea;
Ember.LinkComponent = LinkComponent;
Ember.TextSupport = views.TextSupport;
Ember.TargetActionSupport = TargetActionSupport;
}
Ember._setComponentManager = setComponentManager;
Ember._componentManagerCapabilities = componentCapabilities;
Expand Down
25 changes: 16 additions & 9 deletions packages/ember/tests/reexports_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ moduleFor(
['TextField', '@ember/component/text-field', '@ember/-internals/glimmer'],
['TextArea', '@ember/component/text-area', '@ember/-internals/glimmer'],
['LinkComponent', '@ember/routing/link-component', '@ember/-internals/glimmer'],
['TextSupport', '@ember/-internals/views', '@ember/-internals/views'],
['TextSupport', null, '@ember/-internals/views'],
['TargetActionSupport', null, '@ember/-internals/runtime'],
].forEach(([name, publicPath, privatePath]) => {
// loosely based on confirmExport
try {
Expand All @@ -51,13 +52,17 @@ moduleFor(
`Ember._Legacy${name} has the correct value and does not trigger a deprecation`
);

expectDeprecation(() => {
assert.strictEqual(
Ember[name],
value,
`Ember.${name} has the correct value triggers a deprecation`
);
}, `Using Ember.${name} or importing from '${publicPath}' has been deprecated, install the \`ember-legacy-built-in-components\` addon and use \`import { ${name} } from 'ember-legacy-built-in-components';\` instead`);
expectDeprecation(
() =>
assert.strictEqual(
Ember[name],
value,
`Ember.${name} has the correct value triggers a deprecation`
),
publicPath === null
? `Using Ember.${name} is deprecated.`
: `Using Ember.${name} or importing from '${publicPath}' is deprecated. Install the \`ember-legacy-built-in-components\` addon and use \`import { ${name} } from 'ember-legacy-built-in-components';\` instead.`
);
} catch (error) {
assert.pushResult({
result: false,
Expand Down Expand Up @@ -336,7 +341,9 @@ let allExports = [
['Copyable', '@ember/-internals/runtime'],
['MutableEnumerable', '@ember/-internals/runtime'],
['MutableArray', '@ember/-internals/runtime'],
['TargetActionSupport', '@ember/-internals/runtime'],
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
? null
: ['TargetActionSupport', '@ember/-internals/runtime'],
['Evented', '@ember/-internals/runtime'],
['PromiseProxyMixin', '@ember/-internals/runtime'],
['Observable', '@ember/-internals/runtime'],
Expand Down

0 comments on commit d854377

Please sign in to comment.