Skip to content

Commit

Permalink
Merge pull request #1753 from StephanHoyer/master
Browse files Browse the repository at this point in the history
Fix rendering `0` as only child without attrs - fixes #1752
  • Loading branch information
Isiah Meadows committed Mar 28, 2017
2 parents e88bddb + 7960781 commit 000eec9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion render/hyperscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function hyperscript(selector) {
var cached = selectorCache[selector] || compileSelector(selector)
}

if (!attrs) {
if (attrs == null) {
attrs = {}
} else if (typeof attrs !== "object" || attrs.tag != null || Array.isArray(attrs)) {
attrs = {}
Expand Down
5 changes: 5 additions & 0 deletions render/tests/test-hyperscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ o.spec("hyperscript", function() {
o(vnode.children[0]).equals(null)
o(vnode.children[1]).equals(undefined)
})
o("handles falsy number single child without attrs", function() {
var vnode = m("div", 0)

o(vnode.text).equals(0)
})
})
o.spec("permutations", function() {
o("handles null attr and children", function() {
Expand Down

0 comments on commit 000eec9

Please sign in to comment.