Merge pull request #1753 from StephanHoyer/master

Fix rendering `0` as only child without attrs - fixes #1752
This commit is contained in:
Isiah Meadows 2017-03-28 06:41:16 -04:00 committed by GitHub
commit 000eec90d8
2 changed files with 6 additions and 1 deletions

View file

@ -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 = {}

View file

@ -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() {