boring-router-react
Advanced tools
Comparing version 0.3.0-alpha.40 to 0.3.0-alpha.43
@@ -13,8 +13,5 @@ import { RouteMatch, RouteMatchSharedToParamDict } from 'boring-router'; | ||
export declare class Link<TRouteMatch extends RouteMatch> extends Component<LinkProps<TRouteMatch>> { | ||
private href; | ||
private readonly href; | ||
render(): ReactNode; | ||
private onMouseEnter; | ||
private onFocus; | ||
private onClick; | ||
private updateHref; | ||
} |
@@ -11,9 +11,2 @@ "use strict"; | ||
super(...arguments); | ||
this.href = 'javascript:;'; | ||
this.onMouseEnter = () => { | ||
this.updateHref(); | ||
}; | ||
this.onFocus = () => { | ||
this.updateHref(); | ||
}; | ||
this.onClick = (event) => { | ||
@@ -38,22 +31,19 @@ if (event.ctrlKey || | ||
} | ||
render() { | ||
let _a = this.props, { className, to, params, replace, toggle, onMouseEnter, onFocus, onClick } = _a, props = tslib_1.__rest(_a, ["className", "to", "params", "replace", "toggle", "onMouseEnter", "onFocus", "onClick"]); | ||
return (react_1.default.createElement("a", Object.assign({ className: className, href: this.href, onMouseEnter: _utils_1.composeEventHandler([onMouseEnter, this.onMouseEnter]), onFocus: _utils_1.composeEventHandler([onFocus, this.onFocus]), onClick: _utils_1.composeEventHandler([onClick, this.onClick], true) }, props))); | ||
} | ||
updateHref() { | ||
get href() { | ||
let { to, params } = this.props; | ||
try { | ||
this.href = to.$router.$(to, params).$href(); | ||
return to.$router.$(to, params).$href(); | ||
} | ||
catch (error) { | ||
this.href = 'javascript:;'; | ||
return '#'; | ||
} | ||
} | ||
render() { | ||
let _a = this.props, { className, to, params, replace, toggle, onClick } = _a, props = tslib_1.__rest(_a, ["className", "to", "params", "replace", "toggle", "onClick"]); | ||
return (react_1.default.createElement("a", Object.assign({ className: className, href: this.href, onClick: _utils_1.composeEventHandler([onClick, this.onClick], true) }, props))); | ||
} | ||
}; | ||
tslib_1.__decorate([ | ||
mobx_1.observable | ||
], Link.prototype, "href", void 0); | ||
tslib_1.__decorate([ | ||
mobx_1.action | ||
], Link.prototype, "updateHref", null); | ||
mobx_1.computed | ||
], Link.prototype, "href", null); | ||
Link = tslib_1.__decorate([ | ||
@@ -60,0 +50,0 @@ mobx_react_1.observer |
{ | ||
"name": "boring-router-react", | ||
"version": "0.3.0-alpha.40", | ||
"version": "0.3.0-alpha.43", | ||
"description": "A light-weight, type-safe, yet reactive router service using MobX.", | ||
@@ -41,3 +41,3 @@ "repository": { | ||
}, | ||
"gitHead": "5354f854cb8251db35639c1aea5dca6284bcf61d" | ||
"gitHead": "ec1c0ef3bf5fb384d5c4781e5873a34c7ce780fd" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47208
929