Skip to content

Commit

Permalink
Merge pull request #13228 from sly7-7/fix-linkTo-disabledWhen
Browse files Browse the repository at this point in the history
[BUGFIX release] re-enable link-to when disabledWhen becomes false
  • Loading branch information
rwjblue committed Apr 1, 2016
2 parents 57cf48c + 2d0db1a commit bc78f0c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/ember-routing-views/lib/components/link-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ let LinkComponent = EmberComponent.extend({
assert('You must provide one or more parameters to the link-to component.', params.length);

let disabledWhen = get(this, 'disabledWhen');
if (disabledWhen) {
if (disabledWhen !== undefined) {
this.set('disabled', disabledWhen);
}

Expand Down
17 changes: 16 additions & 1 deletion packages/ember/tests/helpers/link_to_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ QUnit.test('the {{link-to}} applies a \'disabled\' class when disabled', functio

equal(jQuery('#about-link-static.disabled', '#qunit-fixture').length, 1, 'The static link is disabled when its disabledWhen is true');
equal(jQuery('#about-link-dynamic.disabled', '#qunit-fixture').length, 1, 'The dynamic link is disabled when its disabledWhen is true');

run(function() {
set(appInstance.lookup('controller:index'), 'dynamicDisabledWhen', false);
});

equal(jQuery('#about-link-dynamic.disabled', '#qunit-fixture').length, 0, 'The dynamic link is re-enabled when its disabledWhen becomes false');
});

QUnit.test('the {{link-to}} doesn\'t apply a \'disabled\' class if disabledWhen is not provided', function () {
Expand Down Expand Up @@ -362,7 +368,7 @@ QUnit.test('the {{link-to}} helper does not respond to clicks when disabled', fu
equal(jQuery('h3:contains(About)', '#qunit-fixture').length, 0, 'Transitioning did not occur');
});

QUnit.test('the {{link-to}} helper does not respond to clicks when disabled via a bound param', function () {
QUnit.test('the {{link-to}} helper responds to clicks according to its disabledWhen bound param', function () {
Ember.TEMPLATES.index = compile('{{#link-to "about" id="about-link" disabledWhen=disabledWhen}}About{{/link-to}}');

Router.map(function() {
Expand All @@ -384,6 +390,15 @@ QUnit.test('the {{link-to}} helper does not respond to clicks when disabled via
});

equal(jQuery('h3:contains(About)', '#qunit-fixture').length, 0, 'Transitioning did not occur');

run(function() {
set(appInstance.lookup('controller:index'), 'disabledWhen', false);
});
run(function() {
jQuery('#about-link', '#qunit-fixture').click();
});

equal(jQuery('h3:contains(About)', '#qunit-fixture').length, 1, 'Transitioning did occur when disabledWhen became false');
});

QUnit.test('The {{link-to}} helper supports a custom activeClass', function() {
Expand Down

0 comments on commit bc78f0c

Please sign in to comment.