#382 don't render single empty space if not needed

This commit is contained in:
Leo Horie 2015-01-19 22:20:43 -05:00
parent 4deeeb486b
commit fed82b2135
2 changed files with 8 additions and 1 deletions

View file

@ -60,7 +60,9 @@ var m = (function app(window, undefined) {
}
for (var attrName in attrs) {
if (attrName === classAttrName) cell.attrs[attrName] = (cell.attrs[attrName] || "") + " " + attrs[attrName];
if (attrName === classAttrName) {
if (attrs[attrName] !== "") cell.attrs[attrName] = (cell.attrs[attrName] || "") + " " + attrs[attrName];
}
else cell.attrs[attrName] = attrs[attrName]
}
return cell

View file

@ -28,6 +28,11 @@ function testMithril(mock) {
test(function() {return m("svg", [m("a[href='http://google.com']")])})
test(function() {return m(".foo", {"class": "bar"}).attrs["class"] == "foo bar"})
test(function() {return m(".foo", {className: "bar"}).attrs.className == "foo bar"})
test(function() {return m(".foo", {className: ""}).attrs.className == "foo"})
test(function() {return m("div", {className: ""}).attrs.className === undefined}) //https://github.com/lhorie/mithril.js/issues/382
test(function() {return m("div", {class: ""}).attrs.className === undefined})
test(function() {return m("div", {className: ""}).attrs.class === undefined})
test(function() {return m("div", {class: ""}).attrs.class === undefined})
//m.module
test(function() {