mirror of
https://github.com/flarum/framework.git
synced 2024-11-28 20:16:08 +08:00
Add in BC layer for props, initProps, m.withAttr, and m.prop (#2310)
This commit is contained in:
parent
aea8a3ff1f
commit
54ff6e720c
|
@ -132,5 +132,35 @@ export default abstract class Component<T extends ComponentAttrs = any> implemen
|
|||
*
|
||||
* This can be used to assign default values for missing, optional attrs.
|
||||
*/
|
||||
protected static initAttrs<T>(attrs: T): void {}
|
||||
protected static initAttrs<T>(attrs: T): void {
|
||||
// Deprecated, part of Mithril 2 BC layer
|
||||
this.initProps(attrs);
|
||||
}
|
||||
|
||||
// BEGIN DEPRECATED MITHRIL 2 BC LAYER
|
||||
|
||||
/**
|
||||
* Initialize the component's attrs.
|
||||
*
|
||||
* This can be used to assign default values for missing, optional attrs.
|
||||
*
|
||||
* @deprecated, use initAttrs instead.
|
||||
*/
|
||||
protected static initProps<T>(attrs: T): void {}
|
||||
|
||||
/**
|
||||
* The attributes passed into the component.
|
||||
*
|
||||
* @see https://mithril.js.org/components.html#passing-data-to-components
|
||||
*
|
||||
* @deprecated, use attrs instead.
|
||||
*/
|
||||
get props() {
|
||||
return this.attrs;
|
||||
}
|
||||
set props(props) {
|
||||
this.attrs = props;
|
||||
}
|
||||
|
||||
// END DEPRECATED MITHRIL 2 BC LAYER
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Stream from 'mithril/stream';
|
||||
import extract from './extract';
|
||||
import withAttr from './withAttr';
|
||||
|
||||
export default function patchMithril(global) {
|
||||
const defaultMithril = global.m;
|
||||
|
@ -68,5 +69,11 @@ export default function patchMithril(global) {
|
|||
|
||||
modifiedMithril.route.Link = modifiedLink;
|
||||
|
||||
// BEGIN DEPRECATED MITHRIL 2 BC LAYER
|
||||
modifiedMithril.prop = Stream;
|
||||
|
||||
modifiedMithril.withAttr = withAttr;
|
||||
// END DEPRECATED MITHRIL 2 BC LAYER
|
||||
|
||||
global.m = modifiedMithril;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user