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] Ensure query param only link-to's work in error states. #17971

Merged
merged 2 commits into from
Jun 14, 2019
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
4 changes: 3 additions & 1 deletion packages/@ember/-internals/glimmer/lib/components/link-to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,9 @@ if (EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS) {
_currentRouterState: alias('_routing.currentState'),
_targetRouterState: alias('_routing.targetState'),

_route: computed('route', '_currentRoute', function computeLinkToComponentRoute(this: any) {
_route: computed('route', '_currentRouterState', function computeLinkToComponentRoute(
this: any
) {
let { route } = this;
return route === UNDEFINED ? this._currentRoute : route;
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,77 @@ if (EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS) {
});
}

['@test generates proper href for `LinkTo` with no @route after transitioning to an error route GH#17963'](
assert
) {
this.router.map(function() {
this.route('bad');
});

this.add(
'controller:application',
Controller.extend({
queryParams: ['baz'],
})
);

this.add(
'route:bad',
Route.extend({
model() {
throw new Error('bad!');
},
})
);

this.addTemplate('error', `Error: {{model.message}}`);

this.addTemplate(
'application',
`
<LinkTo id="bad-link" @route="bad">
Bad
</LinkTo>

<LinkTo id="good-link" @query={{hash baz='lol'}}>
Good
</LinkTo>

{{outlet}}
`
);

return this.visit('/')
.then(async () => {
assert.equal(this.$('#good-link').length, 1, 'good-link should be in the DOM');
assert.equal(this.$('#bad-link').length, 1, 'bad-link should be in the DOM');

let goodLink = this.$('#good-link');
assert.equal(goodLink.attr('href'), '/?baz=lol');

return this.visit('/bad');
})
.then(() => {
assert.equal(this.$('#good-link').length, 1, 'good-link should be in the DOM');
assert.equal(this.$('#bad-link').length, 1, 'bad-link should be in the DOM');

let goodLink = this.$('#good-link');
// should still be / because we never entered /bad (it errored before being fully entered)
// and error states do not get represented in the URL, so we are _effectively_ still
// on /
assert.equal(goodLink.attr('href'), '/?baz=lol');

runTask(() => this.click('#good-link'));

let applicationController = this.getController('application');
assert.deepEqual(
applicationController.getProperties('baz'),
{ baz: 'lol' },
'index controller QP properties updated'
);
});
}

['@test supplied QP properties can be bound'](assert) {
this.addTemplate(
'index',
Expand Down