preact-router
Advanced tools
Comparing version 2.3.0 to 2.3.1
@@ -107,3 +107,5 @@ (function (global, factory) { | ||
var url = void 0; | ||
if (customHistory && customHistory.getCurrentLocation) { | ||
if (customHistory && customHistory.location) { | ||
url = customHistory.location; | ||
} else if (customHistory && customHistory.getCurrentLocation) { | ||
url = customHistory.getCurrentLocation(); | ||
@@ -110,0 +112,0 @@ } else { |
@@ -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]: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 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(/[+*?]+$/)||C)[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||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,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 f(t){return _ in t}function l(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"push";R&&R[e]?R[e](t):"undefined"!=typeof history&&history[e+"State"]&&history[e+"State"](null,null,t)}function s(){var t=void 0;return t=R&&R.getCurrentLocation?R.getCurrentLocation():"undefined"!=typeof location?location:w,""+(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=U.length;e--;)if(U[e].canRoute(t))return!0;return!1}function g(t){for(var e=!1,n=0;n<U.length;n++)U[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)){var e=t.target;do if("A"===String(e.nodeName).toUpperCase()&&e.getAttribute("href")&&f(e)){if(0!==t.button)return;if(y(e))return m(t)}while(e=e.parentNode)}}var C={},O=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},R=null,U=[],w={},_="undefined"!=typeof Symbol?Symbol.for("preactattr"):"__preactattr_";"function"==typeof addEventListener&&(addEventListener("popstate",function(){return g(s())}),addEventListener("click",b));var j=function(e){var n=e.children,r=c(e,["children"]);return t.h("a",O({},r,{onClick:v}),n)},x=function(t){function r(e){u(this,r);var n=a(this,t.call(this,e));return e.history&&(R=e.history),n.state={url:n.props.url||s()},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(){this.updating=!1},r.prototype.componentWillUnmount=function(){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){var n=e.component,r=e.url,o=e.matches;return t.h(n,{url:r,matches:o})};return x.route=h,x.Router=x,x.Route=P,x.Link=j,x}); | ||
!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 c=i[1].split("&"),p=0;p<c.length;p++){var f=c[p].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(/[+*?]+$/)||C)[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||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 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 p(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 f(t){return _ in t}function l(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"push";R&&R[e]?R[e](t):"undefined"!=typeof history&&history[e+"State"]&&history[e+"State"](null,null,t)}function s(){var t=void 0;return t=R&&R.location?R.location:R&&R.getCurrentLocation?R.getCurrentLocation():"undefined"!=typeof location?location:w,""+(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=U.length;e--;)if(U[e].canRoute(t))return!0;return!1}function g(t){for(var e=!1,n=0;n<U.length;n++)U[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)){var e=t.target;do if("A"===String(e.nodeName).toUpperCase()&&e.getAttribute("href")&&f(e)){if(0!==t.button)return;if(y(e))return m(t)}while(e=e.parentNode)}}var C={},O=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},R=null,U=[],w={},_="undefined"!=typeof Symbol?Symbol.for("preactattr"):"__preactattr_";"function"==typeof addEventListener&&(addEventListener("popstate",function(){return g(s())}),addEventListener("click",b));var j=function(e){var n=e.children,r=p(e,["children"]);return t.h("a",O({},r,{onClick:v}),n)},x=function(t){function r(e){u(this,r);var n=a(this,t.call(this,e));return e.history&&(R=e.history),n.state={url:n.props.url||s()},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(){U.push(this),this.updating=!0},r.prototype.componentDidMount=function(){this.updating=!1},r.prototype.componentWillUnmount=function(){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){var n=e.component,r=e.url,o=e.matches;return t.h(n,{url:r,matches:o})};return x.route=h,x.Router=x,x.Route=P,x.Link=j,x}); | ||
//# sourceMappingURL=preact-router.min.js.map |
{ | ||
"name": "preact-router", | ||
"amdName": "preactRouter", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"description": "Connect your components up to that address bar.", | ||
@@ -6,0 +6,0 @@ "main": "dist/preact-router.js", |
@@ -30,3 +30,6 @@ import { h, Component } from 'preact'; | ||
let url; | ||
if (customHistory && customHistory.getCurrentLocation) { | ||
if (customHistory && customHistory.location) { | ||
url = customHistory.location; | ||
} | ||
else if (customHistory && customHistory.getCurrentLocation) { | ||
url = customHistory.getCurrentLocation(); | ||
@@ -33,0 +36,0 @@ } |
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
70225
17430
1009