Cast className using toString (#2309)

* Cast className using toString

* Add to change-log
This commit is contained in:
Rasmus Porsager 2018-11-24 14:13:56 +01:00 committed by Isiah Meadows
parent b5219920ab
commit 421474c0e2
3 changed files with 11 additions and 1 deletions

View file

@ -30,6 +30,7 @@
- render: remove some redundancy within the component initialization code ([#2213](https://github.com/MithrilJS/mithril.js/pull/2213)) - render: remove some redundancy within the component initialization code ([#2213](https://github.com/MithrilJS/mithril.js/pull/2213))
- render: Align custom elements to work like normal elements, minus all the HTML-specific magic. ([#2221](https://github.com/MithrilJS/mithril.js/pull/2221)) - render: Align custom elements to work like normal elements, minus all the HTML-specific magic. ([#2221](https://github.com/MithrilJS/mithril.js/pull/2221))
- render: simplify component removal ([#2214](https://github.com/MithrilJS/mithril.js/pull/2214)) - render: simplify component removal ([#2214](https://github.com/MithrilJS/mithril.js/pull/2214))
- cast className using toString ([#2309](https://github.com/MithrilJS/mithril.js/pull/2309))
#### News #### News

View file

@ -54,7 +54,7 @@ function execSelector(state, attrs, children) {
if (className != null || state.attrs.className != null) attrs.className = if (className != null || state.attrs.className != null) attrs.className =
className != null className != null
? state.attrs.className != null ? state.attrs.className != null
? state.attrs.className + " " + className ? String(state.attrs.className) + " " + String(className)
: className : className
: state.attrs.className != null : state.attrs.className != null
? state.attrs.className ? state.attrs.className

View file

@ -358,6 +358,15 @@ o.spec("hyperscript", function() {
o(vnode.attrs.className).equals("a") o(vnode.attrs.className).equals("a")
}) })
o("casts className using toString like browsers", function() {
const className = {
valueOf: () => ".valueOf",
toString: () => "toString"
}
var vnode = m("custom-element" + className, {className: className})
o(vnode.attrs.className).equals("valueOf toString")
})
}) })
o.spec("children", function() { o.spec("children", function() {
o("handles string single child", function() { o("handles string single child", function() {