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] Partially revert #12229 and add a test for #13432 #13438

Merged
merged 1 commit into from
May 2, 2016
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
12 changes: 12 additions & 0 deletions packages/ember-routing-htmlbars/tests/helpers/link-to_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,16 @@ QUnit.test('able to safely extend the built-in component and use the normal path
equal(view.$().text(), 'my custom link-to component', 'rendered a custom-link-to component');
});

QUnit.test('[GH#13432] able to safely extend the built-in component and invoke it inline', function() {
view = EmberView.create({
[OWNER]: owner,
title: 'my custom link-to component',
template: compile('{{custom-link-to view.title \'index\'}}')
});

runAppend(view);

equal(view.$().text(), 'my custom link-to component', 'rendered a custom-link-to component');
});

}
8 changes: 6 additions & 2 deletions packages/ember-routing-views/lib/components/link-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ import EmberComponent from 'ember-views/components/component';
import inject from 'ember-runtime/inject';
import 'ember-runtime/system/service'; // creates inject.service
import ControllerMixin from 'ember-runtime/mixins/controller';
import { HAS_BLOCK } from 'ember-htmlbars/node-managers/component-node-manager';
import htmlbarsTemplate from 'ember-htmlbars/templates/link-to';
import require from 'require';

Expand Down Expand Up @@ -666,7 +667,7 @@ let LinkComponent = EmberComponent.extend({
if (lastParam && lastParam.isQueryParams) {
params.pop();
}
let onlyQueryParamsSupplied = (params.length === 0);
let onlyQueryParamsSupplied = (this[HAS_BLOCK] ? params.length === 0 : params.length === 1);
if (onlyQueryParamsSupplied) {
return get(this, '_routing.currentRouteName');
}
Expand Down Expand Up @@ -777,7 +778,10 @@ let LinkComponent = EmberComponent.extend({
}

// Process the positional arguments, in order.
// 1. Inline link title was shifted off by AST.
// 1. Inline link title comes first, if present.
if (!this[HAS_BLOCK]) {
this.set('linkTitle', params.shift());
}

// 2. `targetRouteName` is now always at index 0.
this.set('targetRouteName', params[0]);
Expand Down