Socket
Socket
Sign inDemoInstall

riot-route

Package Overview
Dependencies
1
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.3.12 to 2.3.13

test/specs/server.specs.js

57

dist/amd.route.js

@@ -21,5 +21,6 @@ ;define(function(require, exports, module) {

MAX_EMIT_STACK_LEVEL = 3,
win = window,
doc = document,
loc = win.history.location || win.location, // see html5-history-api
win = typeof window != 'undefined' && window,
doc = typeof document != 'undefined' && document,
hist = win && history,
loc = win && (hist.location || win.location), // see html5-history-api
prot = Router.prototype, // to minify more

@@ -105,3 +106,3 @@ clickEvent = doc && doc.ontouchstart ? 'touchstart' : 'click',

function getPathFromRoot(href) {
return (href || loc.href)[REPLACE](RE_ORIGIN, '')
return (href || loc.href || '')[REPLACE](RE_ORIGIN, '')
}

@@ -116,3 +117,3 @@

return base[0] == '#'
? (href || loc.href).split(base)[1] || ''
? (href || loc.href || '').split(base)[1] || ''
: getPathFromRoot(href)[REPLACE](base, '')

@@ -178,10 +179,15 @@ }

function go(path, title) {
title = title || doc.title
// browsers ignores the second parameter `title`
history.pushState(null, title, base + normalize(path))
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
if (hist) { // if a browser
title = title || doc.title
// browsers ignores the second parameter `title`
hist.pushState(null, title, base + normalize(path))
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
}
// Server-side usage: directly execute handlers for the path
return central[TRIGGER]('emit', getPathFromBase(path))
}

@@ -289,3 +295,4 @@

var q = {}
loc.href[REPLACE](/[?&](.+?)=([^&]*)/g, function(_, k, v) { q[k] = v })
var href = loc.href || current
href[REPLACE](/[?&](.+?)=([^&]*)/g, function(_, k, v) { q[k] = v })
return q

@@ -297,5 +304,7 @@ }

if (started) {
win[REMOVE_EVENT_LISTENER](POPSTATE, debouncedEmit)
win[REMOVE_EVENT_LISTENER](HASHCHANGE, debouncedEmit)
doc[REMOVE_EVENT_LISTENER](clickEvent, click)
if (win) {
win[REMOVE_EVENT_LISTENER](POPSTATE, debouncedEmit)
win[REMOVE_EVENT_LISTENER](HASHCHANGE, debouncedEmit)
doc[REMOVE_EVENT_LISTENER](clickEvent, click)
}
central[TRIGGER]('stop')

@@ -312,8 +321,10 @@ started = false

if (!started) {
if (document.readyState == 'complete') start(autoExec)
// the timeout is needed to solve
// a weird safari bug https://github.com/riot/route/issues/33
else win[ADD_EVENT_LISTENER]('load', function() {
setTimeout(function() { start(autoExec) }, 1)
})
if (win) {
if (document.readyState == 'complete') start(autoExec)
// the timeout is needed to solve
// a weird safari bug https://github.com/riot/route/issues/33
else win[ADD_EVENT_LISTENER]('load', function() {
setTimeout(function() { start(autoExec) }, 1)
})
}
started = true

@@ -320,0 +331,0 @@ }

@@ -1,1 +0,1 @@

define(function(t,e,n){"use strict";var i=t("riot-observable");var r=/^.+?\/+[^\/]+/,f="EventListener",o="remove"+f,u="add"+f,s="hasAttribute",c="replace",a="popstate",h="hashchange",l="trigger",p=3,d=window,m=document,v=d.history.location||d.location,g=L.prototype,y=m&&m.ontouchstart?"touchstart":"click",b=false,w=i(),$=false,x,A,K,N,T,E=[],O=0;function S(t){return t.split(/[\/?#]/)}function k(t,e){var n=new RegExp("^"+e[c](/\*/g,"([^/?#]+?)")[c](/\.\./,".*")+"$"),i=t.match(n);if(i)return i.slice(1)}function q(t,e){var n;return function(){clearTimeout(n);n=setTimeout(t,e)}}function D(t){x=q(z,1);d[u](a,x);d[u](h,x);m[u](y,B);if(t)z(true)}function L(){this.$=[];i(this);w.on("stop",this.s.bind(this));w.on("emit",this.e.bind(this))}function P(t){return t[c](/^\/|\/$/,"")}function R(t){return typeof t=="string"}function _(t){return(t||v.href)[c](r,"")}function j(t){return A[0]=="#"?(t||v.href).split(A)[1]||"":_(t)[c](A,"")}function z(t){var e=O==0;if(p<=O)return;O++;E.push(function(){var e=j();if(t||e!=K){w[l]("emit",e);K=e}});if(e){while(E.length){E[0]();E.shift()}O=0}}function B(t){if(t.which!=1||t.metaKey||t.ctrlKey||t.shiftKey||t.defaultPrevented)return;var e=t.target;while(e&&e.nodeName!="A")e=e.parentNode;if(!e||e.nodeName!="A"||e[s]("download")||!e[s]("href")||e.target&&e.target!="_self"||e.href.indexOf(v.href.match(r)[0])==-1)return;if(e.href!=v.href){if(e.href.split("#")[0]==v.href.split("#")[0]||A!="#"&&_(e.href).indexOf(A)!==0||!C(j(e.href),e.title||m.title))return}t.preventDefault()}function C(t,e){e=e||m.title;history.pushState(null,e,A+P(t));m.title=e;$=false;z();return $}g.m=function(t,e){if(R(t)&&(!e||R(e)))C(t,e);else if(e)this.r(t,e);else this.r("@",t)};g.s=function(){this.off("*");this.$=[]};g.e=function(t){this.$.concat("@").some(function(e){var n=(e=="@"?N:T)(P(t),P(e));if(typeof n!="undefined"){this[l].apply(null,[e].concat(n));return $=true}},this)};g.r=function(t,e){if(t!="@"){t="/"+P(t);this.$.push(t)}this.on(t,e)};var F=new L;var G=F.m.bind(F);G.create=function(){var t=new L;t.m.stop=t.s.bind(t);return t.m.bind(t)};G.base=function(t){A=t||"#";K=j()};G.exec=function(){z(true)};G.parser=function(t,e){if(!t&&!e){N=S;T=k}if(t)N=t;if(e)T=e};G.query=function(){var t={};v.href[c](/[?&](.+?)=([^&]*)/g,function(e,n,i){t[n]=i});return t};G.stop=function(){if(b){d[o](a,x);d[o](h,x);m[o](y,B);w[l]("stop");b=false}};G.start=function(t){if(!b){if(document.readyState=="complete")D(t);else d[u]("load",function(){setTimeout(function(){D(t)},1)});b=true}};G.base();G.parser();n.exports=G});
define(function(t,e,n){"use strict";var i=t("riot-observable");var r=/^.+?\/+[^\/]+/,f="EventListener",o="remove"+f,u="add"+f,s="hasAttribute",c="replace",a="popstate",h="hashchange",l="trigger",d=3,p=typeof window!="undefined"&&window,m=typeof document!="undefined"&&document,v=p&&history,y=p&&(v.location||p.location),g=P.prototype,w=m&&m.ontouchstart?"touchstart":"click",b=false,$=i(),x=false,A,K,N,T,E,O=[],S=0;function k(t){return t.split(/[\/?#]/)}function q(t,e){var n=new RegExp("^"+e[c](/\*/g,"([^/?#]+?)")[c](/\.\./,".*")+"$"),i=t.match(n);if(i)return i.slice(1)}function D(t,e){var n;return function(){clearTimeout(n);n=setTimeout(t,e)}}function L(t){A=D(B,1);p[u](a,A);p[u](h,A);m[u](w,C);if(t)B(true)}function P(){this.$=[];i(this);$.on("stop",this.s.bind(this));$.on("emit",this.e.bind(this))}function R(t){return t[c](/^\/|\/$/,"")}function _(t){return typeof t=="string"}function j(t){return(t||y.href||"")[c](r,"")}function z(t){return K[0]=="#"?(t||y.href||"").split(K)[1]||"":j(t)[c](K,"")}function B(t){var e=S==0;if(d<=S)return;S++;O.push(function(){var e=z();if(t||e!=N){$[l]("emit",e);N=e}});if(e){while(O.length){O[0]();O.shift()}S=0}}function C(t){if(t.which!=1||t.metaKey||t.ctrlKey||t.shiftKey||t.defaultPrevented)return;var e=t.target;while(e&&e.nodeName!="A")e=e.parentNode;if(!e||e.nodeName!="A"||e[s]("download")||!e[s]("href")||e.target&&e.target!="_self"||e.href.indexOf(y.href.match(r)[0])==-1)return;if(e.href!=y.href){if(e.href.split("#")[0]==y.href.split("#")[0]||K!="#"&&j(e.href).indexOf(K)!==0||!F(z(e.href),e.title||m.title))return}t.preventDefault()}function F(t,e){if(v){e=e||m.title;v.pushState(null,e,K+R(t));m.title=e;x=false;B();return x}return $[l]("emit",z(t))}g.m=function(t,e){if(_(t)&&(!e||_(e)))F(t,e);else if(e)this.r(t,e);else this.r("@",t)};g.s=function(){this.off("*");this.$=[]};g.e=function(t){this.$.concat("@").some(function(e){var n=(e=="@"?T:E)(R(t),R(e));if(typeof n!="undefined"){this[l].apply(null,[e].concat(n));return x=true}},this)};g.r=function(t,e){if(t!="@"){t="/"+R(t);this.$.push(t)}this.on(t,e)};var G=new P;var H=G.m.bind(G);H.create=function(){var t=new P;t.m.stop=t.s.bind(t);return t.m.bind(t)};H.base=function(t){K=t||"#";N=z()};H.exec=function(){B(true)};H.parser=function(t,e){if(!t&&!e){T=k;E=q}if(t)T=t;if(e)E=e};H.query=function(){var t={};var e=y.href||N;e[c](/[?&](.+?)=([^&]*)/g,function(e,n,i){t[n]=i});return t};H.stop=function(){if(b){if(p){p[o](a,A);p[o](h,A);m[o](w,C)}$[l]("stop");b=false}};H.start=function(t){if(!b){if(p){if(document.readyState=="complete")L(t);else p[u]("load",function(){setTimeout(function(){L(t)},1)})}b=true}};H.base();H.parser();n.exports=H});

@@ -18,5 +18,6 @@ import observable from 'riot-observable'

MAX_EMIT_STACK_LEVEL = 3,
win = window,
doc = document,
loc = win.history.location || win.location, // see html5-history-api
win = typeof window != 'undefined' && window,
doc = typeof document != 'undefined' && document,
hist = win && history,
loc = win && (hist.location || win.location), // see html5-history-api
prot = Router.prototype, // to minify more

@@ -102,3 +103,3 @@ clickEvent = doc && doc.ontouchstart ? 'touchstart' : 'click',

function getPathFromRoot(href) {
return (href || loc.href)[REPLACE](RE_ORIGIN, '')
return (href || loc.href || '')[REPLACE](RE_ORIGIN, '')
}

@@ -113,3 +114,3 @@

return base[0] == '#'
? (href || loc.href).split(base)[1] || ''
? (href || loc.href || '').split(base)[1] || ''
: getPathFromRoot(href)[REPLACE](base, '')

@@ -175,10 +176,15 @@ }

function go(path, title) {
title = title || doc.title
// browsers ignores the second parameter `title`
history.pushState(null, title, base + normalize(path))
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
if (hist) { // if a browser
title = title || doc.title
// browsers ignores the second parameter `title`
hist.pushState(null, title, base + normalize(path))
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
}
// Server-side usage: directly execute handlers for the path
return central[TRIGGER]('emit', getPathFromBase(path))
}

@@ -286,3 +292,4 @@

var q = {}
loc.href[REPLACE](/[?&](.+?)=([^&]*)/g, function(_, k, v) { q[k] = v })
var href = loc.href || current
href[REPLACE](/[?&](.+?)=([^&]*)/g, function(_, k, v) { q[k] = v })
return q

@@ -294,5 +301,7 @@ }

if (started) {
win[REMOVE_EVENT_LISTENER](POPSTATE, debouncedEmit)
win[REMOVE_EVENT_LISTENER](HASHCHANGE, debouncedEmit)
doc[REMOVE_EVENT_LISTENER](clickEvent, click)
if (win) {
win[REMOVE_EVENT_LISTENER](POPSTATE, debouncedEmit)
win[REMOVE_EVENT_LISTENER](HASHCHANGE, debouncedEmit)
doc[REMOVE_EVENT_LISTENER](clickEvent, click)
}
central[TRIGGER]('stop')

@@ -309,8 +318,10 @@ started = false

if (!started) {
if (document.readyState == 'complete') start(autoExec)
// the timeout is needed to solve
// a weird safari bug https://github.com/riot/route/issues/33
else win[ADD_EVENT_LISTENER]('load', function() {
setTimeout(function() { start(autoExec) }, 1)
})
if (win) {
if (document.readyState == 'complete') start(autoExec)
// the timeout is needed to solve
// a weird safari bug https://github.com/riot/route/issues/33
else win[ADD_EVENT_LISTENER]('load', function() {
setTimeout(function() { start(autoExec) }, 1)
})
}
started = true

@@ -317,0 +328,0 @@ }

@@ -1,2 +0,2 @@

;(function(riot) { if (!window) return;
;(function(riot) {

@@ -19,5 +19,6 @@ /**

MAX_EMIT_STACK_LEVEL = 3,
win = window,
doc = document,
loc = win.history.location || win.location, // see html5-history-api
win = typeof window != 'undefined' && window,
doc = typeof document != 'undefined' && document,
hist = win && history,
loc = win && (hist.location || win.location), // see html5-history-api
prot = Router.prototype, // to minify more

@@ -103,3 +104,3 @@ clickEvent = doc && doc.ontouchstart ? 'touchstart' : 'click',

function getPathFromRoot(href) {
return (href || loc.href)[REPLACE](RE_ORIGIN, '')
return (href || loc.href || '')[REPLACE](RE_ORIGIN, '')
}

@@ -114,3 +115,3 @@

return base[0] == '#'
? (href || loc.href).split(base)[1] || ''
? (href || loc.href || '').split(base)[1] || ''
: getPathFromRoot(href)[REPLACE](base, '')

@@ -176,10 +177,15 @@ }

function go(path, title) {
title = title || doc.title
// browsers ignores the second parameter `title`
history.pushState(null, title, base + normalize(path))
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
if (hist) { // if a browser
title = title || doc.title
// browsers ignores the second parameter `title`
hist.pushState(null, title, base + normalize(path))
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
}
// Server-side usage: directly execute handlers for the path
return central[TRIGGER]('emit', getPathFromBase(path))
}

@@ -287,3 +293,4 @@

var q = {}
loc.href[REPLACE](/[?&](.+?)=([^&]*)/g, function(_, k, v) { q[k] = v })
var href = loc.href || current
href[REPLACE](/[?&](.+?)=([^&]*)/g, function(_, k, v) { q[k] = v })
return q

@@ -295,5 +302,7 @@ }

if (started) {
win[REMOVE_EVENT_LISTENER](POPSTATE, debouncedEmit)
win[REMOVE_EVENT_LISTENER](HASHCHANGE, debouncedEmit)
doc[REMOVE_EVENT_LISTENER](clickEvent, click)
if (win) {
win[REMOVE_EVENT_LISTENER](POPSTATE, debouncedEmit)
win[REMOVE_EVENT_LISTENER](HASHCHANGE, debouncedEmit)
doc[REMOVE_EVENT_LISTENER](clickEvent, click)
}
central[TRIGGER]('stop')

@@ -310,8 +319,10 @@ started = false

if (!started) {
if (document.readyState == 'complete') start(autoExec)
// the timeout is needed to solve
// a weird safari bug https://github.com/riot/route/issues/33
else win[ADD_EVENT_LISTENER]('load', function() {
setTimeout(function() { start(autoExec) }, 1)
})
if (win) {
if (document.readyState == 'complete') start(autoExec)
// the timeout is needed to solve
// a weird safari bug https://github.com/riot/route/issues/33
else win[ADD_EVENT_LISTENER]('load', function() {
setTimeout(function() { start(autoExec) }, 1)
})
}
started = true

@@ -318,0 +329,0 @@ }

@@ -142,5 +142,6 @@ ;(function() {

MAX_EMIT_STACK_LEVEL = 3,
win = window,
doc = document,
loc = win.history.location || win.location, // see html5-history-api
win = typeof window != 'undefined' && window,
doc = typeof document != 'undefined' && document,
hist = win && history,
loc = win && (hist.location || win.location), // see html5-history-api
prot = Router.prototype, // to minify more

@@ -226,3 +227,3 @@ clickEvent = doc && doc.ontouchstart ? 'touchstart' : 'click',

function getPathFromRoot(href) {
return (href || loc.href)[REPLACE](RE_ORIGIN, '')
return (href || loc.href || '')[REPLACE](RE_ORIGIN, '')
}

@@ -237,3 +238,3 @@

return base[0] == '#'
? (href || loc.href).split(base)[1] || ''
? (href || loc.href || '').split(base)[1] || ''
: getPathFromRoot(href)[REPLACE](base, '')

@@ -299,10 +300,15 @@ }

function go(path, title) {
title = title || doc.title
// browsers ignores the second parameter `title`
history.pushState(null, title, base + normalize(path))
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
if (hist) { // if a browser
title = title || doc.title
// browsers ignores the second parameter `title`
hist.pushState(null, title, base + normalize(path))
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
}
// Server-side usage: directly execute handlers for the path
return central[TRIGGER]('emit', getPathFromBase(path))
}

@@ -410,3 +416,4 @@

var q = {}
loc.href[REPLACE](/[?&](.+?)=([^&]*)/g, function(_, k, v) { q[k] = v })
var href = loc.href || current
href[REPLACE](/[?&](.+?)=([^&]*)/g, function(_, k, v) { q[k] = v })
return q

@@ -418,5 +425,7 @@ }

if (started) {
win[REMOVE_EVENT_LISTENER](POPSTATE, debouncedEmit)
win[REMOVE_EVENT_LISTENER](HASHCHANGE, debouncedEmit)
doc[REMOVE_EVENT_LISTENER](clickEvent, click)
if (win) {
win[REMOVE_EVENT_LISTENER](POPSTATE, debouncedEmit)
win[REMOVE_EVENT_LISTENER](HASHCHANGE, debouncedEmit)
doc[REMOVE_EVENT_LISTENER](clickEvent, click)
}
central[TRIGGER]('stop')

@@ -433,8 +442,10 @@ started = false

if (!started) {
if (document.readyState == 'complete') start(autoExec)
// the timeout is needed to solve
// a weird safari bug https://github.com/riot/route/issues/33
else win[ADD_EVENT_LISTENER]('load', function() {
setTimeout(function() { start(autoExec) }, 1)
})
if (win) {
if (document.readyState == 'complete') start(autoExec)
// the timeout is needed to solve
// a weird safari bug https://github.com/riot/route/issues/33
else win[ADD_EVENT_LISTENER]('load', function() {
setTimeout(function() { start(autoExec) }, 1)
})
}
started = true

@@ -441,0 +452,0 @@ }

@@ -1,1 +0,1 @@

(function(){"use strict";var t=function(t){t=t||{};var e={},n=function(t,e){t.replace(/\S+/g,e)},r=function(e,n){Object.defineProperty(t,e,{value:n,enumerable:false,writable:false,configurable:false})};r("on",function(r,i){if(typeof i!="function")return t;n(r,function(t,n){(e[t]=e[t]||[]).push(i);i.typed=n>0});return t});r("off",function(r,i){if(r=="*")e={};else{n(r,function(t){if(i){var n=e[t];for(var r=0,f;f=n&&n[r];++r){if(f==i)n.splice(r--,1)}}else delete e[t]})}return t});r("one",function(e,n){function r(){t.off(e,r);n.apply(t,arguments)}return t.on(e,r)});r("trigger",function(r){var i=arguments.length-1,f=new Array(i);for(var u=0;u<i;u++){f[u]=arguments[u+1]}n(r,function(n){var r=(e[n]||[]).slice(0);for(var i=0,u;u=r[i];++i){if(u.busy)return;u.busy=1;try{u.apply(t,u.typed?[n].concat(f):f)}catch(o){}if(r[i]!==u){i--}u.busy=0}if(e.all&&n!="all")t.trigger.apply(t,["all",n].concat(f))});return t});return t};var e=/^.+?\/+[^\/]+/,n="EventListener",r="remove"+n,i="add"+n,f="hasAttribute",u="replace",o="popstate",a="hashchange",c="trigger",s=3,l=window,h=document,p=l.history.location||l.location,d=P.prototype,v=h&&h.ontouchstart?"touchstart":"click",m=false,y=t(),g=false,b,w,$,x,A,K=[],N=0;function O(t){return t.split(/[\/?#]/)}function S(t,e){var n=new RegExp("^"+e[u](/\*/g,"([^/?#]+?)")[u](/\.\./,".*")+"$"),r=t.match(n);if(r)return r.slice(1)}function T(t,e){var n;return function(){clearTimeout(n);n=setTimeout(t,e)}}function E(t){b=T(L,1);l[i](o,b);l[i](a,b);h[i](v,R);if(t)L(true)}function P(){this.$=[];t(this);y.on("stop",this.s.bind(this));y.on("emit",this.e.bind(this))}function j(t){return t[u](/^\/|\/$/,"")}function k(t){return typeof t=="string"}function q(t){return(t||p.href)[u](e,"")}function D(t){return w[0]=="#"?(t||p.href).split(w)[1]||"":q(t)[u](w,"")}function L(t){var e=N==0;if(s<=N)return;N++;K.push(function(){var e=D();if(t||e!=$){y[c]("emit",e);$=e}});if(e){while(K.length){K[0]();K.shift()}N=0}}function R(t){if(t.which!=1||t.metaKey||t.ctrlKey||t.shiftKey||t.defaultPrevented)return;var n=t.target;while(n&&n.nodeName!="A")n=n.parentNode;if(!n||n.nodeName!="A"||n[f]("download")||!n[f]("href")||n.target&&n.target!="_self"||n.href.indexOf(p.href.match(e)[0])==-1)return;if(n.href!=p.href){if(n.href.split("#")[0]==p.href.split("#")[0]||w!="#"&&q(n.href).indexOf(w)!==0||!_(D(n.href),n.title||h.title))return}t.preventDefault()}function _(t,e){e=e||h.title;history.pushState(null,e,w+j(t));h.title=e;g=false;L();return g}d.m=function(t,e){if(k(t)&&(!e||k(e)))_(t,e);else if(e)this.r(t,e);else this.r("@",t)};d.s=function(){this.off("*");this.$=[]};d.e=function(t){this.$.concat("@").some(function(e){var n=(e=="@"?x:A)(j(t),j(e));if(typeof n!="undefined"){this[c].apply(null,[e].concat(n));return g=true}},this)};d.r=function(t,e){if(t!="@"){t="/"+j(t);this.$.push(t)}this.on(t,e)};var z=new P;var B=z.m.bind(z);B.create=function(){var t=new P;t.m.stop=t.s.bind(t);return t.m.bind(t)};B.base=function(t){w=t||"#";$=D()};B.exec=function(){L(true)};B.parser=function(t,e){if(!t&&!e){x=O;A=S}if(t)x=t;if(e)A=e};B.query=function(){var t={};p.href[u](/[?&](.+?)=([^&]*)/g,function(e,n,r){t[n]=r});return t};B.stop=function(){if(m){l[r](o,b);l[r](a,b);h[r](v,R);y[c]("stop");m=false}};B.start=function(t){if(!m){if(document.readyState=="complete")E(t);else l[i]("load",function(){setTimeout(function(){E(t)},1)});m=true}};B.base();B.parser();window.route=B})();
(function(){"use strict";var t=function(t){t=t||{};var e={},n=function(t,e){t.replace(/\S+/g,e)},i=function(e,n){Object.defineProperty(t,e,{value:n,enumerable:false,writable:false,configurable:false})};i("on",function(i,r){if(typeof r!="function")return t;n(i,function(t,n){(e[t]=e[t]||[]).push(r);r.typed=n>0});return t});i("off",function(i,r){if(i=="*")e={};else{n(i,function(t){if(r){var n=e[t];for(var i=0,f;f=n&&n[i];++i){if(f==r)n.splice(i--,1)}}else delete e[t]})}return t});i("one",function(e,n){function i(){t.off(e,i);n.apply(t,arguments)}return t.on(e,i)});i("trigger",function(i){var r=arguments.length-1,f=new Array(r);for(var u=0;u<r;u++){f[u]=arguments[u+1]}n(i,function(n){var i=(e[n]||[]).slice(0);for(var r=0,u;u=i[r];++r){if(u.busy)return;u.busy=1;try{u.apply(t,u.typed?[n].concat(f):f)}catch(o){}if(i[r]!==u){r--}u.busy=0}if(e.all&&n!="all")t.trigger.apply(t,["all",n].concat(f))});return t});return t};var e=/^.+?\/+[^\/]+/,n="EventListener",i="remove"+n,r="add"+n,f="hasAttribute",u="replace",o="popstate",a="hashchange",c="trigger",s=3,l=typeof window!="undefined"&&window,h=typeof document!="undefined"&&document,p=l&&history,d=l&&(p.location||l.location),m=j.prototype,v=h&&h.ontouchstart?"touchstart":"click",y=false,g=t(),b=false,w,$,x,A,K,N=[],O=0;function S(t){return t.split(/[\/?#]/)}function T(t,e){var n=new RegExp("^"+e[u](/\*/g,"([^/?#]+?)")[u](/\.\./,".*")+"$"),i=t.match(n);if(i)return i.slice(1)}function E(t,e){var n;return function(){clearTimeout(n);n=setTimeout(t,e)}}function P(t){w=E(R,1);l[r](o,w);l[r](a,w);h[r](v,_);if(t)R(true)}function j(){this.$=[];t(this);g.on("stop",this.s.bind(this));g.on("emit",this.e.bind(this))}function k(t){return t[u](/^\/|\/$/,"")}function q(t){return typeof t=="string"}function D(t){return(t||d.href||"")[u](e,"")}function L(t){return $[0]=="#"?(t||d.href||"").split($)[1]||"":D(t)[u]($,"")}function R(t){var e=O==0;if(s<=O)return;O++;N.push(function(){var e=L();if(t||e!=x){g[c]("emit",e);x=e}});if(e){while(N.length){N[0]();N.shift()}O=0}}function _(t){if(t.which!=1||t.metaKey||t.ctrlKey||t.shiftKey||t.defaultPrevented)return;var n=t.target;while(n&&n.nodeName!="A")n=n.parentNode;if(!n||n.nodeName!="A"||n[f]("download")||!n[f]("href")||n.target&&n.target!="_self"||n.href.indexOf(d.href.match(e)[0])==-1)return;if(n.href!=d.href){if(n.href.split("#")[0]==d.href.split("#")[0]||$!="#"&&D(n.href).indexOf($)!==0||!z(L(n.href),n.title||h.title))return}t.preventDefault()}function z(t,e){if(p){e=e||h.title;p.pushState(null,e,$+k(t));h.title=e;b=false;R();return b}return g[c]("emit",L(t))}m.m=function(t,e){if(q(t)&&(!e||q(e)))z(t,e);else if(e)this.r(t,e);else this.r("@",t)};m.s=function(){this.off("*");this.$=[]};m.e=function(t){this.$.concat("@").some(function(e){var n=(e=="@"?A:K)(k(t),k(e));if(typeof n!="undefined"){this[c].apply(null,[e].concat(n));return b=true}},this)};m.r=function(t,e){if(t!="@"){t="/"+k(t);this.$.push(t)}this.on(t,e)};var B=new j;var C=B.m.bind(B);C.create=function(){var t=new j;t.m.stop=t.s.bind(t);return t.m.bind(t)};C.base=function(t){$=t||"#";x=L()};C.exec=function(){R(true)};C.parser=function(t,e){if(!t&&!e){A=S;K=T}if(t)A=t;if(e)K=e};C.query=function(){var t={};var e=d.href||x;e[u](/[?&](.+?)=([^&]*)/g,function(e,n,i){t[n]=i});return t};C.stop=function(){if(y){if(l){l[i](o,w);l[i](a,w);h[i](v,_)}g[c]("stop");y=false}};C.start=function(t){if(!y){if(l){if(document.readyState=="complete")P(t);else l[r]("load",function(){setTimeout(function(){P(t)},1)})}y=true}};C.base();C.parser();window.route=C})();

@@ -8,4 +8,5 @@ # Router API

- replacable parser
- isomorphic
- use a [polyfill](https://github.com/devote/HTML5-History-API) for ie9 support and earlier. Because ie.
## Setup routing

@@ -108,3 +109,3 @@

See also [Routing group](#routing-group) and [Routing priority](#routing-priority) section, for detail.
See also [Routing group](#routing-groups) and [Routing priority](#routing-priority) section, for detail.

@@ -132,2 +133,4 @@ ## Use router

route.start()
<<<<<<< HEAD
=======
```

@@ -153,4 +156,10 @@

route.exec()
>>>>>>> master
```
<span class="tag red">&gt;= v2.3</span>
Riot doesn't `start` its router automatically. DON'T FORGET TO START IT BY YOURSELF. This also means that you can choose your favorite router.
(Note: before v2.3 Riot started the router automatically. The behavior was changed)
### route.stop()

@@ -185,3 +194,3 @@

Study the current path "in place" emit routing without waiting for it to change. For example:
Study the current browser path "in place" and emit routing without waiting for it to change.

@@ -188,0 +197,0 @@ ```javascript

@@ -18,5 +18,6 @@ /**

MAX_EMIT_STACK_LEVEL = 3,
win = window,
doc = document,
loc = win.history.location || win.location, // see html5-history-api
win = typeof window != 'undefined' && window,
doc = typeof document != 'undefined' && document,
hist = win && history,
loc = win && (hist.location || win.location), // see html5-history-api
prot = Router.prototype, // to minify more

@@ -102,3 +103,3 @@ clickEvent = doc && doc.ontouchstart ? 'touchstart' : 'click',

function getPathFromRoot(href) {
return (href || loc.href)[REPLACE](RE_ORIGIN, '')
return (href || loc.href || '')[REPLACE](RE_ORIGIN, '')
}

@@ -113,3 +114,3 @@

return base[0] == '#'
? (href || loc.href).split(base)[1] || ''
? (href || loc.href || '').split(base)[1] || ''
: getPathFromRoot(href)[REPLACE](base, '')

@@ -175,10 +176,15 @@ }

function go(path, title) {
title = title || doc.title
// browsers ignores the second parameter `title`
history.pushState(null, title, base + normalize(path))
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
if (hist) { // if a browser
title = title || doc.title
// browsers ignores the second parameter `title`
hist.pushState(null, title, base + normalize(path))
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
}
// Server-side usage: directly execute handlers for the path
return central[TRIGGER]('emit', getPathFromBase(path))
}

@@ -286,3 +292,4 @@

var q = {}
loc.href[REPLACE](/[?&](.+?)=([^&]*)/g, function(_, k, v) { q[k] = v })
var href = loc.href || current
href[REPLACE](/[?&](.+?)=([^&]*)/g, function(_, k, v) { q[k] = v })
return q

@@ -294,5 +301,7 @@ }

if (started) {
win[REMOVE_EVENT_LISTENER](POPSTATE, debouncedEmit)
win[REMOVE_EVENT_LISTENER](HASHCHANGE, debouncedEmit)
doc[REMOVE_EVENT_LISTENER](clickEvent, click)
if (win) {
win[REMOVE_EVENT_LISTENER](POPSTATE, debouncedEmit)
win[REMOVE_EVENT_LISTENER](HASHCHANGE, debouncedEmit)
doc[REMOVE_EVENT_LISTENER](clickEvent, click)
}
central[TRIGGER]('stop')

@@ -309,8 +318,10 @@ started = false

if (!started) {
if (document.readyState == 'complete') start(autoExec)
// the timeout is needed to solve
// a weird safari bug https://github.com/riot/route/issues/33
else win[ADD_EVENT_LISTENER]('load', function() {
setTimeout(function() { start(autoExec) }, 1)
})
if (win) {
if (document.readyState == 'complete') start(autoExec)
// the timeout is needed to solve
// a weird safari bug https://github.com/riot/route/issues/33
else win[ADD_EVENT_LISTENER]('load', function() {
setTimeout(function() { start(autoExec) }, 1)
})
}
started = true

@@ -317,0 +328,0 @@ }

{
"name": "riot-route",
"version": "2.3.12",
"description": "Simple client-side router",
"version": "2.3.13",
"description": "Simple isomorphic router",
"main": "lib/index.js",
"jsnext:main": "lib/es6.route.js",
"directories": {

@@ -24,3 +25,3 @@ "lib": "lib",

"dependencies": {
"riot-observable": "^2.3.11"
"riot-observable": "^2.3.12"
},

@@ -35,3 +36,3 @@ "devDependencies": {

"karma-mocha": "^0.2.1",
"karma-browserstack-launcher": "^0.1.7",
"karma-browserstack-launcher": "^0.1.8",
"karma-mocha-reporter": "^1.1.3",

@@ -38,0 +39,0 @@ "karma-phantomjs-launcher": "^0.2.1",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc