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 release] Fix classNames clobbering issue with AttrProxy. #12073

Merged
merged 1 commit into from
Aug 13, 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
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,28 @@ QUnit.test('non-block with each rendering child components', function() {
equal(jQuery('#qunit-fixture').text(), 'In layout. [Child: Tom.][Child: Dick.][Child: Harry.][Child: James.]');
});

QUnit.test('specifying classNames results in correct class', function(assert) {
expect(1);

registry.register('component:some-clicky-thing', Component.extend({
tagName: 'button',
classNames: ['foo', 'bar'],
click() {
assert.ok(true, 'click was fired!');
}
}));

view = EmberView.extend({
template: compile('{{#some-clicky-thing classNames="baz"}}Click Me{{/some-clicky-thing}}'),
container: container
}).create();

runAppend(view);

let button = view.$('button');
ok(button.is('.foo.bar.baz.ember-view'), 'the element has the correct classes: ' + button.attr('class'));
});

// jscs:disable validateIndentation
if (isEnabled('ember-htmlbars-component-generation')) {
QUnit.module('component - invocation (angle brackets)', {
Expand Down
14 changes: 10 additions & 4 deletions packages/ember-views/lib/compat/attrs-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,19 @@ let AttrsProxyMixin = {

_propagateAttrsToThis() {
let attrs = this.attrs;
let values = {};

for (let prop in attrs) {
if (prop !== 'attrs') {
values[prop] = this.getAttr(prop);
if (prop !== 'attrs' &&
// These list of properties are concatenated and merged properties of
// Ember.View / Ember.Component. Setting them here results in them being
// completely stomped and not handled properly, BAIL OUT!
prop !== 'actions' &&
prop !== 'classNames' &&
prop !== 'classNameBindings' &&
prop !== 'attributeBindings') {
this.set(prop, this.getAttr(prop));
}
}
this.setProperties(values);
},

initializeShape: on('init', function() {
Expand Down