Skip to content
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

[CLEANUP] Remove _actions functionality #15914

Merged
merged 2 commits into from
Dec 4, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2447,33 +2447,6 @@ moduleFor('Components test: curly components', class extends RenderingTest {
}, 'Attempting to inject an unknown injection: \'service:missingService\'');
}

['@test can access `actions` hash via `_actions` [DEPRECATED]']() {
let component;

function derp() { }

this.registerComponent('foo-bar', {
ComponentClass: Component.extend({
init() {
this._super(...arguments);
component = this;
},

actions: {
derp
}
})
});

this.render('{{foo-bar}}');

this.assert.strictEqual(component.actions.derp, derp);

expectDeprecation(() => {
this.assert.strictEqual(component._actions.derp, derp);
}, 'Usage of `_actions` is deprecated, use `actions` instead.');
}

['@test throws if `this._super` is not called from `init`']() {
this.registerComponent('foo-bar', {
ComponentClass: Component.extend({
Expand Down
5 changes: 1 addition & 4 deletions packages/ember-routing/lib/system/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import {
Object as EmberObject,
A as emberA,
Evented,
ActionHandler,
deprecateUnderscoreActions
ActionHandler
} from 'ember-runtime';
import generateController from './generate_controller';
import {
Expand Down Expand Up @@ -2200,8 +2199,6 @@ let Route = EmberObject.extend(ActionHandler, Evented, {
}
});

deprecateUnderscoreActions(Route);

Route.reopenClass({
isRouteFactory: true
});
Expand Down
49 changes: 0 additions & 49 deletions packages/ember-routing/tests/system/route_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,55 +203,6 @@ QUnit.test('.send just calls an action if the routers internal router property i
equal(undefined, route.send('nonexistent', 1, 2, 3));
});

QUnit.test('can access `actions` hash via `_actions` [DEPRECATED]', function() {
expect(2);

let route = EmberRoute.extend({
actions: {
foo: function() {
ok(true, 'called foo action');
}
}
}).create();

expectDeprecation(function() {
route._actions.foo();
}, 'Usage of `_actions` is deprecated, use `actions` instead.');
});

QUnit.test('actions in both `_actions` and `actions` results in an assertion', function() {
expectAssertion(function() {
EmberRoute.extend({
_actions: { },
actions: { }
}).create();
}, 'Specifying `_actions` and `actions` in the same mixin is not supported.');
});

QUnit.test('actions added via `_actions` can be used [DEPRECATED]', function() {
expect(3);

let route;
expectDeprecation(function() {
route = EmberRoute.extend({
_actions: {
bar: function() {
ok(true, 'called bar action');
}
}
}, {
actions: {
foo: function() {
ok(true, 'called foo action');
}
}
}).create();
}, 'Specifying actions in `_actions` is deprecated, please use `actions` instead.');

route.send('foo');
route.send('bar');
});

QUnit.module('Ember.Route serialize', {
setup: setup,
teardown: teardown
Expand Down
3 changes: 0 additions & 3 deletions packages/ember-runtime/lib/controllers/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { assert } from 'ember-debug';
import EmberObject from '../system/object';
import Mixin from '../mixins/controller';
import { createInjectionHelper } from '../inject';
import { deprecateUnderscoreActions } from '../mixins/action_handler';

/**
@module @ember/controller
Expand All @@ -16,8 +15,6 @@ import { deprecateUnderscoreActions } from '../mixins/action_handler';
*/
const Controller = EmberObject.extend(Mixin);

deprecateUnderscoreActions(Controller);

function controllerInjectionHelper(factory) {
assert(
'Defining an injected controller property on a ' +
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-runtime/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ export { default as ObjectProxy } from './system/object_proxy';
export { default as CoreObject } from './system/core_object';
export { default as NativeArray, A } from './system/native_array';
export {
default as ActionHandler,
deprecateUnderscoreActions
default as ActionHandler
} from './mixins/action_handler';
export { default as Copyable } from './mixins/copyable';
export { default as Enumerable } from './mixins/enumerable';
Expand Down
33 changes: 1 addition & 32 deletions packages/ember-runtime/lib/mixins/action_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,38 +212,7 @@ const ActionHandler = Mixin.create({
}
},

willMergeMixin(props) {
assert('Specifying `_actions` and `actions` in the same mixin is not supported.', !props.actions || !props._actions);

if (props._actions) {
deprecate(
'Specifying actions in `_actions` is deprecated, please use `actions` instead.',
false,
{ id: 'ember-runtime.action-handler-_actions', until: '3.0.0' }
);

props.actions = props._actions;
delete props._actions;
}
}
willMergeMixin() {}
Copy link
Member

Choose a reason for hiding this comment

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

I think we can remove the implementation completely?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

No, removing this empty function shouldn’t affect that (we aren’t removing the functionality yet)...

});

export default ActionHandler;

export function deprecateUnderscoreActions(factory) {
Object.defineProperty(factory.prototype, '_actions', {
configurable: true,
enumerable: false,
set(value) {
assert(`You cannot set \`_actions\` on ${this}, please use \`actions\` instead.`);
},
get() {
deprecate(
`Usage of \`_actions\` is deprecated, use \`actions\` instead.`,
false,
{ id: 'ember-runtime.action-handler-_actions', until: '3.0.0' }
);
return get(this, 'actions');
}
});
}
16 changes: 0 additions & 16 deletions packages/ember-runtime/tests/controllers/controller_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,6 @@ import { buildOwner } from 'internal-test-helpers';

QUnit.module('Controller event handling');

QUnit.test('can access `actions` hash via `_actions` [DEPRECATED]', function() {
expect(2);

let controller = Controller.extend({
actions: {
foo: function() {
ok(true, 'called foo action');
}
}
}).create();

expectDeprecation(function() {
controller._actions.foo();
}, 'Usage of `_actions` is deprecated, use `actions` instead.');
});

QUnit.test('Action can be handled by a function on actions object', function() {
expect(1);
let TestController = Controller.extend({
Expand Down
5 changes: 1 addition & 4 deletions packages/ember-views/lib/views/core_view.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {
ActionHandler,
Evented,
FrameworkObject,
deprecateUnderscoreActions
FrameworkObject
} from 'ember-runtime';
import { initViewElement } from '../system/utils';
import { cloneStates, states } from './states';
Expand Down Expand Up @@ -79,8 +78,6 @@ const CoreView = FrameworkObject.extend(Evented, ActionHandler, {
}
});

deprecateUnderscoreActions(CoreView);

CoreView.reopenClass({
isViewFactory: true
});
Expand Down