From 295b764f52c5286dba75d7b3ff6dda3bc559a38f Mon Sep 17 00:00:00 2001 From: Isiah Meadows Date: Tue, 28 Mar 2017 06:41:16 -0400 Subject: [PATCH] Merge pull request #1753 from StephanHoyer/master Fix rendering `0` as only child without attrs - fixes #1752 --- render/hyperscript.js | 2 +- render/tests/test-hyperscript.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/render/hyperscript.js b/render/hyperscript.js index 24151431..ece288fc 100644 --- a/render/hyperscript.js +++ b/render/hyperscript.js @@ -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 = {} diff --git a/render/tests/test-hyperscript.js b/render/tests/test-hyperscript.js index 2264fe18..cf0b3155 100644 --- a/render/tests/test-hyperscript.js +++ b/render/tests/test-hyperscript.js @@ -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() {