Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix link to bindings #11960

Merged
merged 2 commits into from
Aug 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/ember-routing-htmlbars/lib/keywords/link-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@submodule ember-routing-htmlbars
*/

import { readArray, readHash } from 'ember-metal/streams/utils';
import { readArray } from 'ember-metal/streams/utils';
import Ember from 'ember-metal/core'; // assert
import merge from 'ember-metal/merge';

Expand Down Expand Up @@ -286,7 +286,9 @@ export default {
},

render(morph, env, scope, params, hash, template, inverse, visitor) {
var attrs = merge({}, readHash(hash));
var attrs = merge({}, hash);

// TODO: Rewrite link-to to use arbitrary length positional params.
attrs.params = readArray(params);

// Used for deprecations (to tell the user what view the deprecated syntax
Expand Down
27 changes: 27 additions & 0 deletions packages/ember/tests/helpers/link_to_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,33 @@ QUnit.test('The {{link-to}} helper supports a custom activeClass', function() {
equal(Ember.$('#about-link:not(.active)', '#qunit-fixture').length, 1, 'The other link was rendered without active class');
});

QUnit.test('The {{link-to}} helper supports \'classNameBindings\' with custom values [GH #11699]', function() {
Ember.TEMPLATES.index = compile('<h3>Home</h3>{{#link-to \'about\' id=\'about-link\' classNameBindings=\'foo:foo-is-true:foo-is-false\'}}About{{/link-to}}');

Router.map(function() {
this.route('about');
});

App.IndexController = Ember.Controller.extend({
foo: false
});

bootApplication();

Ember.run(function() {
router.handleURL('/');
});

equal(Ember.$('#about-link.foo-is-false', '#qunit-fixture').length, 1, 'The about-link was rendered with the falsy class');

var controller = container.lookup('controller:index');
Ember.run(function() {
controller.set('foo', true);
});

equal(Ember.$('#about-link.foo-is-true', '#qunit-fixture').length, 1, 'The about-link was rendered with the truthy class after toggling the property');
});

QUnit.test('The {{link-to}} helper supports leaving off .index for nested routes', function() {
Router.map(function() {
this.route('about', function() {
Expand Down