1
0
mirror of https://github.com/flarum/core.git synced 2025-08-13 11:54:32 +02:00

update: common/utils/patchMithril (remove unnecessary hacks)

Removed m.prop AND m.withAttr, no alternatives yet (m.prop is mithril/stream import)
This commit is contained in:
Matthew Kilgore
2020-08-04 19:17:26 -04:00
committed by Franz Liedke
parent 4435ff193a
commit 5bf5bd36ee

View File

@@ -4,24 +4,17 @@ export default function patchMithril(global) {
const mo = global.m;
const m = function (comp, ...args) {
if (comp.prototype && comp.prototype instanceof Component) {
let children = args.slice(1);
if (children.length === 1 && Array.isArray(children[0])) {
children = children[0];
}
return comp.component(args[0], children);
}
const node = mo.apply(this, arguments);
if (!node.attrs) node.attrs = {};
if (node.attrs.bidi) {
m.bidi(node, node.attrs.bidi);
}
if (node.attrs.route) {
node.attrs.href = node.attrs.route;
node.attrs.config = m.route;
node.attrs.tag = m.route.Link;
delete node.attrs.route;
}
@@ -31,15 +24,5 @@ export default function patchMithril(global) {
Object.keys(mo).forEach((key) => (m[key] = mo[key]));
/**
* Redraw only if not in the middle of a computation (e.g. a route change).
*
* @return {void}
*/
m.lazyRedraw = function () {
m.startComputation();
m.endComputation();
};
global.m = m;
}