Cast className using toString (#2309)
* Cast className using toString * Add to change-log
This commit is contained in:
parent
b5219920ab
commit
421474c0e2
3 changed files with 11 additions and 1 deletions
|
|
@ -30,6 +30,7 @@
|
|||
- 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: 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
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ function execSelector(state, attrs, children) {
|
|||
if (className != null || state.attrs.className != null) attrs.className =
|
||||
className != null
|
||||
? state.attrs.className != null
|
||||
? state.attrs.className + " " + className
|
||||
? String(state.attrs.className) + " " + String(className)
|
||||
: className
|
||||
: state.attrs.className != null
|
||||
? state.attrs.className
|
||||
|
|
|
|||
|
|
@ -358,6 +358,15 @@ o.spec("hyperscript", function() {
|
|||
|
||||
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("handles string single child", function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue