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.0-beta.3 to 2.3.0-beta.4

2

dist/amd.route.js

@@ -44,3 +44,3 @@ ;define(function(require, exports, module) {

function DEFAULT_SECOND_PARSER(path, filter) {
var re = new RegExp('^' + filter[REPLACE](/\*/g, '(\\w+)')[REPLACE](/\.\./, '.*') + '$'),
var re = new RegExp('^' + filter[REPLACE](/\*/g, '([^/?#]+?)')[REPLACE](/\.\./, '.*') + '$'),
args = path.match(re)

@@ -47,0 +47,0 @@

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

define(function(t,e,n){"use strict";var i=t("riot-observable");var r=/^.+?\/+[^\/]+/,f="EventListener",o="remove"+f,s="add"+f,u="hasAttribute",a="replace",c="popstate",h="trigger",l=window,p=document,d=l.history.location||l.location,v=N.prototype,m=p&&p.ontouchstart?"touchstart":"click",b=false,w=i(),g,y,$,x;function A(t){return t.split(/[\/?#]/)}function K(t,e){var n=new RegExp("^"+e[a](/\*/g,"(\\w+)")[a](/\.\./,".*")+"$"),i=t.match(n);if(i)return i.slice(1)}function N(){this.$=[];i(this);w.on("stop",this.s.bind(this));w.on("emit",this.e.bind(this))}function E(t){return t[a](/^\/|\/$/,"")}function k(t){return(t||d.href)[a](r,"")}function q(t){return g[0]=="#"?(t||d.href).split(g)[1]||"":k(t)[a](g,"")}function D(t){var e=q();if(t||e!=y){w[h]("emit",e);y=e}}function L(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[u]("download")||!e[u]("href")||e.target&&e.target!="_self"||e.href.indexOf(d.href.match(r)[0])==-1)return;if(e.href!=d.href){if(e.href.split("#")[0]==d.href.split("#")[0])return;O(q(e.href),e.title||p.title)}t.preventDefault()}function O(t,e){e=e||p.title;history.pushState(null,e,g+t);p.title=e;D()}v.m=function(t,e){if(t[0]&&(!e||e[0]))O(t,e);else if(e)this.r(t,e);else this.r("@",t)};v.s=function(){this.off("*");this.$=[]};v.e=function(t){this.$.concat("@").some(function(e){var n=(e=="@"?$:x)(E(t),E(e));if(n){this[h].apply(null,[e].concat(n));return true}},this)};v.r=function(t,e){if(t!="@")this.$.push(t);this.on(t,e)};var P=new N;var R=P.m.bind(P);R.create=function(){var t=new N;t.m.stop=t.s.bind(t);return t.m.bind(t)};R.base=function(t){g=t||"#";y=q()};R.exec=function(){D(true)};R.parser=function(t,e){if(!t&&!e){$=A;x=K}if(t)$=t;if(e)x=e};R.query=function(){var t={};d.href[a](/[?&](.+?)=([^&]*)/g,function(e,n,i){t[n]=i});return t};R.stop=function(){if(b){l[o](c,D);p[o](m,L);w[h]("stop");b=false}};R.start=function(){if(!b){l[s](c,D);p[s](m,L);b=true}};R.base();R.parser();R.start();n.exports=R});
define(function(t,e,n){"use strict";var i=t("riot-observable");var r=/^.+?\/+[^\/]+/,f="EventListener",o="remove"+f,s="add"+f,u="hasAttribute",a="replace",c="popstate",h="trigger",l=window,p=document,d=l.history.location||l.location,v=N.prototype,m=p&&p.ontouchstart?"touchstart":"click",b=false,g=i(),w,y,$,x;function A(t){return t.split(/[\/?#]/)}function K(t,e){var n=new RegExp("^"+e[a](/\*/g,"([^/?#]+?)")[a](/\.\./,".*")+"$"),i=t.match(n);if(i)return i.slice(1)}function N(){this.$=[];i(this);g.on("stop",this.s.bind(this));g.on("emit",this.e.bind(this))}function E(t){return t[a](/^\/|\/$/,"")}function k(t){return(t||d.href)[a](r,"")}function q(t){return w[0]=="#"?(t||d.href).split(w)[1]||"":k(t)[a](w,"")}function D(t){var e=q();if(t||e!=y){g[h]("emit",e);y=e}}function L(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[u]("download")||!e[u]("href")||e.target&&e.target!="_self"||e.href.indexOf(d.href.match(r)[0])==-1)return;if(e.href!=d.href){if(e.href.split("#")[0]==d.href.split("#")[0])return;O(q(e.href),e.title||p.title)}t.preventDefault()}function O(t,e){e=e||p.title;history.pushState(null,e,w+t);p.title=e;D()}v.m=function(t,e){if(t[0]&&(!e||e[0]))O(t,e);else if(e)this.r(t,e);else this.r("@",t)};v.s=function(){this.off("*");this.$=[]};v.e=function(t){this.$.concat("@").some(function(e){var n=(e=="@"?$:x)(E(t),E(e));if(n){this[h].apply(null,[e].concat(n));return true}},this)};v.r=function(t,e){if(t!="@")this.$.push(t);this.on(t,e)};var P=new N;var R=P.m.bind(P);R.create=function(){var t=new N;t.m.stop=t.s.bind(t);return t.m.bind(t)};R.base=function(t){w=t||"#";y=q()};R.exec=function(){D(true)};R.parser=function(t,e){if(!t&&!e){$=A;x=K}if(t)$=t;if(e)x=e};R.query=function(){var t={};d.href[a](/[?&](.+?)=([^&]*)/g,function(e,n,i){t[n]=i});return t};R.stop=function(){if(b){l[o](c,D);p[o](m,L);g[h]("stop");b=false}};R.start=function(){if(!b){l[s](c,D);p[s](m,L);b=true}};R.base();R.parser();R.start();n.exports=R});

@@ -42,3 +42,3 @@ ;(function(riot) { if (!window) return;

function DEFAULT_SECOND_PARSER(path, filter) {
var re = new RegExp('^' + filter[REPLACE](/\*/g, '(\\w+)')[REPLACE](/\.\./, '.*') + '$'),
var re = new RegExp('^' + filter[REPLACE](/\*/g, '([^/?#]+?)')[REPLACE](/\.\./, '.*') + '$'),
args = path.match(re)

@@ -45,0 +45,0 @@

@@ -19,3 +19,11 @@ ;(function() {

var callbacks = {},
onEachEvent = function(e, fn) { e.replace(/\S+/g, fn) }
onEachEvent = function(e, fn) { e.replace(/\S+/g, fn) },
defineProperty = function (key, value) {
Object.defineProperty(el, key, {
value: value,
enumerable: false,
writable: false,
configurable: false
})
}

@@ -29,3 +37,3 @@ /**

el.on = function(events, fn) {
defineProperty('on', function(events, fn) {
if (typeof fn != 'function') return el

@@ -39,3 +47,3 @@

return el
}
})

@@ -49,3 +57,3 @@ /**

el.off = function(events, fn) {
defineProperty('off', function(events, fn) {
if (events == '*') callbacks = {}

@@ -63,3 +71,3 @@ else {

return el
}
})

@@ -73,9 +81,18 @@ /**

el.one = function(events, fn) {
defineProperty('one', function(events, fn) {
function on() {
el.off(events, on)
fn.apply(el, arguments)
// V8 performance optimization
// https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments
var arglen = arguments.length
var args = new Array(arglen)
for (var i = 0; i < arglen; i++) {
args[i] = arguments[i]
}
fn.apply(el, args)
}
return el.on(events, on)
}
})

@@ -88,8 +105,14 @@ /**

el.trigger = function(events) {
var args = [].slice.call(arguments, 1)
defineProperty('trigger', function(events) {
// V8 performance optimization
// https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments
var arglen = arguments.length - 1
var args = new Array(arglen)
for (var i = 0; i < arglen; i++) {
args[i] = arguments[i + 1] // skip first argument
}
onEachEvent(events, function(name) {
var fns = callbacks[name] || []
var fns = (callbacks[name] || []).slice(0)

@@ -99,4 +122,9 @@ for (var i = 0, fn; fn = fns[i]; ++i) {

fn.busy = 1
fn.apply(el, fn.typed ? [name].concat(args) : args)
if (fns[i] !== fn) i--
// avoid that this fn.busy gets stuck in case of errors it fixes #3
// TODO: try/catch should be removed
// https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#2-unsupported-syntax
try {
fn.apply(el, fn.typed ? [name].concat(args) : args)
} catch (e) { /* error */}
if (fns[i] !== fn) { i-- }
fn.busy = 0

@@ -111,7 +139,8 @@ }

return el
}
})
return el
}/**
}
/**
* Simple client-side router

@@ -155,3 +184,3 @@ * @module riot-route

function DEFAULT_SECOND_PARSER(path, filter) {
var re = new RegExp('^' + filter[REPLACE](/\*/g, '(\\w+)')[REPLACE](/\.\./, '.*') + '$'),
var re = new RegExp('^' + filter[REPLACE](/\*/g, '([^/?#]+?)')[REPLACE](/\.\./, '.*') + '$'),
args = path.match(re)

@@ -158,0 +187,0 @@

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

(function(){"use strict";var t=function(t){t=t||{};var n={},e=function(t,n){t.replace(/\S+/g,n)};t.on=function(i,r){if(typeof r!="function")return t;e(i,function(t,e){(n[t]=n[t]||[]).push(r);r.typed=e>0});return t};t.off=function(i,r){if(i=="*")n={};else{e(i,function(t){if(r){var e=n[t];for(var i=0,f;f=e&&e[i];++i){if(f==r)e.splice(i--,1)}}else delete n[t]})}return t};t.one=function(n,e){function i(){t.off(n,i);e.apply(t,arguments)}return t.on(n,i)};t.trigger=function(i){var r=[].slice.call(arguments,1);e(i,function(e){var i=n[e]||[];for(var f=0,o;o=i[f];++f){if(o.busy)return;o.busy=1;o.apply(t,o.typed?[e].concat(r):r);if(i[f]!==o)f--;o.busy=0}if(n.all&&e!="all")t.trigger.apply(t,["all",e].concat(r))});return t};return t};var n=/^.+?\/+[^\/]+/,e="EventListener",i="remove"+e,r="add"+e,f="hasAttribute",o="replace",u="popstate",c="trigger",a=window,s=document,l=a.history.location||a.location,h=x.prototype,p=s&&s.ontouchstart?"touchstart":"click",d=false,v=t(),y,m,g,b;function w(t){return t.split(/[\/?#]/)}function $(t,n){var e=new RegExp("^"+n[o](/\*/g,"(\\w+)")[o](/\.\./,".*")+"$"),i=t.match(e);if(i)return i.slice(1)}function x(){this.$=[];t(this);v.on("stop",this.s.bind(this));v.on("emit",this.e.bind(this))}function A(t){return t[o](/^\/|\/$/,"")}function K(t){return(t||l.href)[o](n,"")}function N(t){return y[0]=="#"?(t||l.href).split(y)[1]||"":K(t)[o](y,"")}function E(t){var n=N();if(t||n!=m){v[c]("emit",n);m=n}}function S(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[f]("download")||!e[f]("href")||e.target&&e.target!="_self"||e.href.indexOf(l.href.match(n)[0])==-1)return;if(e.href!=l.href){if(e.href.split("#")[0]==l.href.split("#")[0])return;k(N(e.href),e.title||s.title)}t.preventDefault()}function k(t,n){n=n||s.title;history.pushState(null,n,y+t);s.title=n;E()}h.m=function(t,n){if(t[0]&&(!n||n[0]))k(t,n);else if(n)this.r(t,n);else this.r("@",t)};h.s=function(){this.off("*");this.$=[]};h.e=function(t){this.$.concat("@").some(function(n){var e=(n=="@"?g:b)(A(t),A(n));if(e){this[c].apply(null,[n].concat(e));return true}},this)};h.r=function(t,n){if(t!="@")this.$.push(t);this.on(t,n)};var q=new x;var D=q.m.bind(q);D.create=function(){var t=new x;t.m.stop=t.s.bind(t);return t.m.bind(t)};D.base=function(t){y=t||"#";m=N()};D.exec=function(){E(true)};D.parser=function(t,n){if(!t&&!n){g=w;b=$}if(t)g=t;if(n)b=n};D.query=function(){var t={};l.href[o](/[?&](.+?)=([^&]*)/g,function(n,e,i){t[e]=i});return t};D.stop=function(){if(d){a[i](u,E);s[i](p,S);v[c]("stop");d=false}};D.start=function(){if(!d){a[r](u,E);s[r](p,S);d=true}};D.base();D.parser();D.start();window.route=D})();
(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);var i=arguments.length;var f=new Array(i);for(var o=0;o<i;o++){f[o]=arguments[o]}n.apply(t,f)}return t.on(e,r)});r("trigger",function(r){var i=arguments.length-1;var f=new Array(i);for(var o=0;o<i;o++){f[o]=arguments[o+1]}n(r,function(n){var r=(e[n]||[]).slice(0);for(var i=0,o;o=r[i];++i){if(o.busy)return;o.busy=1;try{o.apply(t,o.typed?[n].concat(f):f)}catch(u){}if(r[i]!==o){i--}o.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",o="replace",u="popstate",a="trigger",c=window,s=document,l=c.history.location||c.location,h=A.prototype,p=s&&s.ontouchstart?"touchstart":"click",v=false,d=t(),y,g,m,b;function w(t){return t.split(/[\/?#]/)}function $(t,e){var n=new RegExp("^"+e[o](/\*/g,"([^/?#]+?)")[o](/\.\./,".*")+"$"),r=t.match(n);if(r)return r.slice(1)}function A(){this.$=[];t(this);d.on("stop",this.s.bind(this));d.on("emit",this.e.bind(this))}function x(t){return t[o](/^\/|\/$/,"")}function K(t){return(t||l.href)[o](e,"")}function N(t){return y[0]=="#"?(t||l.href).split(y)[1]||"":K(t)[o](y,"")}function E(t){var e=N();if(t||e!=g){d[a]("emit",e);g=e}}function O(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(l.href.match(e)[0])==-1)return;if(n.href!=l.href){if(n.href.split("#")[0]==l.href.split("#")[0])return;P(N(n.href),n.title||s.title)}t.preventDefault()}function P(t,e){e=e||s.title;history.pushState(null,e,y+t);s.title=e;E()}h.m=function(t,e){if(t[0]&&(!e||e[0]))P(t,e);else if(e)this.r(t,e);else this.r("@",t)};h.s=function(){this.off("*");this.$=[]};h.e=function(t){this.$.concat("@").some(function(e){var n=(e=="@"?m:b)(x(t),x(e));if(n){this[a].apply(null,[e].concat(n));return true}},this)};h.r=function(t,e){if(t!="@")this.$.push(t);this.on(t,e)};var S=new A;var j=S.m.bind(S);j.create=function(){var t=new A;t.m.stop=t.s.bind(t);return t.m.bind(t)};j.base=function(t){y=t||"#";g=N()};j.exec=function(){E(true)};j.parser=function(t,e){if(!t&&!e){m=w;b=$}if(t)m=t;if(e)b=e};j.query=function(){var t={};l.href[o](/[?&](.+?)=([^&]*)/g,function(e,n,r){t[n]=r});return t};j.stop=function(){if(v){c[r](u,E);s[r](p,O);d[a]("stop");v=false}};j.start=function(){if(!v){c[i](u,E);s[i](p,O);v=true}};j.base();j.parser();j.start();window.route=j})();

@@ -93,3 +93,3 @@ # Router API

- `*`: `(\w+)`
- `*`: `([^/?#]+?)`
- `..`: `.*`

@@ -250,3 +250,3 @@

function second(path, filter) {
var re = new RegExp('^' + filter.replace(/\*/g, '(\\w+)').replace(/\.\./, '.*') + '$')
var re = new RegExp('^' + filter.replace(/\*/g, '([^/?#]+?)').replace(/\.\./, '.*') + '$')
if (args = path.match(re)) return args.slice(1)

@@ -253,0 +253,0 @@ }

@@ -41,3 +41,3 @@ /**

function DEFAULT_SECOND_PARSER(path, filter) {
var re = new RegExp('^' + filter[REPLACE](/\*/g, '(\\w+)')[REPLACE](/\.\./, '.*') + '$'),
var re = new RegExp('^' + filter[REPLACE](/\*/g, '([^/?#]+?)')[REPLACE](/\.\./, '.*') + '$'),
args = path.match(re)

@@ -44,0 +44,0 @@

{
"name": "riot-route",
"version": "2.3.0-beta.3",
"version": "2.3.0-beta.4",
"description": "Simple client-side router",

@@ -23,15 +23,15 @@ "main": "lib/index.js",

"dependencies": {
"riot-observable": "^2.0.0-beta.2"
"riot-observable": "^2.3.0-beta.4"
},
"devDependencies": {
"chokidar-cli": "^1.0.1",
"chokidar-cli": "^1.1.1",
"coveralls": "^2.11.4",
"eslint": "^1.4.1",
"eslint": "^1.8.0",
"expect.js": "^0.3.1",
"karma": "^0.13.9",
"karma-coverage": "^0.5.2",
"karma": "^0.13.14",
"karma-coverage": "^0.5.3",
"karma-mocha": "^0.2.0",
"karma-mocha-reporter": "^1.1.1",
"karma-phantomjs-launcher": "^0.2.1",
"uglify-js": "latest"
"uglify-js": "^2.5.0"
},

@@ -38,0 +38,0 @@ "author": "Muut, Inc. and other contributors",

@@ -32,2 +32,3 @@ function fireEvent(node, eventName) {

'<a class="tag-h" href="/fruit/apple">H</a>' +
'<a class="tag-h2" href="/fruit/red-apple">H2</a>' +
'<a class="tag-i" href="/fruit/orange">I</a>' +

@@ -163,9 +164,13 @@ '<a class="tag-j" href="/search?keyword=test&limit=30">J</a>' +

counter++
expect(first).to.be('apple')
expect(['apple', 'red-apple']).to.contain(first)
})
route('fruit')
route('fruit/apple')
route('fruit/red-apple') // see issue #20
fireEvent($('.tag-g'), 'click')
fireEvent($('.tag-h'), 'click')
expect(counter).to.be(2)
fireEvent($('.tag-h2'), 'click') // see issue #20
expect(counter).to.be(4)
})

@@ -172,0 +177,0 @@

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