Skip to content

Commit

Permalink
Merge pull request #60 from mreinstein/master
Browse files Browse the repository at this point in the history
make class inclusion check truthy to match snabbdom. fixes #59
  • Loading branch information
acstll authored Jun 30, 2021
2 parents 2c2ee16 + 0b992ea commit 4ab896c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = function classModule (vnode, attributes) {
existing = existing.length > 0 ? existing.split(' ') : []

forOwn(classes, function (value, key) {
if (value === true) {
if (value) {
_add.push(key)
} else {
_remove.push(key)
Expand Down
10 changes: 10 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,16 @@ test('Modules', function (t) {
}, 'Github')
t.equal(renderToString(vnode), '<a id="github" class="a b" href="http://github.com" target="_blank">Github</a>', 'attrs 2')

vnode = h('img', {
attrs: {
src: 'https://test.com'
},
class: {
selected: 'true'
}
})
t.equal(renderToString(vnode), '<img class="selected" src="https://test.com">', 'class truthy check')

vnode = h('a#github', {
attrs: {
id: 'overridden',
Expand Down

0 comments on commit 4ab896c

Please sign in to comment.