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

[BUGFIX release] Fix blockless link-to with only query params #11655

Merged
merged 1 commit into from
Jul 6, 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
2 changes: 1 addition & 1 deletion packages/ember-routing-views/lib/views/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ var LinkComponent = EmberComponent.extend({
if (lastParam && lastParam.isQueryParams) {
params.pop();
}
let onlyQueryParamsSupplied = (params.length === 0);
let onlyQueryParamsSupplied = (this.attrs.hasBlock ? params.length === 0 : params.length === 1);
if (onlyQueryParamsSupplied) {
var appController = this.container.lookup('controller:application');
if (appController) {
Expand Down
36 changes: 35 additions & 1 deletion packages/ember/tests/helpers/link_to_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ QUnit.test('{{link-to}} populates href with fully supplied query param values',
equal(Ember.$('#the-link').attr('href'), '/?bar=NAW&foo=456', 'link has right href');
});

QUnit.test('{{link-to}} with only query-params updates when route changes', function() {
QUnit.test('{{link-to}} with only query-params and a block updates when route changes', function() {
Router.map(function() {
this.route('about');
});
Expand Down Expand Up @@ -1405,3 +1405,37 @@ QUnit.test('{{link-to}} with only query-params updates when route changes', func
});
equal(Ember.$('#the-link').attr('href'), '/about?bar=NAW&foo=456', 'link has right href');
});

QUnit.test('Block-less {{link-to}} with only query-params updates when route changes', function() {
Router.map(function() {
this.route('about');
});

if (isEnabled('ember-routing-route-configured-query-params')) {
App.ApplicationRoute = Ember.Route.extend({
queryParams: {
foo: {
defaultValue: '123'
},
bar: {
defaultValue: 'yes'
}
}
});
} else {
App.ApplicationController = Ember.Controller.extend({
queryParams: ['foo', 'bar'],
foo: '123',
bar: 'yes'
});
}

Ember.TEMPLATES.application = compile('{{link-to "Index" (query-params foo=\'456\' bar=\'NAW\') id=\'the-link\'}}');
bootApplication();
equal(Ember.$('#the-link').attr('href'), '/?bar=NAW&foo=456', 'link has right href');

Ember.run(function() {
router.handleURL('/about');
});
equal(Ember.$('#the-link').attr('href'), '/about?bar=NAW&foo=456', 'link has right href');
});