Skip to content

Commit

Permalink
Merge pull request #11822 from cibernox/deprecate_currentWhen
Browse files Browse the repository at this point in the history
[BUGFIX beta] Deprecate currentWhen using deprecatingAlias
  • Loading branch information
mixonic committed Jul 20, 2015
2 parents e12bb2f + b0b18ff commit c4ff3da
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
18 changes: 3 additions & 15 deletions packages/ember-routing-views/lib/views/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import isEnabled from 'ember-metal/features';
import { get } from 'ember-metal/property_get';
import { set } from 'ember-metal/property_set';
import { computed } from 'ember-metal/computed';
import { deprecatingAlias } from 'ember-metal/computed_macros';
import { isSimpleClick } from 'ember-views/system/utils';
import EmberComponent from 'ember-views/views/component';
import inject from 'ember-runtime/inject';
Expand Down Expand Up @@ -47,7 +48,7 @@ var LinkComponent = EmberComponent.extend({
@property currentWhen
@private
*/
currentWhen: null,
currentWhen: deprecatingAlias('current-when'),

/**
Used to determine when this LinkComponent is active.
Expand Down Expand Up @@ -216,8 +217,6 @@ var LinkComponent = EmberComponent.extend({
init() {
this._super(...arguments);

Ember.deprecate('Using currentWhen with {{link-to}} is deprecated in favor of `current-when`.', !this.currentWhen);

// Map desired event name to invoke function
var eventName = get(this, 'eventName');
this.on(eventName, this, this._invoke);
Expand Down Expand Up @@ -421,17 +420,6 @@ var LinkComponent = EmberComponent.extend({
this.set('disabled', attrs.disabledWhen);
}

var currentWhen = attrs['current-when'];

if (attrs.currentWhen) {
Ember.deprecate('Using currentWhen with {{link-to}} is deprecated in favor of `current-when`.', !attrs.currentWhen);
currentWhen = attrs.currentWhen;
}

if (currentWhen) {
this.set('currentWhen', currentWhen);
}

// TODO: Change to built-in hasBlock once it's available
if (!attrs.hasBlock) {
this.set('linkTitle', params.shift());
Expand Down Expand Up @@ -474,7 +462,7 @@ LinkComponent.toString = function() { return 'LinkComponent'; };
function computeActive(view, routerState) {
if (get(view, 'loading')) { return false; }

var currentWhen = get(view, 'currentWhen');
var currentWhen = get(view, 'current-when');
var isCurrentWhenSpecified = !!currentWhen;
currentWhen = currentWhen || get(view, 'targetRouteName');
currentWhen = currentWhen.split(' ');
Expand Down
6 changes: 6 additions & 0 deletions packages/ember-routing-views/tests/main_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ QUnit.test('exports correctly', function() {
ok(Ember.LinkComponent, 'LinkComponent is exported correctly');
ok(Ember.OutletView, 'OutletView is exported correctly');
});

QUnit.test('`LinkComponent#currentWhen` is deprecated in favour of `current-when` (DEPRECATED)', function() {
expectDeprecation(/Usage of `currentWhen` is deprecated, use `current-when` instead/);
var link = Ember.LinkComponent.create();
link.get('currentWhen');
});
2 changes: 1 addition & 1 deletion packages/ember/tests/helpers/link_to_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ QUnit.test('The {{link-to}} helper supports leaving off .index for nested routes
});

QUnit.test('The {{link-to}} helper supports currentWhen (DEPRECATED)', function() {
expectDeprecation('Using currentWhen with {{link-to}} is deprecated in favor of `current-when`.');
expectDeprecation('Usage of `currentWhen` is deprecated, use `current-when` instead.');

Router.map(function(match) {
this.route('index', { path: '/' }, function() {
Expand Down

0 comments on commit c4ff3da

Please sign in to comment.