Skip to content

Commit

Permalink
Merge pull request #11791 from cibernox/remove_support_for_actions_in…
Browse files Browse the repository at this point in the history
…side_events_object

[CLEANUP beta] Remove support for actions in `events` key
  • Loading branch information
rwjblue committed Jul 17, 2015
2 parents 8701af4 + 92b64e3 commit 513494f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 92 deletions.
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

0 comments on commit 513494f

Please sign in to comment.