Monkey patch mithril so we can use JSX component syntax

<Alert foo="bar"/> instead of Alert.component({foo: 'bar'})
This commit is contained in:
Toby Zerner
2015-08-26 16:22:29 +09:30
parent 0b8aa5c124
commit df385b7df2
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,17 @@
import Component from '../Component';
export default function patchMithril(global) {
const mo = global.m;
const m = function(comp, ...args) {
if (comp.prototype && comp.prototype instanceof Component) {
return comp.component(...args);
}
return mo.apply(this, arguments);
}
Object.keys(mo).forEach(key => m[key] = mo[key]);
global.m = m;
}