diff --git a/packages/ember-routing-views/lib/views/link.js b/packages/ember-routing-views/lib/views/link.js index 570f07e65b1..c177c07cba7 100644 --- a/packages/ember-routing-views/lib/views/link.js +++ b/packages/ember-routing-views/lib/views/link.js @@ -6,12 +6,12 @@ import Ember from "ember-metal/core"; // FEATURES, Logger, assert import { get } from "ember-metal/property_get"; -import { set } from "ember-metal/property_set"; import { computed } from "ember-metal/computed"; import { isSimpleClick } from "ember-views/system/utils"; import EmberComponent from "ember-views/views/component"; import inject from "ember-runtime/inject"; import ControllerMixin from "ember-runtime/mixins/controller"; +import getValue from 'ember-htmlbars/hooks/get-value'; import linkToTemplate from "ember-htmlbars/templates/link-to"; linkToTemplate.meta.revision = 'Ember@VERSION_STRING_PLACEHOLDER'; @@ -408,19 +408,11 @@ var LinkComponent = EmberComponent.extend({ queryParams = {}; } - if (attrs.disabledClass) { - this.set('disabledClass', attrs.disabledClass); - } - - if (attrs.activeClass) { - this.set('activeClass', attrs.activeClass); - } - if (attrs.disabledWhen) { - this.set('disabled', attrs.disabledWhen); + this.set('disabled', getValue(attrs.disabledWhen)); } - var currentWhen = attrs['current-when']; + var currentWhen = getValue(attrs['current-when']); if (attrs.currentWhen) { Ember.deprecate('Using currentWhen with {{link-to}} is deprecated in favor of `current-when`.', !attrs.currentWhen); @@ -436,10 +428,6 @@ var LinkComponent = EmberComponent.extend({ this.set('linkTitle', params.shift()); } - if (attrs.loadingClass) { - set(this, 'loadingClass', attrs.loadingClass); - } - for (let i = 0; i < params.length; i++) { var value = params[i]; diff --git a/packages/ember/tests/helpers/link_to_test.js b/packages/ember/tests/helpers/link_to_test.js index 3d85b47430d..0c943299ae1 100644 --- a/packages/ember/tests/helpers/link_to_test.js +++ b/packages/ember/tests/helpers/link_to_test.js @@ -250,6 +250,27 @@ QUnit.test("the {{link-to}} helper supports a custom disabledClass", function () }); +QUnit.test("the {{link-to}} helper supports a custom disabledClass set via bound param", function () { + Ember.TEMPLATES.index = compile('{{#link-to "about" id="about-link" disabledWhen=true disabledClass=disabledClass}}About{{/link-to}}'); + + Router.map(function() { + this.route("about"); + }); + + App.IndexController = Ember.Controller.extend({ + disabledClass: 'do-not-want' + }); + + bootApplication(); + + Ember.run(function() { + router.handleURL("/"); + }); + + equal(Ember.$('#about-link.do-not-want', '#qunit-fixture').length, 1, "The link can apply a custom disabled class"); + +}); + QUnit.test("the {{link-to}} helper does not respond to clicks when disabled", function () { Ember.TEMPLATES.index = compile('{{#link-to "about" id="about-link" disabledWhen=true}}About{{/link-to}}'); @@ -270,6 +291,30 @@ QUnit.test("the {{link-to}} helper does not respond to clicks when disabled", fu equal(Ember.$('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 () { + Ember.TEMPLATES.index = compile('{{#link-to "about" id="about-link" disabledWhen=disabledWhen}}About{{/link-to}}'); + + Router.map(function() { + this.route("about"); + }); + + App.IndexController = Ember.Controller.extend({ + disabledWhen: true + }); + + bootApplication(); + + Ember.run(function() { + router.handleURL("/"); + }); + + Ember.run(function() { + Ember.$('#about-link', '#qunit-fixture').click(); + }); + + equal(Ember.$('h3:contains(About)', '#qunit-fixture').length, 0, "Transitioning did not occur"); +}); + QUnit.test("The {{link-to}} helper supports a custom activeClass", function() { Ember.TEMPLATES.index = compile("