Merge pull request #1103 from brlewis/next
Render booleans as empty strings
This commit is contained in:
commit
8faab54c4c
3 changed files with 37 additions and 1 deletions
|
|
@ -188,7 +188,7 @@
|
|||
// value of Console.log in some versions of Firefox (behavior depends on
|
||||
// version)
|
||||
try {
|
||||
if (data != null && data.toString() != null) return data
|
||||
if (typeof data !== "boolean" && data != null && data.toString() != null) return data
|
||||
} catch (e) {
|
||||
// silently ignore errors
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,24 @@ describe("m.render()", function () {
|
|||
expect(root.childNodes[0].childNodes[0].nodeValue).to.equal("")
|
||||
})
|
||||
|
||||
it("renders `null` body to empty string", function () {
|
||||
var root = mock.document.createElement("div")
|
||||
m.render(root, m("div", [null]))
|
||||
expect(root.childNodes[0].childNodes[0].nodeValue).to.equal("")
|
||||
})
|
||||
|
||||
it("renders `true` body to empty string", function () {
|
||||
var root = mock.document.createElement("div")
|
||||
m.render(root, m("div", [true]))
|
||||
expect(root.childNodes[0].childNodes[0].nodeValue).to.equal("")
|
||||
})
|
||||
|
||||
it("renders `false` body to empty string", function () {
|
||||
var root = mock.document.createElement("div")
|
||||
m.render(root, m("div", [false]))
|
||||
expect(root.childNodes[0].childNodes[0].nodeValue).to.equal("")
|
||||
})
|
||||
|
||||
it("uses the W3C URI as default namespace for SVG children", function () {
|
||||
var root = mock.document.createElement("div")
|
||||
m.render(root, m("svg", [m("g")]))
|
||||
|
|
|
|||
|
|
@ -1750,6 +1750,24 @@
|
|||
return root.childNodes[0].childNodes[0].nodeValue === ""
|
||||
})
|
||||
|
||||
test(function () {
|
||||
var root = mock.document.createElement("div")
|
||||
m.render(root, m("div", [null]))
|
||||
return root.childNodes[0].childNodes[0].nodeValue === ""
|
||||
})
|
||||
|
||||
test(function () {
|
||||
var root = mock.document.createElement("div")
|
||||
m.render(root, m("div", [true]))
|
||||
return root.childNodes[0].childNodes[0].nodeValue === ""
|
||||
})
|
||||
|
||||
test(function () {
|
||||
var root = mock.document.createElement("div")
|
||||
m.render(root, m("div", [false]))
|
||||
return root.childNodes[0].childNodes[0].nodeValue === ""
|
||||
})
|
||||
|
||||
test(function () {
|
||||
var root = mock.document.createElement("div")
|
||||
m.render(root, m("svg", [m("g")]))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue