From 1f71415d0dcc670877efaca15e607011cb88a106 Mon Sep 17 00:00:00 2001 From: bekzod Date: Thu, 30 Nov 2017 14:04:27 +0500 Subject: [PATCH] removed `providing reversed arguments to observer` --- packages/ember-metal/lib/mixin.js | 29 ++++--------------- .../ember-metal/tests/mixin/observer_test.js | 11 ------- packages/ember-metal/tests/observer_test.js | 2 -- 3 files changed, 5 insertions(+), 37 deletions(-) diff --git a/packages/ember-metal/lib/mixin.js b/packages/ember-metal/lib/mixin.js index 735f33b84d4..97115207962 100644 --- a/packages/ember-metal/lib/mixin.js +++ b/packages/ember-metal/lib/mixin.js @@ -758,17 +758,8 @@ export function aliasMethod(methodName) { @static */ export function observer(...args) { - let _paths, func; - if (typeof args[args.length - 1] !== 'function') { - // revert to old, soft-deprecated argument ordering - deprecate('Passing the dependentKeys after the callback function in observer is deprecated. Ensure the callback function is the last argument.', false, { id: 'ember-metal.observer-argument-order', until: '3.0.0' }); - - func = args.shift(); - _paths = args; - } else { - func = args.pop(); - _paths = args; - } + let func = args.pop(); + let _paths = args; assert('observer called without a function', typeof func === 'function'); assert('observer called without valid path', _paths.length > 0 && _paths.every((p)=> typeof p === 'string' && p.length)); @@ -842,22 +833,12 @@ export function _immediateObserver() { @private */ export function _beforeObserver(...args) { - let func = args[args.length - 1]; - let paths; + let func = args.pop(); + let _paths = args; + let paths = []; let addWatchedProperty = path => { paths.push(path); }; - let _paths = args.slice(0, -1); - - if (typeof func !== 'function') { - // revert to old, soft-deprecated argument ordering - - func = args[0]; - _paths = args.slice(1); - } - - paths = []; - for (let i = 0; i < _paths.length; ++i) { expandProperties(_paths[i], addWatchedProperty); } diff --git a/packages/ember-metal/tests/mixin/observer_test.js b/packages/ember-metal/tests/mixin/observer_test.js index c3380269207..ec390a88bd9 100644 --- a/packages/ember-metal/tests/mixin/observer_test.js +++ b/packages/ember-metal/tests/mixin/observer_test.js @@ -209,14 +209,3 @@ testBoth('observing chain with overridden property', function(get, set) { set(obj3, 'baz', 'BEAR'); equal(get(obj, 'count'), 1, 'should invoke observer after change'); }); - -testBoth('providing the arguments in reverse order is deprecated', function(get, set) { - expectDeprecation(/Passing the dependentKeys after the callback function in observer is deprecated. Ensure the callback function is the last argument/); - - Mixin.create({ - count: 0, - foo: observer(function() { - set(this, 'count', get(this, 'count') + 1); - }, 'bar.baz') - }); -}); diff --git a/packages/ember-metal/tests/observer_test.js b/packages/ember-metal/tests/observer_test.js index b3299e35982..2a254bb3053 100644 --- a/packages/ember-metal/tests/observer_test.js +++ b/packages/ember-metal/tests/observer_test.js @@ -36,8 +36,6 @@ testBoth('observer should assert to invalid input', function(get, set) { observer(()=>{}); }, 'observer called without valid path'); - expectDeprecation('Passing the dependentKeys after the callback function in observer is deprecated. Ensure the callback function is the last argument.'); - expectAssertion(()=> { observer(null); }, 'observer called without a function');