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 beta] Remove support for actions in events key #11791

Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 2 additions & 12 deletions packages/ember-runtime/lib/mixins/action_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,24 +155,14 @@ var ActionHandler = Mixin.create({
@method willMergeMixin
*/
willMergeMixin(props) {
var hashName;

if (!props._actions) {
Ember.assert('\'actions\' should not be a function', typeof(props.actions) !== 'function');

if (!!props.actions && typeof props.actions === 'object') {
hashName = 'actions';
} else if (!!props.events && typeof props.events === 'object') {
Ember.deprecate('Action handlers contained in an `events` object are deprecated in favor' +
' of putting them in an `actions` object', false);
hashName = 'events';
}

if (hashName) {
let hashName = 'actions';
props._actions = merge(props._actions || {}, props[hashName]);
delete props[hashName];
}

delete props[hashName];
}
},

Expand Down
80 changes: 0 additions & 80 deletions packages/ember/tests/routing/basic_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -961,12 +961,6 @@ QUnit.test('ApplicationRoute\'s default error handler can be overridden', functi
testOverridableErrorHandler('actions');
});

QUnit.test('ApplicationRoute\'s default error handler can be overridden (with DEPRECATED `events`)', function() {
ignoreDeprecation(function() {
testOverridableErrorHandler('events');
});
});

asyncTest('Moving from one page to another triggers the correct callbacks', function() {
expect(3);

Expand Down Expand Up @@ -1240,80 +1234,6 @@ QUnit.asyncTest('Events defined in `actions` object are triggered on the current
action.handler(event);
});

QUnit.asyncTest('Events are triggered on the current state when defined in `events` object (DEPRECATED)', function() {
Router.map(function() {
this.route('home', { path: '/' });
});

var model = { name: 'Tom Dale' };

App.HomeRoute = Ember.Route.extend({
model() {
return model;
},

events: {
showStuff(obj) {
ok(this instanceof App.HomeRoute, 'the handler is an App.HomeRoute');
// Using Ember.copy removes any private Ember vars which older IE would be confused by
deepEqual(Ember.copy(obj, true), { name: 'Tom Dale' }, 'the context is correct');
QUnit.start();
}
}
});

Ember.TEMPLATES.home = compile(
'<a {{action \'showStuff\' model}}>{{name}}</a>'
);

expectDeprecation(/Action handlers contained in an `events` object are deprecated/);
bootApplication();

var actionId = Ember.$('#qunit-fixture a').data('ember-action');
var [ action ] = ActionManager.registeredActions[actionId];
var event = new Ember.$.Event('click');
action.handler(event);
});

QUnit.asyncTest('Events defined in `events` object are triggered on the current state when routes are nested (DEPRECATED)', function() {
Router.map(function() {
this.route('root', { path: '/' }, function() {
this.route('index', { path: '/' });
});
});

var model = { name: 'Tom Dale' };

App.RootRoute = Ember.Route.extend({
events: {
showStuff(obj) {
ok(this instanceof App.RootRoute, 'the handler is an App.HomeRoute');
// Using Ember.copy removes any private Ember vars which older IE would be confused by
deepEqual(Ember.copy(obj, true), { name: 'Tom Dale' }, 'the context is correct');
QUnit.start();
}
}
});

App.RootIndexRoute = Ember.Route.extend({
model() {
return model;
}
});

Ember.TEMPLATES['root/index'] = compile(
'<a {{action \'showStuff\' model}}>{{name}}</a>'
);

expectDeprecation(/Action handlers contained in an `events` object are deprecated/);
bootApplication();

var actionId = Ember.$('#qunit-fixture a').data('ember-action');
var [ action ] = ActionManager.registeredActions[actionId];
var event = new Ember.$.Event('click');
action.handler(event);
});

QUnit.test('Events can be handled by inherited event handlers', function() {
expect(4);

Expand Down