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] Prevent classNames from being duplicated. #12184

Merged
merged 2 commits into from
Aug 23, 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 @@ -786,13 +786,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 @@ -805,6 +807,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 Expand Up @@ -1310,4 +1318,3 @@ function equalsElement(element, tagName, attributes, content) {

QUnit.push(element.innerHTML === content, element.innerHTML, content, `The element had '${content}' as its content`);
}

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