Updating to 1.11.1 - View not accessible inside an helper


#1

Hello guys,

We are in the process of updating our ember app from 1.10 to 1.11 and we are running into an issue. We have a simple sort-toggle helper that is not working anymore.

{{#link-to "foo" (sort-toggle "id")}}

Code of the helper:

Ember.HTMLBars._registerHelper('sort-toggle', function(params, hash, options, env) {
	var target = this.get('controller.sortTarget') || hash.target,
		view = env.data.view,
		field = params[0];

	hash = {};
	hash[target] = view.getStream(this.get('controller').createToggleString(field));

	options = {
		hash: hash,
		data: options.data
	};

	return Ember.Handlebars.helpers['query-params'].helperFunction.call(this, [], hash, options, env);
});

It appears that since we updated to ember-cli 0.2.3 (ember 1.11.1), this is now undefined and so we cannot access the view or the controller.

We did not see anything in the changelog related to this, what changed ? and how should we migrate this ?


#2

This is not simple at all.

Streams are Ember internal construct that was introduced in HTMLBars and has since been deprecated and replaced with References in Glimmer 2.

You best course of action is to refactor out of using stream and prefer to pass everything into the helper instead (sortTarget)


#3

Thanks, for now we managed to get away with the refactoring by accessing the view in env.data.view but we will have to refactor that soon. Cf: http://stackoverflow.com/a/42491413/1447468