preact-router
Advanced tools
Comparing version 2.5.1 to 2.5.2
@@ -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){function e(t,e){for(var n in e)t[n]=e[n];return t}function n(t,e,n){void 0===n&&(n=v);var r,i=/(?:\?([^#]*))?(#.*)?$/,u=t.match(i),a={};if(u&&u[1])for(var p=u[1].split("&"),c=0;c<p.length;c++){var f=p[c].split("=");a[decodeURIComponent(f[0])]=decodeURIComponent(f.slice(1).join("="))}t=o(t.replace(i,"")),e=o(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(/[+*?]+$/)||v)[0]||"",g=~d.indexOf("+"),m=~d.indexOf("*"),y=t[s]||"";if(!y&&!m&&(d.indexOf("?")<0||g)){r=!1;break}if(a[h]=decodeURIComponent(y),g||m){a[h]=t.slice(s).map(decodeURIComponent).join("/");break}}else if(e[s]!==t[s]){r=!1;break}return(!0===n.default||!1!==r)&&a}function r(t,e){var n=t.attributes||v,r=e.attributes||v;return n.default?1:r.default?-1:i(n.path)-i(r.path)||n.path.length-r.path.length}function o(t){return u(t).split("/")}function i(t){return(u(t).match(/\/+/g)||"").length}function u(t){return t.replace(/(^\/+|\/+$)/g,"")}function a(t){return null!=t.__preactattr_||"undefined"!=typeof Symbol&&null!=t[Symbol.for("preactattr")]}function p(t,e){void 0===e&&(e="push"),b&&b[e]?b[e](t):"undefined"!=typeof history&&history[e+"State"]&&history[e+"State"](null,null,t)}function c(){var t;return t=b&&b.location?b.location:b&&b.getCurrentLocation?b.getCurrentLocation():"undefined"!=typeof location?location:U,""+(t.pathname||"")+(t.search||"")}function f(t,e){return void 0===e&&(e=!1),"string"!=typeof t&&t.url&&(e=t.replace,t=t.url),l(t)&&p(t,e?"replace":"push"),s(t)}function l(t){for(var e=C.length;e--;)if(C[e].canRoute(t))return!0;return!1}function s(t){for(var e=!1,n=0;n<C.length;n++)!0===C[n].routeTo(t)&&(e=!0);for(var r=R.length;r--;)R[r](t);return e}function h(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 f(e)}}function d(t){if(0==t.button)return h(t.currentTarget||t.target||this),g(t)}function g(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"===(e.nodeName+"").toUpperCase()&&e.getAttribute("href")&&a(e)){if(e.hasAttribute("native"))return;if(h(e))return g(t)}}while(e=e.parentNode)}}function y(){_||("function"==typeof addEventListener&&(b||addEventListener("popstate",function(){return s(c())}),addEventListener("click",m)),_=!0)}var v={},b=null,C=[],R=[],U={},_=!1,x=function(o){function i(t){o.call(this,t),t.history&&(b=t.history),this.state={url:t.url||c()},y()}return o&&(i.__proto__=o),i.prototype=Object.create(o&&o.prototype),i.prototype.constructor=i,i.prototype.shouldComponentUpdate=function(t){return!0!==t.static||(t.url!==this.props.url||t.onChange!==this.props.onChange)},i.prototype.canRoute=function(t){return this.getMatchingChildren(this.props.children,t,!1).length>0},i.prototype.routeTo=function(t){return this._didRoute=!1,this.setState({url:t}),this.updating?this.canRoute(t):(this.forceUpdate(),this._didRoute)},i.prototype.componentWillMount=function(){C.push(this),this.updating=!0},i.prototype.componentDidMount=function(){var t=this;b&&(this.unlisten=b.listen(function(e){t.routeTo(""+(e.pathname||"")+(e.search||""))})),this.updating=!1},i.prototype.componentWillUnmount=function(){"function"==typeof this.unlisten&&this.unlisten(),C.splice(C.indexOf(this),1)},i.prototype.componentWillUpdate=function(){this.updating=!0},i.prototype.componentDidUpdate=function(){this.updating=!1},i.prototype.getMatchingChildren=function(o,i,u){return o.slice().sort(r).map(function(r){var o=r.attributes||{},a=o.path,p=n(i,a,o);if(p){if(!1!==u){var c={url:i,matches:p};return e(c,p),t.cloneElement(r,c)}return r}return!1}).filter(Boolean)},i.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},i}(t.Component),A=function(n){return t.h("a",e({onClick:d},n))},k=function(e){return t.h(e.component,e)};return x.subscribers=R,x.getCurrentUrl=c,x.route=f,x.Router=x,x.Route=k,x.Link=A,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){function e(t,e){for(var n in e)t[n]=e[n];return t}function n(t,e,n){void 0===n&&(n=v);var r,i=/(?:\?([^#]*))?(#.*)?$/,u=t.match(i),a={};if(u&&u[1])for(var p=u[1].split("&"),c=0;c<p.length;c++){var f=p[c].split("=");a[decodeURIComponent(f[0])]=decodeURIComponent(f.slice(1).join("="))}t=o(t.replace(i,"")),e=o(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(/[+*?]+$/)||v)[0]||"",g=~d.indexOf("+"),m=~d.indexOf("*"),y=t[s]||"";if(!y&&!m&&(d.indexOf("?")<0||g)){r=!1;break}if(a[h]=decodeURIComponent(y),g||m){a[h]=t.slice(s).map(decodeURIComponent).join("/");break}}else if(e[s]!==t[s]){r=!1;break}return(n.default===!0||r!==!1)&&a}function r(t,e){var n=t.attributes||v,r=e.attributes||v;if(n.default)return 1;if(r.default)return-1;var o=i(n.path)-i(r.path);return o||n.path.length-r.path.length}function o(t){return u(t).split("/")}function i(t){return(u(t).match(/\/+/g)||"").length}function u(t){return t.replace(/(^\/+|\/+$)/g,"")}function a(t){return null!=t.__preactattr_||"undefined"!=typeof Symbol&&null!=t[Symbol.for("preactattr")]}function p(t,e){void 0===e&&(e="push"),b&&b[e]?b[e](t):"undefined"!=typeof history&&history[e+"State"]&&history[e+"State"](null,null,t)}function c(){var t;return t=b&&b.location?b.location:b&&b.getCurrentLocation?b.getCurrentLocation():"undefined"!=typeof location?location:U,""+(t.pathname||"")+(t.search||"")}function f(t,e){return void 0===e&&(e=!1),"string"!=typeof t&&t.url&&(e=t.replace,t=t.url),l(t)&&p(t,e?"replace":"push"),s(t)}function l(t){for(var e=C.length;e--;)if(C[e].canRoute(t))return!0;return!1}function s(t){for(var e=!1,n=0;n<C.length;n++)C[n].routeTo(t)===!0&&(e=!0);for(var r=R.length;r--;)R[r](t);return e}function h(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 f(e)}}function d(t){if(0==t.button)return h(t.currentTarget||t.target||this),g(t)}function g(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"===(e.nodeName+"").toUpperCase()&&e.getAttribute("href")&&a(e)){if(e.hasAttribute("native"))return;if(h(e))return g(t)}while(e=e.parentNode)}}function y(){_||("function"==typeof addEventListener&&(b||addEventListener("popstate",function(){return s(c())}),addEventListener("click",m)),_=!0)}var v={},b=null,C=[],R=[],U={},_=!1,x=function(o){function i(t){o.call(this,t),t.history&&(b=t.history),this.state={url:t.url||c()},y()}return o&&(i.__proto__=o),i.prototype=Object.create(o&&o.prototype),i.prototype.constructor=i,i.prototype.shouldComponentUpdate=function(t){return t.static!==!0||(t.url!==this.props.url||t.onChange!==this.props.onChange)},i.prototype.canRoute=function(t){return this.getMatchingChildren(this.props.children,t,!1).length>0},i.prototype.routeTo=function(t){return this._didRoute=!1,this.setState({url:t}),this.updating?this.canRoute(t):(this.forceUpdate(),this._didRoute)},i.prototype.componentWillMount=function(){C.push(this),this.updating=!0},i.prototype.componentDidMount=function(){var t=this;b&&(this.unlisten=b.listen(function(e){t.routeTo(""+(e.pathname||"")+(e.search||""))})),this.updating=!1},i.prototype.componentWillUnmount=function(){"function"==typeof this.unlisten&&this.unlisten(),C.splice(C.indexOf(this),1)},i.prototype.componentWillUpdate=function(){this.updating=!0},i.prototype.componentDidUpdate=function(){this.updating=!1},i.prototype.getMatchingChildren=function(o,i,u){return o.slice().sort(r).map(function(r){var o=r.attributes||{},a=o.path,p=n(i,a,o);if(p){if(u!==!1){var c={url:i,matches:p};return e(c,p),t.cloneElement(r,c)}return r}return!1}).filter(Boolean)},i.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},i}(t.Component),A=function(n){return t.h("a",e({onClick:d},n))},k=function(e){return t.h(e.component,e)};return x.subscribers=R,x.getCurrentUrl=c,x.route=f,x.Router=x,x.Route=k,x.Link=A,x}); | ||
//# sourceMappingURL=preact-router.js.map |
{ | ||
"name": "preact-router", | ||
"amdName": "preactRouter", | ||
"version": "2.5.1", | ||
"version": "2.5.2", | ||
"description": "Connect your components up to that address bar.", | ||
@@ -25,3 +25,4 @@ "main": "dist/preact-router.js", | ||
"src", | ||
"dist" | ||
"dist", | ||
"match.js" | ||
], | ||
@@ -28,0 +29,0 @@ "x-typings": "./dist/index.d.ts", |
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
35824
13
740