Skip to content

Commit

Permalink
fix components getting className set incorrectly, it should be in pro…
Browse files Browse the repository at this point in the history
…ps always
  • Loading branch information
Havunen committed Mar 24, 2017
1 parent 7400a3b commit c203e28
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function getVNodeProps(t, astProps, isComponent) {
propName = propName.namespace.name + ':' + propName.name.name;
}

if (propName === 'className' || propName === 'class') {
if (!isComponent && (propName === 'className' || propName === 'class')) {
className = getValue(t, astProp.value);
} else if (propName.substr(0, 11) === 'onComponent' && isComponent) {
if (!ref) {
Expand Down
6 changes: 5 additions & 1 deletion tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ describe('Array', function() {
expect(transform('<div>1</div>')).to.equal('createVNode(2, "div", null, "1");');
});

it('className should be in third parameter as string', function () {
it('className should be in third parameter as string when its element', function () {
expect(transform('<div className="first second">1</div>')).to.equal('createVNode(2, "div", "first second", "1");');
});

it('className should be in fifth parameter as string when its component', function () {
expect(transform('<UnkownClass className="first second">1</UnkownClass>')).to.equal('createVNode(16, UnkownClass, null, null, {\n "className": "first second",\n children: "1"\n});');
});

it('class should be in third parameter as variable', function () {
expect(transform('<div class={variable}>1</div>')).to.equal('createVNode(2, "div", variable, "1");');
});
Expand Down

0 comments on commit c203e28

Please sign in to comment.