From 92b64e3c8048c5c8c52a2eed683f48e977259340 Mon Sep 17 00:00:00 2001 From: Miguel Camba Date: Fri, 17 Jul 2015 08:43:28 +0100 Subject: [PATCH] [CLEANUP beta] Remove support for actions in `events` key --- .../lib/mixins/action_handler.js | 14 +--- packages/ember/tests/routing/basic_test.js | 80 ------------------- 2 files changed, 2 insertions(+), 92 deletions(-) diff --git a/packages/ember-runtime/lib/mixins/action_handler.js b/packages/ember-runtime/lib/mixins/action_handler.js index a1dde279f22..1a147e6b184 100644 --- a/packages/ember-runtime/lib/mixins/action_handler.js +++ b/packages/ember-runtime/lib/mixins/action_handler.js @@ -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]; } }, diff --git a/packages/ember/tests/routing/basic_test.js b/packages/ember/tests/routing/basic_test.js index 8aad1d8f4ee..9ee062a893a 100644 --- a/packages/ember/tests/routing/basic_test.js +++ b/packages/ember/tests/routing/basic_test.js @@ -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); @@ -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( - '{{name}}' - ); - - 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( - '{{name}}' - ); - - 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);