Skip to content

Commit

Permalink
[BUGFIX beta] Fix active link to nested parent with query params
Browse files Browse the repository at this point in the history
failing test of link-to helper with query-params;
make tests pass by checking for non-empty query params and isActive
  • Loading branch information
tpitale committed Aug 14, 2014
1 parent eeffdf0 commit cabad33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/ember-routing-handlebars/lib/helpers/link_to.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,9 @@ var LinkView = Ember.LinkView = EmberComponent.extend({
if (!isActive) { return false; }

if (Ember.FEATURES.isEnabled("query-params-new")) {
if (!isCurrentWhenSpecified && leafName === loadedParams.targetRouteName) {
var emptyQueryParams = Ember.isEmpty(Ember.keys(loadedParams.queryParams));

if (!isCurrentWhenSpecified && !emptyQueryParams && isActive) {
var visibleQueryParams = {};
merge(visibleQueryParams, loadedParams.queryParams);
router._prepareQueryParams(loadedParams.targetRouteName, loadedParams.models, visibleQueryParams);
Expand Down
3 changes: 3 additions & 0 deletions packages/ember/tests/helpers/link_to_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,7 @@ if (Ember.FEATURES.isEnabled("query-params-new")) {
Ember.TEMPLATES.application = Ember.Handlebars.compile(
"{{#link-to 'parent' id='parent-link'}}Parent{{/link-to}} " +
"{{#link-to 'parent.child' id='parent-child-link'}}Child{{/link-to}} " +
"{{#link-to 'parent' (query-params foo=cat) id='parent-link-qp'}}Parent{{/link-to}} " +
"{{outlet}}"
);

Expand All @@ -1540,8 +1541,10 @@ if (Ember.FEATURES.isEnabled("query-params-new")) {
bootApplication();
shouldNotBeActive('#parent-link');
shouldNotBeActive('#parent-child-link');
shouldNotBeActive('#parent-link-qp');
Ember.run(router, 'handleURL', '/parent/child?foo=dog');
shouldBeActive('#parent-link');
shouldNotBeActive('#parent-link-qp');
});

test("The {{link-to}} helper disregards query-params in activeness computation when currentWhen specified", function() {
Expand Down

0 comments on commit cabad33

Please sign in to comment.