emberjs/ember.js — Issue #490: Use set('classNames') in Ember.view?
Author: jviereck
Created: 2012-02-12 08:11:01+00:00
State: open

I've created a new button class

var BS = {};

BS.Icon = Ember.View.extend({
tagName: 'i',
classNames: Ember.computed(function(key, value) {
return ['icon-' + this.name];
}).property('name').cacheable(),
})

Ember.Handlebars.registerHelper('BS_Icon', function(options) {
return Ember.Handlebars.helpers.view.call(this, BS.Icon, options);
});

Note that the `classNames` is computed.

This doesn't work with version 0.9.4 as in the Ember.View definition, `init:`

this.classNames = Ember.A(get(this, 'classNames').slice());

causes an assertion in `Ember.Descriptor.MUST_USE_SETTER`:

Uncaught Error: assertion failed: Must use Ember.set() to access this property

I was able to fix this by changing the line in the `init:` to:

this.set('classNames', Ember.A(get(this, 'classNames').slice()));

Does that makes sense to change using a `set` method here, or am I doing something completly wrong in the way I compute the `classNames` property?