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] Deprecate {{link-to}} unwrapping a controllers model. #10556

Merged
merged 1 commit into from
Mar 1, 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
3 changes: 3 additions & 0 deletions packages/ember-routing-htmlbars/lib/helpers/link-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ import 'ember-htmlbars';
*/
function linkToHelper(params, hash, options, env) {
var queryParamsObject;
var view = env.data.view;

Ember.assert("You must provide one or more parameters to the link-to helper.", params.length);

Expand Down Expand Up @@ -321,6 +322,8 @@ function linkToHelper(params, hash, options, env) {

if (!lazyValue._isController) {
while (ControllerMixin.detect(lazyValue.value())) {
Ember.deprecate('Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated. Please update `' + view + '` to use `{{link-to "post" someController.model}}` instead.');

lazyValue = lazyValue.get('model');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ QUnit.test("unwraps controllers", function() {
template: compile(template)
});

runAppend(view);
expectDeprecation(function() {
runAppend(view);
}, /Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated./);

equal(view.$().text(), 'Text');
});
8 changes: 5 additions & 3 deletions packages/ember/tests/helpers/link_to_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,9 @@ QUnit.test("Issue 4201 - Shorthand for route.index shouldn't throw errors about
QUnit.test("The {{link-to}} helper unwraps controllers", function() {

if (Ember.FEATURES.isEnabled('ember-routing-transitioning-classes')) {
expect(4);
} else {
expect(5);
} else {
expect(6);
}

Router.map(function() {
Expand Down Expand Up @@ -659,7 +659,9 @@ QUnit.test("The {{link-to}} helper unwraps controllers", function() {
Ember.TEMPLATES.filter = compile('<p>{{model.filter}}</p>');
Ember.TEMPLATES.index = compile('{{#link-to "filter" this id="link"}}Filter{{/link-to}}');

bootApplication();
expectDeprecation(function() {
bootApplication();
}, /Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated./);

Ember.run(function() { router.handleURL("/"); });

Expand Down