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 beta] Allow boolean values for current-when #14848

Merged
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: 5 additions & 1 deletion packages/ember-glimmer/lib/components/link-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,12 @@ const LinkComponent = EmberComponent.extend({
let routing = get(this, '_routing');
let models = get(this, 'models');
let resolvedQueryParams = get(this, 'resolvedQueryParams');

let currentWhen = get(this, 'current-when');

if (typeof currentWhen === 'boolean') {
return currentWhen ? get(this, 'activeClass') : false;
}

let isCurrentWhenSpecified = !!currentWhen;
currentWhen = currentWhen || get(this, 'qualifiedRouteName');
currentWhen = currentWhen.split(' ');
Expand Down
16 changes: 16 additions & 0 deletions packages/ember/tests/helpers/link_to_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,22 @@ moduleFor('The {{link-to}} helper - nested routes and link-to arguments', class
assert.equal(this.$('#link3.active').length, 0, 'The link is not active since current-when does not contain the active route');
}

['@test The {{link-to}} helper supports boolean values for current-when'](assert) {
this.router.map(function(match) {
this.route('index', { path: '/' }, function() {
this.route('about');
});
this.route('item');
});

this.addTemplate('index', `<h3>Home</h3>{{outlet}}`);
this.addTemplate('index.about', `{{#link-to 'item' id='other-link' current-when=true}}ITEM{{/link-to}}`);

this.visit('/about');

assert.equal(this.$('#other-link').length, 1, 'The link is active since current-when is true');
}

['@test The {{link-to}} helper defaults to bubbling'](assert) {
this.addTemplate('about', `
<div {{action 'hide'}}>
Expand Down