Socket
Socket
Sign inDemoInstall

dom-router

Package Overview
Dependencies
0
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.1.2 to 5.1.3

4

dist/dom-router.cjs.js

@@ -6,3 +6,3 @@ /**

* @license BSD-3-Clause
* @version 5.1.2
* @version 5.1.3
*/

@@ -171,3 +171,3 @@ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});const cssCurrent = "dr-current";

if (url.hash !== arg) {
if (url.hash.replace("#", "") !== arg) {
url.hash = arg;

@@ -174,0 +174,0 @@ history.pushState({}, "", url.href);

@@ -6,3 +6,3 @@ /**

* @license BSD-3-Clause
* @version 5.1.2
* @version 5.1.3
*/

@@ -171,3 +171,3 @@ const cssCurrent = "dr-current";

if (url.hash !== arg) {
if (url.hash.replace("#", "") !== arg) {
url.hash = arg;

@@ -174,0 +174,0 @@ history.pushState({}, "", url.href);

/*!
2022 Jason Mulligan <jason.mulligan@avoidwork.com>
@version 5.1.2
@version 5.1.3
*/
const t=/.*#/,s=window.requestAnimationFrame;class e{constructor(t){this.hash=t.hash,this.element=t.element,this.trigger=t.trigger,this.timestamp=(new Date).toISOString()}}class i{constructor({active:t=!0,callback:s=function(){},css:e={current:"dr-current",hidden:"dr-hidden"},ctx:i=document.body,start:r=null,delimiter:h="/",logging:o=!1,stickyPos:n=!0,stickyRoute:c=!0,stickySearchParams:a=!1,stop:l=!0,storage:d="session",storageKey:u="lastRoute"}={}){this.active=t,this.callback=s,this.css=e,this.ctx=i,this.delimiter=h,this.history=[],this.logging=o,this.routes=[],this.stickyPos=n,this.stickyRoute=c,this.stickySearchParams=a,this.storage="session"===d?sessionStorage:localStorage,this.storageKey=u,this.stop=l,this.start=this.stickyRoute&&this.storage.getItem(this.storageKey)||r}current(){return this.history[this.history.length-1]}handler(){const i=this.history.length>0&&(this.current().hash||"").replace(t,"")||null,r=location.hash.includes("#")?location.hash.replace(t,""):null;if(this.active&&this.valid(r))if(this.routes.includes(r)){const t=document.body.scrollTop,h=i?i.split(this.delimiter):[],o=r.split(this.delimiter),n=[];let c="";for(const t of h)c+=`${c.length>0?`${this.delimiter}`:""}${t}`,n.push(...this.select(`a[href="#${c}"]`));s((()=>{let s,i;for(const t of n)t.classList.remove(this.css.current);for(const t of o.keys()){const e=t+1,r=h.length>=e,n=r?this.select(`#${h.slice(0,e).join(" #")}`):void 0,c=r?this.select(`a[href='#${h.slice(0,e).join(this.delimiter)}']`):void 0;s=this.select(`#${o.slice(0,e).join(" #")}`),i=this.select(`a[href='#${o.slice(0,e).join(this.delimiter)}']`),this.load(c,n,i,s)}this.stickyRoute&&this.storage.setItem(this.storageKey,r),this.stickyPos&&(document.body.scrollTop=t);const c=function(t={element:null,hash:"",trigger:null}){return new e(t)}({element:s,hash:r,trigger:i});if(!this.stickySearchParams){const t=new URL(location.href);for(const s of t.searchParams.keys())t.searchParams.delete(s);history.replaceState({},"",t.href)}this.log(c),this.callback(c)}))}else this.route(this.routes.filter((t=>t.includes(r)))[0]||this.start);return this}load(t=[],s=[],e=[],i=[]){for(const s of t)s.classList.remove(this.css.current);for(const[t,e]of s.entries())e.id!==i[t]?.id&&e.classList.add(this.css.hidden);for(const t of e)t.classList.add(this.css.current);for(const t of i)this.sweep(t,this.css.hidden);return this}log(t){return this.history.push(this.logging?t:{hash:t.hash}),this}popstate(t){return this.handler(t),this}process(){const t=document.location.hash.replace("#","");this.scan(this.start),this.ctx.classList.contains(this.css.hidden)||(t.length>0&&this.routes.includes(t)?this.handler():this.route(this.start))}route(t=""){const s=new URL(location.href);return s.hash!==t&&(s.hash=t,history.pushState({},"",s.href),this.handler()),this}select(t){return Array.from(this.ctx.querySelectorAll.call(this.ctx,t)).filter((t=>null!==t))}scan(s=""){const e=null===s?"":s;return this.routes=Array.from(new Set(this.select("a[href^='#']").map((s=>s.href.replace(t,""))).filter((t=>""!==t)))),e.length>0&&!this.routes.includes(e)&&this.routes.push(e),this.start=e||this.routes[0]||null,this}sweep(t,e){return s((()=>{Array.from(t.parentNode.childNodes).filter((s=>1===s.nodeType&&s.id&&s.id!==t.id)).forEach((t=>t.classList.add(e))),t.classList.remove(e)})),this}valid(t=""){return""===t||!1===/=/.test(t)}}function r(t){const s=new i(t);return s.popstate=s.popstate.bind(s),"addEventListener"in window?window.addEventListener("popstate",s.popstate,!1):window.onpopstate=s.popstate,s.active&&s.process(),s}export{r as router};//# sourceMappingURL=dom-router.esm.min.js.map
const t=/.*#/,s=window.requestAnimationFrame;class e{constructor(t){this.hash=t.hash,this.element=t.element,this.trigger=t.trigger,this.timestamp=(new Date).toISOString()}}class i{constructor({active:t=!0,callback:s=function(){},css:e={current:"dr-current",hidden:"dr-hidden"},ctx:i=document.body,start:r=null,delimiter:h="/",logging:o=!1,stickyPos:n=!0,stickyRoute:c=!0,stickySearchParams:a=!1,stop:l=!0,storage:d="session",storageKey:u="lastRoute"}={}){this.active=t,this.callback=s,this.css=e,this.ctx=i,this.delimiter=h,this.history=[],this.logging=o,this.routes=[],this.stickyPos=n,this.stickyRoute=c,this.stickySearchParams=a,this.storage="session"===d?sessionStorage:localStorage,this.storageKey=u,this.stop=l,this.start=this.stickyRoute&&this.storage.getItem(this.storageKey)||r}current(){return this.history[this.history.length-1]}handler(){const i=this.history.length>0&&(this.current().hash||"").replace(t,"")||null,r=location.hash.includes("#")?location.hash.replace(t,""):null;if(this.active&&this.valid(r))if(this.routes.includes(r)){const t=document.body.scrollTop,h=i?i.split(this.delimiter):[],o=r.split(this.delimiter),n=[];let c="";for(const t of h)c+=`${c.length>0?`${this.delimiter}`:""}${t}`,n.push(...this.select(`a[href="#${c}"]`));s((()=>{let s,i;for(const t of n)t.classList.remove(this.css.current);for(const t of o.keys()){const e=t+1,r=h.length>=e,n=r?this.select(`#${h.slice(0,e).join(" #")}`):void 0,c=r?this.select(`a[href='#${h.slice(0,e).join(this.delimiter)}']`):void 0;s=this.select(`#${o.slice(0,e).join(" #")}`),i=this.select(`a[href='#${o.slice(0,e).join(this.delimiter)}']`),this.load(c,n,i,s)}this.stickyRoute&&this.storage.setItem(this.storageKey,r),this.stickyPos&&(document.body.scrollTop=t);const c=function(t={element:null,hash:"",trigger:null}){return new e(t)}({element:s,hash:r,trigger:i});if(!this.stickySearchParams){const t=new URL(location.href);for(const s of t.searchParams.keys())t.searchParams.delete(s);history.replaceState({},"",t.href)}this.log(c),this.callback(c)}))}else this.route(this.routes.filter((t=>t.includes(r)))[0]||this.start);return this}load(t=[],s=[],e=[],i=[]){for(const s of t)s.classList.remove(this.css.current);for(const[t,e]of s.entries())e.id!==i[t]?.id&&e.classList.add(this.css.hidden);for(const t of e)t.classList.add(this.css.current);for(const t of i)this.sweep(t,this.css.hidden);return this}log(t){return this.history.push(this.logging?t:{hash:t.hash}),this}popstate(t){return this.handler(t),this}process(){const t=document.location.hash.replace("#","");this.scan(this.start),this.ctx.classList.contains(this.css.hidden)||(t.length>0&&this.routes.includes(t)?this.handler():this.route(this.start))}route(t=""){const s=new URL(location.href);return s.hash.replace("#","")!==t&&(s.hash=t,history.pushState({},"",s.href),this.handler()),this}select(t){return Array.from(this.ctx.querySelectorAll.call(this.ctx,t)).filter((t=>null!==t))}scan(s=""){const e=null===s?"":s;return this.routes=Array.from(new Set(this.select("a[href^='#']").map((s=>s.href.replace(t,""))).filter((t=>""!==t)))),e.length>0&&!this.routes.includes(e)&&this.routes.push(e),this.start=e||this.routes[0]||null,this}sweep(t,e){return s((()=>{Array.from(t.parentNode.childNodes).filter((s=>1===s.nodeType&&s.id&&s.id!==t.id)).forEach((t=>t.classList.add(e))),t.classList.remove(e)})),this}valid(t=""){return""===t||!1===/=/.test(t)}}function r(t){const s=new i(t);return s.popstate=s.popstate.bind(s),"addEventListener"in window?window.addEventListener("popstate",s.popstate,!1):window.onpopstate=s.popstate,s.active&&s.process(),s}export{r as router};//# sourceMappingURL=dom-router.esm.min.js.map

@@ -6,3 +6,3 @@ /**

* @license BSD-3-Clause
* @version 5.1.2
* @version 5.1.3
*/

@@ -171,3 +171,3 @@ (function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports):typeof define==='function'&&define.amd?define(['exports'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(g.domRouter={}));})(this,(function(exports){'use strict';const cssCurrent = "dr-current";

if (url.hash !== arg) {
if (url.hash.replace("#", "") !== arg) {
url.hash = arg;

@@ -174,0 +174,0 @@ history.pushState({}, "", url.href);

/*!
2022 Jason Mulligan <jason.mulligan@avoidwork.com>
@version 5.1.2
@version 5.1.3
*/
!function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports):"function"==typeof define&&define.amd?define(["exports"],s):s((t="undefined"!=typeof globalThis?globalThis:t||self).domRouter={})}(this,(function(t){"use strict";const s="",e=/.*#/,i=window.requestAnimationFrame;class r{constructor(t){this.hash=t.hash,this.element=t.element,this.trigger=t.trigger,this.timestamp=(new Date).toISOString()}}class o{constructor({active:t=!0,callback:s=function(){},css:e={current:"dr-current",hidden:"dr-hidden"},ctx:i=document.body,start:r=null,delimiter:o="/",logging:h=!1,stickyPos:n=!0,stickyRoute:c=!0,stickySearchParams:a=!1,stop:l=!0,storage:d="session",storageKey:u="lastRoute"}={}){this.active=t,this.callback=s,this.css=e,this.ctx=i,this.delimiter=o,this.history=[],this.logging=h,this.routes=[],this.stickyPos=n,this.stickyRoute=c,this.stickySearchParams=a,this.storage="session"===d?sessionStorage:localStorage,this.storageKey=u,this.stop=l,this.start=this.stickyRoute&&this.storage.getItem(this.storageKey)||r}current(){return this.history[this.history.length-1]}handler(){const t=this.history.length>0&&(this.current().hash||s).replace(e,s)||null,o=location.hash.includes("#")?location.hash.replace(e,s):null;if(this.active&&this.valid(o))if(this.routes.includes(o)){const e=document.body.scrollTop,h=t?t.split(this.delimiter):[],n=o.split(this.delimiter),c=[];let a=s;for(const t of h)a+=`${a.length>0?`${this.delimiter}`:s}${t}`,c.push(...this.select(`a[href="#${a}"]`));i((()=>{let t,s;for(const t of c)t.classList.remove(this.css.current);for(const e of n.keys()){const i=e+1,r=h.length>=i,o=r?this.select(`#${h.slice(0,i).join(" #")}`):void 0,c=r?this.select(`a[href='#${h.slice(0,i).join(this.delimiter)}']`):void 0;t=this.select(`#${n.slice(0,i).join(" #")}`),s=this.select(`a[href='#${n.slice(0,i).join(this.delimiter)}']`),this.load(c,o,s,t)}this.stickyRoute&&this.storage.setItem(this.storageKey,o),this.stickyPos&&(document.body.scrollTop=e);const i=function(t={element:null,hash:"",trigger:null}){return new r(t)}({element:t,hash:o,trigger:s});if(!this.stickySearchParams){const t=new URL(location.href);for(const s of t.searchParams.keys())t.searchParams.delete(s);history.replaceState({},"",t.href)}this.log(i),this.callback(i)}))}else this.route(this.routes.filter((t=>t.includes(o)))[0]||this.start);return this}load(t=[],s=[],e=[],i=[]){for(const s of t)s.classList.remove(this.css.current);for(const[t,e]of s.entries())e.id!==i[t]?.id&&e.classList.add(this.css.hidden);for(const t of e)t.classList.add(this.css.current);for(const t of i)this.sweep(t,this.css.hidden);return this}log(t){return this.history.push(this.logging?t:{hash:t.hash}),this}popstate(t){return this.handler(t),this}process(){const t=document.location.hash.replace("#",s);this.scan(this.start),this.ctx.classList.contains(this.css.hidden)||(t.length>0&&this.routes.includes(t)?this.handler():this.route(this.start))}route(t=""){const s=new URL(location.href);return s.hash!==t&&(s.hash=t,history.pushState({},"",s.href),this.handler()),this}select(t){return Array.from(this.ctx.querySelectorAll.call(this.ctx,t)).filter((t=>null!==t))}scan(t=""){const i=null===t?s:t;return this.routes=Array.from(new Set(this.select("a[href^='#']").map((t=>t.href.replace(e,s))).filter((t=>t!==s)))),i.length>0&&!this.routes.includes(i)&&this.routes.push(i),this.start=i||this.routes[0]||null,this}sweep(t,s){return i((()=>{Array.from(t.parentNode.childNodes).filter((s=>1===s.nodeType&&s.id&&s.id!==t.id)).forEach((t=>t.classList.add(s))),t.classList.remove(s)})),this}valid(t=""){return t===s||!1===/=/.test(t)}}t.router=function(t){const s=new o(t);return s.popstate=s.popstate.bind(s),"addEventListener"in window?window.addEventListener("popstate",s.popstate,!1):window.onpopstate=s.popstate,s.active&&s.process(),s},Object.defineProperty(t,"__esModule",{value:!0})}));//# sourceMappingURL=dom-router.min.js.map
!function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports):"function"==typeof define&&define.amd?define(["exports"],s):s((t="undefined"!=typeof globalThis?globalThis:t||self).domRouter={})}(this,(function(t){"use strict";const s="",e=/.*#/,i=window.requestAnimationFrame;class r{constructor(t){this.hash=t.hash,this.element=t.element,this.trigger=t.trigger,this.timestamp=(new Date).toISOString()}}class o{constructor({active:t=!0,callback:s=function(){},css:e={current:"dr-current",hidden:"dr-hidden"},ctx:i=document.body,start:r=null,delimiter:o="/",logging:h=!1,stickyPos:n=!0,stickyRoute:c=!0,stickySearchParams:a=!1,stop:l=!0,storage:d="session",storageKey:u="lastRoute"}={}){this.active=t,this.callback=s,this.css=e,this.ctx=i,this.delimiter=o,this.history=[],this.logging=h,this.routes=[],this.stickyPos=n,this.stickyRoute=c,this.stickySearchParams=a,this.storage="session"===d?sessionStorage:localStorage,this.storageKey=u,this.stop=l,this.start=this.stickyRoute&&this.storage.getItem(this.storageKey)||r}current(){return this.history[this.history.length-1]}handler(){const t=this.history.length>0&&(this.current().hash||s).replace(e,s)||null,o=location.hash.includes("#")?location.hash.replace(e,s):null;if(this.active&&this.valid(o))if(this.routes.includes(o)){const e=document.body.scrollTop,h=t?t.split(this.delimiter):[],n=o.split(this.delimiter),c=[];let a=s;for(const t of h)a+=`${a.length>0?`${this.delimiter}`:s}${t}`,c.push(...this.select(`a[href="#${a}"]`));i((()=>{let t,s;for(const t of c)t.classList.remove(this.css.current);for(const e of n.keys()){const i=e+1,r=h.length>=i,o=r?this.select(`#${h.slice(0,i).join(" #")}`):void 0,c=r?this.select(`a[href='#${h.slice(0,i).join(this.delimiter)}']`):void 0;t=this.select(`#${n.slice(0,i).join(" #")}`),s=this.select(`a[href='#${n.slice(0,i).join(this.delimiter)}']`),this.load(c,o,s,t)}this.stickyRoute&&this.storage.setItem(this.storageKey,o),this.stickyPos&&(document.body.scrollTop=e);const i=function(t={element:null,hash:"",trigger:null}){return new r(t)}({element:t,hash:o,trigger:s});if(!this.stickySearchParams){const t=new URL(location.href);for(const s of t.searchParams.keys())t.searchParams.delete(s);history.replaceState({},"",t.href)}this.log(i),this.callback(i)}))}else this.route(this.routes.filter((t=>t.includes(o)))[0]||this.start);return this}load(t=[],s=[],e=[],i=[]){for(const s of t)s.classList.remove(this.css.current);for(const[t,e]of s.entries())e.id!==i[t]?.id&&e.classList.add(this.css.hidden);for(const t of e)t.classList.add(this.css.current);for(const t of i)this.sweep(t,this.css.hidden);return this}log(t){return this.history.push(this.logging?t:{hash:t.hash}),this}popstate(t){return this.handler(t),this}process(){const t=document.location.hash.replace("#",s);this.scan(this.start),this.ctx.classList.contains(this.css.hidden)||(t.length>0&&this.routes.includes(t)?this.handler():this.route(this.start))}route(t=""){const s=new URL(location.href);return s.hash.replace("#","")!==t&&(s.hash=t,history.pushState({},"",s.href),this.handler()),this}select(t){return Array.from(this.ctx.querySelectorAll.call(this.ctx,t)).filter((t=>null!==t))}scan(t=""){const i=null===t?s:t;return this.routes=Array.from(new Set(this.select("a[href^='#']").map((t=>t.href.replace(e,s))).filter((t=>t!==s)))),i.length>0&&!this.routes.includes(i)&&this.routes.push(i),this.start=i||this.routes[0]||null,this}sweep(t,s){return i((()=>{Array.from(t.parentNode.childNodes).filter((s=>1===s.nodeType&&s.id&&s.id!==t.id)).forEach((t=>t.classList.add(s))),t.classList.remove(s)})),this}valid(t=""){return t===s||!1===/=/.test(t)}}t.router=function(t){const s=new o(t);return s.popstate=s.popstate.bind(s),"addEventListener"in window?window.addEventListener("popstate",s.popstate,!1):window.onpopstate=s.popstate,s.active&&s.process(),s},Object.defineProperty(t,"__esModule",{value:!0})}));//# sourceMappingURL=dom-router.min.js.map
{
"name": "dom-router",
"description": "URL hash DOM router",
"version": "5.1.2",
"version": "5.1.3",
"homepage": "https://github.com/avoidwork/dom-router",

@@ -6,0 +6,0 @@ "author": "Jason Mulligan <jason.mulligan@avoidwork.com>",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc