Skip to content

Commit

Permalink
Merge pull request #12784 from Dhaulagiri/br-class-names
Browse files Browse the repository at this point in the history
[BUGFIX release-1-13] Prevent `classNames` from being duplicated.
  • Loading branch information
stefanpenner committed Jan 8, 2016
2 parents e287342 + 0a22ad5 commit 8cc0fca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -999,13 +999,15 @@ QUnit.test('non-block with each rendering child components', function() {
});

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

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

Expand All @@ -1018,6 +1020,12 @@ QUnit.test('specifying classNames results in correct class', function(assert) {

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

let expectedClassNames = ['ember-view', 'foo', 'bar', 'baz'];
assert.deepEqual(clickyThing.get('classNames'), expectedClassNames, 'classNames are properly combined');

let buttonClassNames = button.attr('class');
assert.deepEqual(buttonClassNames.split(' '), expectedClassNames, 'all classes are set 1:1 in DOM');
});

QUnit.test('specifying custom concatenatedProperties avoids clobbering', function(assert) {
Expand Down
4 changes: 0 additions & 4 deletions packages/ember-views/lib/system/build-component-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,6 @@ function normalizeClass(component, attrs) {
normalizeClasses(attrs.classBinding.split(' '), normalizedClass);
}

if (attrs.classNames) {
normalizedClass.push(['value', attrs.classNames]);
}

if (classNames) {
for (i=0, l=classNames.length; i<l; i++) {
normalizedClass.push(classNames[i]);
Expand Down

0 comments on commit 8cc0fca

Please sign in to comment.