mirror of
https://github.com/flarum/core.git
synced 2025-08-11 10:55:47 +02:00
update: common/components/LinkButton
This commit is contained in:
committed by
Franz Liedke
parent
883e1a9d6a
commit
439e3a5a9a
@@ -13,15 +13,17 @@ import Button from './Button';
|
|||||||
* the `active` prop will automatically be set to true.
|
* the `active` prop will automatically be set to true.
|
||||||
*/
|
*/
|
||||||
export default class LinkButton extends Button {
|
export default class LinkButton extends Button {
|
||||||
static initProps(props) {
|
initAttrs(attrs) {
|
||||||
props.active = this.isActive(props);
|
super.initAttrs(attrs);
|
||||||
props.config = props.config || m.route;
|
|
||||||
|
attrs.active = this.constructor.isActive(attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
view() {
|
view(vnode) {
|
||||||
const vdom = super.view();
|
const vdom = super.view(vnode);
|
||||||
|
|
||||||
vdom.tag = 'a';
|
vdom.tag = m.route.Link;
|
||||||
|
vdom.attrs.active = String(vdom.attrs.active);
|
||||||
|
|
||||||
return vdom;
|
return vdom;
|
||||||
}
|
}
|
||||||
@@ -32,7 +34,7 @@ export default class LinkButton extends Button {
|
|||||||
* @param {Object} props
|
* @param {Object} props
|
||||||
* @return {Boolean}
|
* @return {Boolean}
|
||||||
*/
|
*/
|
||||||
static isActive(props) {
|
static isActive(attrs) {
|
||||||
return typeof props.active !== 'undefined' ? props.active : m.route() === props.href;
|
return typeof attrs.active !== 'undefined' ? attrs.active : m.route.get() === attrs.href;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user