Skip to content

Commit

Permalink
support classname
Browse files Browse the repository at this point in the history
  • Loading branch information
nathancahill committed Apr 29, 2017
1 parent 4b4fd10 commit f4da1f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/vhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function h(name, attrs) {
let s = `<${name}`;
if (attrs) for (let i in attrs) {
if (attrs[i]!==false && attrs[i]!=null) {
s += ` ${esc(i)}="${esc(attrs[i])}"`;
s += ` ${i === 'className' ? 'class' : esc(i)}="${esc(attrs[i])}"`;
}
}

Expand Down
8 changes: 8 additions & 0 deletions test/vhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,12 @@ describe('vhtml', () => {
`<div><area><base><br><col><command><embed><hr><img><input><keygen><link><meta><param><source><track><wbr><div></div><span></span><p></p></div>`
);
});

it('should handle className as class', () => {
expect(
<div className="my-class" />
).to.equal(
'<div class="my-class"></div>'
);
});
});

0 comments on commit f4da1f0

Please sign in to comment.