preact-router
Advanced tools
Comparing version 2.4.2 to 2.4.3
@@ -74,4 +74,2 @@ (function (global, factory) { | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -344,7 +342,4 @@ | ||
var Route = function Route(_ref4) { | ||
var component = _ref4.component, | ||
props = _objectWithoutProperties(_ref4, ['component']); | ||
return preact.h(component, props); | ||
var Route = function Route(props) { | ||
return preact.h(props.component, props); | ||
}; | ||
@@ -351,0 +346,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("preact")):"function"==typeof define&&define.amd?define(["preact"],e):t.preactRouter=e(t.preact)}(this,function(t){"use strict";function e(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:O,o=/(?:\?([^#]*))?(#.*)?$/,i=t.match(o),u={},a=void 0;if(i&&i[1])for(var p=i[1].split("&"),c=0;c<p.length;c++){var f=p[c].split("=");u[decodeURIComponent(f[0])]=decodeURIComponent(f.slice(1).join("="))}t=r(t.replace(o,"")),e=r(e||"");for(var l=Math.max(t.length,e.length),s=0;s<l;s++)if(e[s]&&":"===e[s].charAt(0)){var h=e[s].replace(/(^\:|[+*?]+$)/g,""),d=(e[s].match(/[+*?]+$/)||O)[0]||"",g=~d.indexOf("+"),y=~d.indexOf("*"),v=t[s]||"";if(!v&&!y&&(d.indexOf("?")<0||g)){a=!1;break}if(u[h]=decodeURIComponent(v),g||y){u[h]=t.slice(s).map(decodeURIComponent).join("/");break}}else if(e[s]!==t[s]){a=!1;break}return(n.default===!0||a!==!1)&&u}function n(t,e){var n=t.attributes||O,r=e.attributes||O;if(n.default)return 1;if(r.default)return-1;var i=o(n.path)-o(r.path);return i||n.path.length-r.path.length}function r(t){return i(t).split("/")}function o(t){return(i(t).match(/\/+/g)||"").length}function i(t){return t.replace(/(^\/+|\/+$)/g,"")}function u(t,e){var n={};for(var r in t)e.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function p(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function f(t){return null!=t.__preactattr_||"undefined"!=typeof Symbol&&null!=t[Symbol.for("preactattr")]}function l(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"push";U&&U[e]?U[e](t):"undefined"!=typeof history&&history[e+"State"]&&history[e+"State"](null,null,t)}function s(){var t=void 0;return t=U&&U.location?U.location:U&&U.getCurrentLocation?U.getCurrentLocation():"undefined"!=typeof location?location:_,""+(t.pathname||"")+(t.search||"")}function h(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"string"!=typeof t&&t.url&&(e=t.replace,t=t.url),d(t)&&l(t,e?"replace":"push"),g(t)}function d(t){for(var e=w.length;e--;)if(w[e].canRoute(t))return!0;return!1}function g(t){for(var e=!1,n=0;n<w.length;n++)w[n].routeTo(t)===!0&&(e=!0);return e}function y(t){if(t&&t.getAttribute){var e=t.getAttribute("href"),n=t.getAttribute("target");if(e&&e.match(/^\//g)&&(!n||n.match(/^_?self$/i)))return h(e)}}function v(t){if(0===t.button)return y(t.currentTarget||t.target||this),m(t)}function m(t){return t&&(t.stopImmediatePropagation&&t.stopImmediatePropagation(),t.stopPropagation&&t.stopPropagation(),t.preventDefault()),!1}function b(t){if(!(t.ctrlKey||t.metaKey||t.altKey||t.shiftKey||0!==t.button)){var e=t.target;do if("A"===String(e.nodeName).toUpperCase()&&e.getAttribute("href")&&f(e)){if(e.hasAttribute("native"))return;if(y(e))return m(t)}while(e=e.parentNode)}}function C(){j||("function"==typeof addEventListener&&(U||addEventListener("popstate",function(){return g(s())}),addEventListener("click",b)),j=!0)}var O={},R=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},U=null,w=[],_={},j=!1,x=function(e){return t.h("a",R({},e,{onClick:v}))},P=function(t){function r(e){a(this,r);var n=p(this,t.call(this,e));return e.history&&(U=e.history),n.state={url:n.props.url||s()},C(),n}return c(r,t),r.prototype.shouldComponentUpdate=function(t){return t.static!==!0||(t.url!==this.props.url||t.onChange!==this.props.onChange)},r.prototype.canRoute=function(t){return this.getMatchingChildren(this.props.children,t,!1).length>0},r.prototype.routeTo=function(t){return this._didRoute=!1,this.setState({url:t}),this.updating?this.canRoute(t):(this.forceUpdate(),this._didRoute)},r.prototype.componentWillMount=function(){w.push(this),this.updating=!0},r.prototype.componentDidMount=function(){var t=this;U&&(this.unlisten=U.listen(function(e){t.routeTo(""+(e.pathname||"")+(e.search||""))})),this.updating=!1},r.prototype.componentWillUnmount=function(){"function"==typeof this.unlisten&&this.unlisten(),w.splice(w.indexOf(this),1)},r.prototype.componentWillUpdate=function(){this.updating=!0},r.prototype.componentDidUpdate=function(){this.updating=!1},r.prototype.getMatchingChildren=function(t,r,o){return t.slice().sort(n).filter(function(t){var n=t.attributes,i=n.path,u=e(r,i,n);if(u){if(o!==!1){n.url=r,n.matches=u;for(var a in u)u.hasOwnProperty(a)&&(n[a]=u[a])}return!0}})},r.prototype.render=function(t,e){var n=t.children,r=t.onChange,o=e.url,i=this.getMatchingChildren(n,o,!0),u=i[0]||null;this._didRoute=!!u;var a=this.previousUrl;return o!==a&&(this.previousUrl=o,"function"==typeof r&&r({router:this,url:o,previous:a,active:i,current:u})),u},r}(t.Component),A=function(e){var n=e.component,r=u(e,["component"]);return t.h(n,r)};return P.route=h,P.Router=P,P.Route=A,P.Link=x,P}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("preact")):"function"==typeof define&&define.amd?define(["preact"],e):t.preactRouter=e(t.preact)}(this,function(t){"use strict";function e(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:C,o=/(?:\?([^#]*))?(#.*)?$/,i=t.match(o),u={},a=void 0;if(i&&i[1])for(var p=i[1].split("&"),c=0;c<p.length;c++){var f=p[c].split("=");u[decodeURIComponent(f[0])]=decodeURIComponent(f.slice(1).join("="))}t=r(t.replace(o,"")),e=r(e||"");for(var s=Math.max(t.length,e.length),l=0;l<s;l++)if(e[l]&&":"===e[l].charAt(0)){var h=e[l].replace(/(^\:|[+*?]+$)/g,""),d=(e[l].match(/[+*?]+$/)||C)[0]||"",g=~d.indexOf("+"),y=~d.indexOf("*"),v=t[l]||"";if(!v&&!y&&(d.indexOf("?")<0||g)){a=!1;break}if(u[h]=decodeURIComponent(v),g||y){u[h]=t.slice(l).map(decodeURIComponent).join("/");break}}else if(e[l]!==t[l]){a=!1;break}return(n.default===!0||a!==!1)&&u}function n(t,e){var n=t.attributes||C,r=e.attributes||C;if(n.default)return 1;if(r.default)return-1;var i=o(n.path)-o(r.path);return i||n.path.length-r.path.length}function r(t){return i(t).split("/")}function o(t){return(i(t).match(/\/+/g)||"").length}function i(t){return t.replace(/(^\/+|\/+$)/g,"")}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function p(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function c(t){return null!=t.__preactattr_||"undefined"!=typeof Symbol&&null!=t[Symbol.for("preactattr")]}function f(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"push";O&&O[e]?O[e](t):"undefined"!=typeof history&&history[e+"State"]&&history[e+"State"](null,null,t)}function s(){var t=void 0;return t=O&&O.location?O.location:O&&O.getCurrentLocation?O.getCurrentLocation():"undefined"!=typeof location?location:_,""+(t.pathname||"")+(t.search||"")}function l(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"string"!=typeof t&&t.url&&(e=t.replace,t=t.url),h(t)&&f(t,e?"replace":"push"),d(t)}function h(t){for(var e=U.length;e--;)if(U[e].canRoute(t))return!0;return!1}function d(t){for(var e=!1,n=0;n<U.length;n++)U[n].routeTo(t)===!0&&(e=!0);return e}function g(t){if(t&&t.getAttribute){var e=t.getAttribute("href"),n=t.getAttribute("target");if(e&&e.match(/^\//g)&&(!n||n.match(/^_?self$/i)))return l(e)}}function y(t){if(0===t.button)return g(t.currentTarget||t.target||this),v(t)}function v(t){return t&&(t.stopImmediatePropagation&&t.stopImmediatePropagation(),t.stopPropagation&&t.stopPropagation(),t.preventDefault()),!1}function m(t){if(!(t.ctrlKey||t.metaKey||t.altKey||t.shiftKey||0!==t.button)){var e=t.target;do if("A"===String(e.nodeName).toUpperCase()&&e.getAttribute("href")&&c(e)){if(e.hasAttribute("native"))return;if(g(e))return v(t)}while(e=e.parentNode)}}function b(){w||("function"==typeof addEventListener&&(O||addEventListener("popstate",function(){return d(s())}),addEventListener("click",m)),w=!0)}var C={},R=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},O=null,U=[],_={},w=!1,j=function(e){return t.h("a",R({},e,{onClick:y}))},x=function(t){function r(e){u(this,r);var n=a(this,t.call(this,e));return e.history&&(O=e.history),n.state={url:n.props.url||s()},b(),n}return p(r,t),r.prototype.shouldComponentUpdate=function(t){return t.static!==!0||(t.url!==this.props.url||t.onChange!==this.props.onChange)},r.prototype.canRoute=function(t){return this.getMatchingChildren(this.props.children,t,!1).length>0},r.prototype.routeTo=function(t){return this._didRoute=!1,this.setState({url:t}),this.updating?this.canRoute(t):(this.forceUpdate(),this._didRoute)},r.prototype.componentWillMount=function(){U.push(this),this.updating=!0},r.prototype.componentDidMount=function(){var t=this;O&&(this.unlisten=O.listen(function(e){t.routeTo(""+(e.pathname||"")+(e.search||""))})),this.updating=!1},r.prototype.componentWillUnmount=function(){"function"==typeof this.unlisten&&this.unlisten(),U.splice(U.indexOf(this),1)},r.prototype.componentWillUpdate=function(){this.updating=!0},r.prototype.componentDidUpdate=function(){this.updating=!1},r.prototype.getMatchingChildren=function(t,r,o){return t.slice().sort(n).filter(function(t){var n=t.attributes,i=n.path,u=e(r,i,n);if(u){if(o!==!1){n.url=r,n.matches=u;for(var a in u)u.hasOwnProperty(a)&&(n[a]=u[a])}return!0}})},r.prototype.render=function(t,e){var n=t.children,r=t.onChange,o=e.url,i=this.getMatchingChildren(n,o,!0),u=i[0]||null;this._didRoute=!!u;var a=this.previousUrl;return o!==a&&(this.previousUrl=o,"function"==typeof r&&r({router:this,url:o,previous:a,active:i,current:u})),u},r}(t.Component),P=function(e){return t.h(e.component,e)};return x.route=l,x.Router=x,x.Route=P,x.Link=j,x}); | ||
//# sourceMappingURL=preact-router.min.js.map |
{ | ||
"name": "preact-router", | ||
"amdName": "preactRouter", | ||
"version": "2.4.2", | ||
"version": "2.4.3", | ||
"description": "Connect your components up to that address bar.", | ||
@@ -6,0 +6,0 @@ "main": "dist/preact-router.js", |
@@ -253,5 +253,3 @@ import { h, Component } from 'preact'; | ||
const Route = ({ component, ...props }) => { | ||
return h(component, props); | ||
}; | ||
const Route = props => h(props.component, props); | ||
@@ -258,0 +256,0 @@ Router.route = route; |
Sorry, the diff of this file is not supported yet
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
61662
615