Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

domvm

Package Overview
Dependencies
Maintainers
2
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

domvm - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

demos/ModalStack/ModalStack.css

24

demos/ModalStack/ModalStack.js
function ModalStack(ctnr, opts) {
this.opts = opts || {};
this.stack = [];

@@ -29,2 +31,11 @@

function ModalStackView(vm, mod) {
var opts = mod.opts;
if (opts.popOnEsc) {
document.addEventListener("keyup", function(e) {
if (e.keyCode == 27)
mod.pop();
});
}
function genProps(handle, cache) {

@@ -83,2 +94,7 @@ var push = handle.onpush;

function popOne(e) {
mod.pop();
return false;
}
function modalTpl(i, stack) {

@@ -88,4 +104,8 @@ var modal = stack[i];

return ["aside.modal.modal-overlay", genProps(modal.overlay, oProps),
["section.modal-content", genProps(modal.content, cProps),
// requires overlay.onpush.initial to exist
if (opts.popOnClick)
modal.overlay.onpush.initial.onclick = {".dvm-modal-overlay": popOne};
return ["aside.dvm-modal-overlay", genProps(modal.overlay, oProps),
["section.dvm-modal-content", genProps(modal.content, cProps),
modal.content.body,

@@ -92,0 +112,0 @@ isLast ? null : modalTpl(i + 1, stack),

66

dist/domvm.min.js
/*
https://github.com/leeoniya/domvm (1.2.1)
https://github.com/leeoniya/domvm (1.2.2)
*/
("undefined"!==typeof global?global:this).domvm={};(function(w){var t=("undefined"==typeof window?{}:window).requestAnimationFrame,u={animationIterationCount:!0,boxFlex:!0,boxFlexGroup:!0,columnCount:!0,counterIncrement:!0,fillOpacity:!0,flex:!0,flexGrow:!0,flexOrder:!0,flexPositive:!0,flexShrink:!0,"float":!0,fontWeight:!0,gridColumn:!0,lineHeight:!0,lineClamp:!0,opacity:!0,order:!0,orphans:!0,stopOpacity:!0,strokeDashoffset:!0,strokeOpacity:!0,strokeWidth:!0,tabSize:!0,transform:!0,transformOrigin:!0,widows:!0,zIndex:!0,zoom:!0},n={TYPE_ELEM:1,
TYPE_TEXT:2,isArr:function(c){return c instanceof Array},isVal:function(c){c=typeof c;return"string"===c||"number"===c},isObj:function(c){return"object"===typeof c&&null!==c&&!n.isArr(c)},isFunc:function(c){return"function"===typeof c},isProm:function(c){return"object"===typeof c&&n.isFunc(c.then)},isElem:function(c){return c instanceof HTMLElement},execAll:function(c,f,g,a,h,x){var q;c&&(n.isArr(c)?c:[c]).forEach(function(c){q=c.call(null,f,g,a,h,x)});return q},tick:function(c,f){f&&t?t&&t(function(){n.tick(c,
f-1)}):n.isArr(c)?c[0].apply(null,c.slice(1)):c()},insertArr:function(c,f,g,a){c.splice.apply(c,[g,a].concat(f))},isEvProp:function(c){return"on"===c.substr(0,2)},isDynProp:function(c,f){switch(c){case "input":case "textarea":case "select":case "option":switch(f){case "value":case "checked":case "selected":case "selectedIndex":return!0}}},camelDash:function(c){return c.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},autoPx:function(c,f){return isNaN(f)||u[c]?f:f+"px"},cmpArr:function(c,f){var g=
c.length;if(g!=f.length)return!1;for(;g--;)if(c[g]!==f[g])return!1;return!0},deepSet:function(c,f,g,a,h,x){f=f.split(".");var q=f.pop();f.forEach(function(a){c[a]||(c[a]={});c=c[a]});if(n.isFunc(c[q]))c[q](g,a,h,x);else c[q]=g},deepGet:function(c,f){var g=f.split(".");do c=c[g.shift()];while(g.length);return c},keyedIdx:function(c,f,g,a,h){for(a=0;a<f.length;a++)if(h=f[a],h.key===c)if(g){if(h.vm&&h.vm.view[0]===g)return a}else return a;return-1},raft:function(c){function f(){g=0;c.apply(a,h)}if(!t)return c;
var g,a,h;return function(){a=this;h=arguments;g||(g=t(f))}}};w.utils=n})(domvm);(function(w){function t(){for(var b;b=K.pop();)b[0].apply(null,b.slice(1))}function u(b,k){return!1===k?null:null==k&&null!=b?b:m.isVal(k)||m.isObj(k)||m.isArr(k)||m.isFunc(k)?k:null}function n(b,k,p,a,y,e){function l(b,k,e){if(e)b[k]=b[k]||[],b[k].push(e);else for(var p in k)b[p]=b[p]||[],b[p].push(k[p])}function d(b,k,p){y=b;e=k;r.update(p,!1);null!=r.node&&(y.body[e]=r.node);return n(0,!1)}function x(b){return null==b?"":b}function n(b,c){if(b){for(var a=r;b--&&a.parent;)a=a.parent;a.redraw(0,
!0);return a.vm}(a=r.node)&&f(r,"willRedraw",r);var C=r.refs;r.refs={};var l=r.render.call(r.api,r,k,p),d;if(!1===l||(d=h(l,y,e,r,!0))&&z(a,d))return a.moved=!0,a.wasSame=!0,r.refs=C,r;d.vm=r;r.node=d;C=m.isVal(p)&&"^"===p[0]?p.substr(1):m.isVal(d.ref)&&"^"===d.ref[0]?d.ref.substr(1):null;d.key=null!=p?p:d.key;for(l=y;l;)l.vm&&(r.parent||(r.parent=l.vm),null!==C&&m.deepSet(l.vm.refs,C,d)),l=l.parent;if((C=a)&&(d.type!==a.type||d.tag!==a.tag))var C=null,x=!0,L=a.el.parentNode;q(d,C);y&&(y.body[e]=
d);!1!==c&&(a&&g(a),!a&&A||v(d,null,d.el),x&&(L||d.parent.el).insertBefore(d.el,L.childNodes[a.idx]));a&&f(r,"didRedraw",r);!1!==c&&m.tick(t,2);return r}var A=!y;m.isArr(b)&&(k=b[1],p=b[2],a=b[3],b=b[0]);p=u(k,p);var r={api:{},node:null,view:[b,p],model:k,opts:a||{},render:null,update:function(b,e){null==b||p===k&&!m.isVal(p)||(k=r.model=b);return!1!==e?n(0):r},on:function(b,k){l(r.events,b,k)},hook:function(b,k){r.hooks=r.hooks||{};l(r.hooks,b,k)},events:{},hooks:null,redraw:G.useRaf?m.raft(n):n,
patch:function(b,k){var e=null!=b.el;if(m.isObj(k)){var p="class"in k?(x(b["class"])+" "+x(k["class"])).trim():b.props["class"],a="style"in k?k.style:b.props.style;e&&(e=Object.create(b.props),e["class"]=p,e.style=a,e={tag:b.tag,el:b.el,ns:b.ns,props:e},D(e,b));b.props["class"]=p;b.props.style=a}else p=b.parent,e=q(h(k,p,b.idx,r),b),p.body[b.idx]=e},emit:function(b){for(var k=Array.prototype.slice.call(arguments),e=r,p;e;){if(p=e.events[b]){k[0]=p;m.execAll.apply(null,k);break}e=e.parent}},refs:{},
parent:null,mount:function(b,k){var e=null;k&&(b.textContent="",e=b,b=null);v(r.node,e,null,b);return r},attach:function(b){c(r.node,b);return r},unmount:function(){g(r.node)},moveTo:d,updIdx:function(b){e=b}};a&&a.hooks&&r.hook(a.hooks);m.execAll(F,r);r.render=b.call(r.api,r,k,p);return y?d(y,e):n(0)}function c(b,k){b.el=k;k._node=b;for(var p in b.props){var a=b.props[p],y=m.isEvProp(p)?p:"."===p[0]?p.substr(1):null;null!==y&&(k[y]=a)}if(m.isArr(b.body))for(p=0;p<b.body.length;p++)c(b.body[p],k.childNodes[p])}
function f(b,k,p,a,c,e){if(b&&b.hooks&&(b=b.hooks[k]))if(G.useRaf&&"did"==k.substr(0,3))K.push([m.execAll,b,p,a,c,e]);else return m.execAll(b,p,a,c,e)}function g(b,k){var p=b.el&&!b.moved;if(p){var c=f(b.vm,"willUnmount",b.vm),y=f(b,"willRemove",b),e=c||y;b.removed=!0}b.wasSame?b.wasSame=!1:(m.isArr(b.body)&&b.body.forEach(function(b,p){g(b,k||e)}),k||(e?e.then(function(){a(b,p)}):a(b,p)));b.moved=!1}function a(b,k){null!=b.el&&b.el.parentNode&&(k&&(b.el.parentNode.removeChild(b.el),b.el=null,f(b.vm,
"didUnmount",b.vm),f(b,"didRemove",b)),m.isArr(b.body)&&b.body.forEach(function(b,k){a(b,!b.moved)}))}function h(b,k,p,a,c){var e=b;b={type:null,key:null,ref:null,idx:null,parent:null,moved:!1,wasSame:!1,removed:!1,hooks:null,tag:null,"class":null,ns:null,guard:!1,raw:!1,props:null,el:null,hasKeys:!1,body:null};m.isFunc(e)&&(e=e());var d=e.length;if(m.isArr(e)&&d){b.type=m.TYPE_ELEM;if(1<d){var l=1;m.isObj(e[1])&&!m.isElem(e[1])&&(b.props=e[1],l=2);b.body=d==l+1?m.isVal(e[l])?e[l]:m.isFunc(e[l])?
e[l]():e.slice(l):e.slice(l)}e=e[0];d=M[e];d||(d=["",""],d={tag:(e.match(/^[-\w]+/)||["div"])[0],id:(e.match(/#([-\w]+)/)||d)[1],"class":(e.match(/\.([-\w.]+)/)||d)[1].replace(/\./g," ")},M[e]=d);b.tag=d.tag;if(d.id||d["class"])e=b.props||{},d.id&&null==e.id&&(e.id=d.id),d["class"]&&(b["class"]=d["class"],e["class"]=d["class"]+(null!=e["class"]?" "+e["class"]:"")),b.props=e;if(b.props){var e=b.props,h;for(h in e)!m.isEvProp(h)&&m.isFunc(e[h])&&("href"==h?(e.onclick=e[h],e.href=e[h].href):e[h]=e[h]()),
m.isDynProp(b.tag,h)&&(e["."+h]=e[h]);if(m.isObj(e.style))for(var f in e.style)h=e.style[f],m.isFunc(h)&&(e.style[f]=h());m.isObj(e._hooks)&&(b.hooks=e._hooks,e._hooks=null);b.key=m.isVal(e._key)?e._key:m.isVal(e._ref)?e._ref:m.isVal(e.id)?e.id:m.isVal(e.name)?e.name:null;null!=e._ref&&(b.ref=e._ref);e._raw&&(b.raw=!0);null!=e._data&&(b.data=e._data);e._diff&&(b.diff=e._diff);e._ref=e._key=e._raw=e._data=e._diff=null}}else m.isVal(e)?(b.type=m.TYPE_TEXT,b.body=e):m.isElem(e)&&(b.type=m.TYPE_ELEM,
b.el=e,b.tag=e.nodeName.toLowerCase());null!==b.ref&&m.deepSet(a.refs,b.ref,b);b.parent=k;b.idx=p;b.ns=k&&k.ns?k.ns:"svg"===b.tag||"math"===b.tag?b.tag:null;c||b.diff||!m.isArr(b.body)||x(b,a);return b}function x(b,k){for(var a=0,c=b.body.length;a<c;a++){var d=b.body[a],e=null,l=null,f=!1,x=!1;m.isFunc(d)&&(d=d());if(null==d)f=!0;else{var g=m.isArr(d),q=g?!1:m.isObj(d);if(g)d.length?"string"==typeof d[0]&&""!==d[0]?(l=h(d,b,a,k),e=l.key):m.isFunc(d[0])?e=u(d[1],d[2]):x=!0:f=!0;else if(q)if(m.isFunc(d.redraw))d.moveTo(b,
a),l=d.node,e=d.view[1];else if(m.isElem(d))l=h(d,b,a,k);else{b.body[a--]=""+d;continue}else""===d?f=!0:0<a&&b.body[a-1].type===m.TYPE_TEXT?(b.body[a-1].body+=""+d,f=!0):l=h(""+d,b,a,k)}f||x?(x?m.insertArr(b.body,d,a,1):b.body.splice(a,1),c=b.body.length,a--):(null!==e&&(b.hasKeys=!0),b.body[a]=l||d)}b.body._init=!0}function q(b,k){if(z(k,b))return k.moved=!0,k.wasSame=!0,k;k&&(f(b,"willRecycle",k,b),d(k,b),f(b,"didRecycle",k,b));if(m.isArr(b.body)){if(!b.body._init){for(var a=b;!a.vm;)a=a.parent;
x(b,a.vm)}var c=0;b.body.forEach(function(a,e){var d=m.isArr(a);if(k){var p=A(a,b,k,c);if(null!==p){var l=p[0],p=p[1];l===c&&c++;l=k.body[l];l.vm?d?2===p?l.vm.moveTo(b,e,a[1]):1===p&&n(a[0],a[1],a[2],a[3],b,e):a.vm&&2===p&&a.vm===l.vm&&l.vm.moveTo(b,e):b.body[e]=q(a,l);return}}d?n(a[0],a[1],a[2],a[3],b,e):b.body[e]=q(a)})}return b}function v(b,k,a,d){for(var c=!b.el;a&&a._node.removed;)a=a.nextSibling;c&&f(b.vm,"willMount",b.vm);if(b.type==m.TYPE_ELEM)if(c&&(b.el=k||(b.ns?H.createElementNS(O[b.ns],
b.tag):H.createElement(b.tag)),b.props&&D(b)),m.isArr(b.body)){k=0;for(var e=b.el.firstChild;k<b.body.length;k++)e=v(b.body[k],null,e)}else m.isVal(b.body)&&(b.raw?b.el.innerHTML=b.body:c&&(b.el.textContent=b.body));else b.type==m.TYPE_TEXT&&c&&(b.el=H.createTextNode(b.body));b.el._node=b;k=b.parent;a!==b.el&&(d||k&&k.el)&&(k=c?"Insert":"Reinsert",f(b,"will"+k,b),(d||b.parent.el).insertBefore(b.el,a),f(b,"did"+k,b));c&&b.vm&&b.vm.hooks&&!b.moved&&f(b.vm,"didMount",b.vm);return a!==b.el?a:a.nextSibling}
function A(b,k,a,d,c){var e=m.isArr(b),l=e?u(b[1],b[2]):b.key,h=a.hasKeys,f=k.hasKeys;a=a.body;k=k.body;if(null!==l&&h)return b=m.keyedIdx(l,a,e?b[0]:null),-1<b?[b,2]:null;d=d||0;if(d>a.length-1)return null;c=0===c?0:c||a.length-1;for(l=null;d<=c;d++)if(h=a[d],null!==h&&h.el)if(e&&h.vm){if(h.vm.view[0]===b[0]){if(h.vm.view[1]===u(b[1],b[2]))return[d,2];!l&&f&&-1==m.keyedIdx(h.key,k,h.vm.view[0])&&(l=[d,1])}}else if(b.type===h.type&&(b.type===m.TYPE_TEXT||null!==b.tag&&b.tag===h.tag)&&(null===h.key||
!f||-1==m.keyedIdx(h.key,k,h.vm?h.vm.view[0]:null)))return[d,1];return l}function z(b,a){if(b&&b.diff&&a.diff&&b.diff[0]===a.diff[0]){var d=b.diff.slice(1).concat(a.diff.slice(1));return!a.diff[0].apply(null,d)}return!1}function d(b,a){a.el=b.el;b.el=null;a.el&&(a.el._node=a);if(a.type===m.TYPE_TEXT&&a.body!==b.body)a.el.nodeValue=a.body;else{D(a,b);var d=!m.isArr(a.body),c=!m.isArr(b.body);d&&a.body!==b.body?c&&a.el.firstChild?a.el.firstChild.nodeValue=a.body:a.raw?a.el.innerHTML=a.body:a.el.textContent=
a.body:c&&!d&&(a.el.textContent="");b.moved=!0}}function l(b,a,d,c){return function(d){var e,l=d.target._node,h=null;if(m.isFunc(b))e=b.call(a,d,l,c);else if(m.isArr(b))h=b.slice(1),e=b[0].apply(a,h.concat(d,l,c));else if(m.isObj(b))for(var p in b){var f=b[p];null!=f&&"_"!=p[0]&&d.target.matches(p)&&(m.isArr(f)?(h=f.slice(1),e=f[0].apply(a,h.concat(d,l,c))):m.isFunc(f)&&(e=f.call(a,d,l,c)))}!1===e&&(d.preventDefault(),d.stopPropagation());c.opts.hasOwnProperty("watch")&&c.opts.watch.fire({type:"event",
vm:c,node:l,event:d,data:h})}}function D(b,a){var d=!a;a=a||{};if(a.props||b.props){var c=a.props||{},l=b.props||{},e=c.style,h=l.style;if(m.isObj(e)||m.isObj(h))N(b.el,b.tag,e||{},h||{},B,I,b.ns,d,b),c.style=l.style=null;N(b.el,b.tag,c,l,J,E,b.ns,d,b);h&&(l.style=h)}}function N(b,a,d,c,l,e,h,f,x){for(var g in c)if(a=c[g],null!==a){var q="."===g[0]?b[g.substr(1)]:d[g];a===q||m.isArr(a)&&m.isArr(q)&&m.cmpArr(a,q)||l(b,g,a,h,f,x)}for(g in d)null!==d[g]&&null==c[g]&&e(b,g,h,f)}function B(b,a,d){b.style[a]=
m.autoPx(a,d)}function I(b,a){b.style[a]=""}function J(b,a,d,c,h,e){if("."===a[0])a=a.substr(1),"svg"===c?b[a].baseVal=d:b[a]=d;else if("class"===a)b.className=d;else if("id"===a)b[a]=d;else if(m.isEvProp(a)){for(c=e;!c.vm;)c=c.parent;b[a]=l(d,c.vm.opts.evctx||c.vm.model||null,e,c.vm)}else!1===d?E(b,a,c,h):b.setAttribute(a,!0===d?"":d)}function E(b,a,d,c){c||("."===a[0]?(a=a.substr(1),"svg"===d?b[a].baseVal=null:b[a]=null):"class"===a?b.className="":"id"===a||m.isEvProp(a)?b[a]=null:b.removeAttribute(a))}
var O={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},H="undefined"==typeof document?{}:document,M={},K=[],G={useRaf:!0};w.view=n;w.view.config=function(b){G=b};var F=null;w.view.extend=function(b,a){F=!F||a?[]:F;F.push(b)};var m=w.utils;return w})(domvm);(function(w){var t=/^(?:img|br|input|col|link|meta|area|base|command|embed|hr|keygen|param|source|track|wbr)$/,u=w.utils;w.html=function(n){var c="";switch(n.type){case u.TYPE_ELEM:c+="<"+n.tag;if(n.props){var f=u.isVal(n.props.style)?n.props.style:"",g=u.isObj(n.props.style)?n.props.style:null;if(g)for(var a in g)null!==g[a]&&(f+=u.camelDash(a)+": "+u.autoPx(a,g[a])+"; ");for(a in n.props)u.isEvProp(a)||"."===a[0]||(g=n.props[a],u.isFunc(g)&&(g=g()),u.isObj(g)||(!0===g?c+=" "+a:!1!==g&&null!==g&&
"."!==a[0]&&(c+=" "+a+'="'+g+'"')));f.length&&(c+=' style="'+f.trim()+'"')}if(n.ns&&"svg"!==n.tag&&"math"!==n.tag&&!n.body)return c+"/>";c+=">";break;case u.TYPE_TEXT:return n.body}t.test(n.tag)||(u.isArr(n.body)?n.body.forEach(function(a){c+=w.html(a)}):c+=n.body||"",c+="</"+n.tag+">");return c}})(domvm);(function(w){var t=w.utils;w.watch=function(u){function n(){}function c(a,c,f,q,v){v=v||{};v.method=a.toUpperCase();"credentials"in v||(v.credentials="same-origin");null!==f&&(t.isArr(f)||t.isObj(f)?(v.headers=v.headers||new Headers,v.headers.set("Content-Type","application/json"),v.body=JSON.stringify(f)):v.body=""+f);var A=q,z=n;q instanceof Array&&(A=q[0],q[1]&&(z=q[1]));var d={type:"fetch",fetch:{method:a,url:c,body:f}};q=fetch(c,v).then(function(a){if(200<=a.status&&300>a.status)return a;var d=
Error(a.status+": "+a.statusText);d.data=a;return Promise.reject(d)}).then(function(a){switch(a.headers.get("Content-Type").split("; ")[0]){case "application/json":return a.json();case "text/plain":return a.text();default:return a}}).then(A,z).then(function(a){!1!==a&&g.fire(d);return a},function(a){d.error=a;g.fire(d);return a});q._fetchArgs=[a,c,f,[A,z],v];return q}var f=[];t.isFunc(u)&&f.push(u);var g={on:function(a){f.push(a);return g},off:function(a){f.splice(f.indexOf(a),1);return g},fire:t.raft(function(a){t.execAll(f,
a);return g}),prop:function(a,h,f){var q=a,v=function(a,d,c){if(arguments.length&&a!==q){c=c||{type:"prop",prop:v,data:{old:q,"new":a}};f&&(a=f(c));if("undefined"==typeof a||a===q)return q;q=c.data["new"]=a;t.isFunc(d)?d(c):!1!==d&&g.fire(c)}return q};v._prop=!0;if(h&&h.then){v.update=n;if(h._fetchArgs){var A=h._fetchArgs[3];h._fetchArgs[3]=[function(a){return v(A[0]?A[0](a):a)},A[1]];v.update=function(){c.apply(null,h._fetchArgs)}}h.then(v)}return v.toString=v},sync:function(a,c,f){var q=a,n=c;t.isFunc(q)||
(q=function(c,h,d){if("string"==typeof a){var f,g;"e."==a.substr(0,2)?(f=c,g=a.substr(2)):(f=c.target,g=a)}return t.deepGet(f,g)});t.isArr(n)&&(n=function(a,f,d){var l=c[0],q=c[1];t.isFunc(q)&&(q=q(d.event,d.node,d.vm));var n=t.deepGet(l,q);a!==n&&(t.deepSet(l,q,a,f,d),t.isFunc(f)?f(d):!1!==f&&g.fire(d))});return function(a,c,d){var h={type:"sync",vm:d,node:c,event:a};n(q(a,c,d),f,h)}},fetch:c,get:function(a,f,n){n?a+=g.query(f):n=f;return c("get",a,null,n)},"delete":function(a,f,n){n?a+=g.query(f):
n=f;return c("delete",a,null,n)},post:function(a,f,g){return c("post",a,f,g)},put:function(a,f,g){return c("put",a,f,g)},patch:function(a,f,g){return c("patch",a,f,g)},query:function(a){if(!t.isObj(a))return"";var c=[],f=encodeURIComponent,g;for(g in a)c.push(f(g)+"="+f(a[g]));return c.length?"?"+c.join("&"):""}};return g}})(domvm);(function(w){function t(a,c,f,g,n,t){var u=null,d=null,l=null;if("/"==f[0]){l=f;d=!1;g={};t=l.split("#");c=t[0].split("?");u=c[0];t=t[1];c[1]&&(n={},c[1].split("&").map(function(a){a=a.split("=");n[a[0]]=null==a[1]?!0:a[1]}));var D,w;for(w in a){f=a[w];var B=f.path;if(D=u.match(f.regexPath)){d=w;-1!==B.indexOf(":")&&(g={},D.shift(),B.replace(/:([^\/]+)/g,function(a,c){g[c]=D.shift()}));break}}}else{d=f;f=a[d];var B=c+f.path,I=f.vars||{},J=/^[^\/]+$/,l=-1!==B.indexOf(":")?u=B.replace(/:([^\/]+)/g,
function(a,c){if((I[c]||J).test(g[c]))return g[c]+="";throw Error("Invalid value for route '"+B+"' segment '"+c+"': '"+g[c]+"'");}):u=B;if(n){var l=l+"?",E;for(E in n)l+=E+(!0!==n[E]?"="+n[E]:"")+"&";l=l.slice(0,-1)}l+=t?"#"+t:""}return{href:l,name:d,path:u,segs:g,hash:t,query:n}}function u(a,c){for(var f in a){var g=a[f];g.regexPath=new RegExp("^"+c+g.path.replace(/:([^\/]+)/g,function(a,c){var f=""+g.vars[c];return"("+f.substring(1,f.lastIndexOf("/"))+")"})+"$")}}var n=[],c=null,f=!1,g="";w.route=
function(a,h){function x(){var a=location,a=f?a.href.substr(a.origin.length):a.hash.substr(1)||"/";return t(z,g,a)}var q=null,v={href:function(a,c,h,n,q){var u=t(z,g,a,c,h,n);return f?(a=function(a){v["goto"](u,null,null,null,q);a.preventDefault()},a.href=u.href,a):"#"+u.href},config:function(a){(f=a.useHist)&&(g=a.root||"");q=a.init||null},refresh:function(){v["goto"](x(),null,null,null,!0)},"goto":function(a,l,h,q,u){u=u||w;a.href||(a=t(z,g,a,l,h,q));if(!1===a.name)console.log("Could not find route");
else{l=null;for(h=0;h<n.length;h++)if(n[h].href===a.href){l=h;break}null===l&&(n.splice(c+1,1E4),n.push(a),l=n.length-1);a=n[c];h=n[l];q=!0;null!==c&&(q=(q=z[a.name].onexit)?q.apply(null,(a?[a.segs,a.query,a.hash]:[]).concat(h)):!0);if(!1!==q&&!1!==z[h.name].onenter.apply(null,(h?[h.segs,h.query,h.hash]:[]).concat(a))){if(f)history[u?"replaceState":"pushState"](null,"title",h.href);c=l}w=!1}},location:function(){return w?x():n[c]}},w=!0,z=a(v,h);u(z,g);window.onhashchange=window.onpopstate=function(a){(f||
"popstate"!=a.type)&&v["goto"](x(),null,null,null,!0)};q&&q();return v}})(domvm);
("undefined"!==typeof global?global:this).domvm={};(function(x){var r=("undefined"==typeof window?{}:window).requestAnimationFrame,w={animationIterationCount:!0,boxFlex:!0,boxFlexGroup:!0,columnCount:!0,counterIncrement:!0,fillOpacity:!0,flex:!0,flexGrow:!0,flexOrder:!0,flexPositive:!0,flexShrink:!0,"float":!0,fontWeight:!0,gridColumn:!0,lineHeight:!0,lineClamp:!0,opacity:!0,order:!0,orphans:!0,stopOpacity:!0,strokeDashoffset:!0,strokeOpacity:!0,strokeWidth:!0,tabSize:!0,transform:!0,transformOrigin:!0,widows:!0,zIndex:!0,zoom:!0},f={TYPE_ELEM:1,
TYPE_TEXT:2,isArr:function(c){return c instanceof Array},isVal:function(c){c=typeof c;return"string"===c||"number"===c},isObj:function(c){return"object"===typeof c&&null!==c&&!f.isArr(c)},isFunc:function(c){return"function"===typeof c},isProm:function(c){return"object"===typeof c&&f.isFunc(c.then)},isElem:function(c){return c instanceof HTMLElement},execAll:function(c,d,n,a,m,u){var z;c&&(f.isArr(c)?c:[c]).forEach(function(c){z=c.call(null,d,n,a,m,u)});return z},tick:function(c,d){d&&r?r&&r(function(){f.tick(c,
d-1)}):f.isArr(c)?c[0].apply(null,c.slice(1)):c()},insertArr:function(c,d,n,a){c.splice.apply(c,[n,a].concat(d))},isEvProp:function(c){return"on"===c.substr(0,2)},isDynProp:function(c,d){switch(c){case "input":case "textarea":case "select":case "option":switch(d){case "value":case "checked":case "selected":case "selectedIndex":return!0}}},camelDash:function(c){return c.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},autoPx:function(c,d){return isNaN(d)||w[c]?d:d+"px"},cmpArr:function(c,d){var n=
c.length;if(n!=d.length)return!1;for(;n--;)if(c[n]!==d[n])return!1;return!0},deepSet:function(c,d,n,a,m,u){d=d.split(".");var z=d.pop();d.forEach(function(a){c[a]||(c[a]={});c=c[a]});if(f.isFunc(c[z]))c[z](n,a,m,u);else c[z]=n},deepGet:function(c,d){var n=d.split(".");do c=c[n.shift()];while(n.length);return c},keyedIdx:function(c,d,n,a,m){for(a=0;a<d.length;a++)if(m=d[a],m.key===c)if(n){if(m.vm&&m.vm.view[0]===n)return a}else return a;return-1},raft:function(c){function d(){n=0;c.apply(a,m)}if(!r)return c;
var n,a,m;return function(){a=this;m=arguments;n||(n=r(d))}}};x.utils=f})(domvm);(function(x){function r(){for(var b,g,k=[I,L];g=k.shift();)for(;b=g.shift();)b[0].apply(null,b.slice(1))}function w(b,g){return!1===g?null:null==g&&null!=b?b:l.isVal(g)||l.isObj(g)||l.isArr(g)||l.isFunc(g)?g:null}function f(b,g,k,a,A,e){function t(b,g,e){if(e)b[g]=b[g]||[],b[g].push(e);else for(var k in g)b[k]=b[k]||[],b[k].push(g[k])}function v(b,g,k){A=b;e=g;q.update(k,!1);null!=q.node&&(A.body[e]=q.node);return f(0,!1)}function u(b){return null==b?"":b}function f(b,c){if((c=!1!==c)&&I.length)return L.push([f,
b,c]),q;if(b){for(var a=q;b--&&a.parent;)a=a.parent;a.redraw(0,!0);return a.vm}(a=q.node)&&d(q,"willRedraw",q);var E=q.refs;q.refs={};q.body=[];var h=q.render.call(q.api,q,g,k),t;if(!1===h||(t=m(h,A,e,q,!0))&&D(a,t))return a.moved=!0,a.wasSame=!0,q.refs=E,q;t.vm=q;q.node=t;E=l.isVal(k)&&"^"===k[0]?k.substr(1):l.isVal(t.ref)&&"^"===t.ref[0]?t.ref.substr(1):null;t.key=null!=k?k:t.key;for(h=A;h;)h.vm&&(q.parent||(q.parent=h.vm,h.vm.body.push(q)),null!==E&&l.deepSet(h.vm.refs,E,t)),h=h.parent;if((E=a)&&
(t.type!==a.type||t.tag!==a.tag))var E=null,v=!0,u=a.el.parentNode;z(t,E);A&&(A.body[e]=t);c&&(a&&n(a),!a&&B||p(t,null,t.el),v&&(u||t.parent.el).insertBefore(t.el,u.childNodes[a.idx]));a&&d(q,"didRedraw",q);!1!==c&&l.tick(r,2);return q}var B=!A;l.isArr(b)&&(g=b[1],k=b[2],a=b[3],b=b[0]);k=w(g,k);var q={api:{},node:null,view:[b,k],model:g,opts:a||{},render:null,update:function(b,e){null==b||k===g&&!l.isVal(k)||(g=q.model=b);return!1!==e?f(0):q},on:function(b,g){t(q.events,b,g)},hook:function(b,g){q.hooks=
q.hooks||{};t(q.hooks,b,g)},events:{},hooks:null,redraw:J.useRaf?l.raft(f):f,patch:function(b,g){var e=null!=b.el;if(l.isObj(g)){var k="class"in g?(u(b["class"])+" "+u(g["class"])).trim():b.props["class"],c="style"in g?g.style:b.props.style;e&&(e=Object.create(b.props),e["class"]=k,e.style=c,e={tag:b.tag,el:b.el,ns:b.ns,props:e},h(e,b));b.props["class"]=k;b.props.style=c}else k=b.parent,e=z(m(g,k,b.idx,q),b),k.body[b.idx]=e},emit:function(b){for(var g=Array.prototype.slice.call(arguments),e=q,k;e;){if(k=
e.events[b]){g[0]=k;l.execAll.apply(null,g);break}e=e.parent}},refs:{},parent:null,body:[],mount:function(b,g){var e=null;g&&(b.textContent="",e=b,b=null);p(q.node,e,null,b);return q},attach:function(b){c(q.node,b);return q},unmount:function(){n(q.node)},moveTo:v,updIdx:function(b){e=b}};a&&a.hooks&&q.hook(a.hooks);l.execAll(G,q);q.render=b.call(q.api,q,g,k);return A?v(A,e):f(0)}function c(b,g){b.el=g;g._node=b;for(var k in b.props){var a=b.props[k],A=l.isEvProp(k)?k:"."===k[0]?k.substr(1):null;null!==
A&&(g[A]=a)}if(l.isArr(b.body))for(k=0;k<b.body.length;k++)c(b.body[k],g.childNodes[k])}function d(b,g,k,c,a,e){if(b&&b.hooks&&(b=b.hooks[g]))if(J.useRaf&&"did"==g.substr(0,3))I.push([l.execAll,b,k,c,a,e]);else return l.execAll(b,k,c,a,e)}function n(b,g){var k=b.el&&!b.moved;if(k){var c=d(b.vm,"willUnmount",b.vm),A=d(b,"willRemove",b),e=c||A;b.removed=!0}b.wasSame?b.wasSame=!1:(l.isArr(b.body)&&b.body.forEach(function(b,k){n(b,g||e)}),g||(e?e.then(function(){a(b,k)}):a(b,k)));b.moved=!1}function a(b,
g){null!=b.el&&b.el.parentNode&&(g&&(b.el.parentNode.removeChild(b.el),b.el=null,d(b.vm,"didUnmount",b.vm),d(b,"didRemove",b)),l.isArr(b.body)&&b.body.forEach(function(b,g){a(b,!b.moved)}))}function m(b,g,k,c,a){var e=b;b={type:null,key:null,ref:null,idx:null,parent:null,moved:!1,wasSame:!1,removed:!1,hooks:null,tag:null,"class":null,ns:null,guard:!1,raw:!1,props:null,el:null,hasKeys:!1,body:null};l.isFunc(e)&&(e=e());var t=e.length;if(l.isArr(e)&&t){b.type=l.TYPE_ELEM;if(1<t){var h=1;l.isObj(e[1])&&
!l.isElem(e[1])&&(b.props=e[1],h=2);b.body=t==h+1?l.isVal(e[h])?e[h]:l.isFunc(e[h])?e[h]():e.slice(h):e.slice(h)}e=e[0];t=M[e];t||(t=["",""],t={tag:(e.match(/^[-\w]+/)||["div"])[0],id:(e.match(/#([-\w]+)/)||t)[1],"class":(e.match(/\.([-\w.]+)/)||t)[1].replace(/\./g," ")},M[e]=t);b.tag=t.tag;if(t.id||t["class"])e=b.props||{},t.id&&null==e.id&&(e.id=t.id),t["class"]&&(b["class"]=t["class"],e["class"]=t["class"]+(null!=e["class"]?" "+e["class"]:"")),b.props=e;if(b.props){var e=b.props,d;for(d in e)!l.isEvProp(d)&&
l.isFunc(e[d])&&("href"==d?(e.onclick=e[d],e.href=e[d].href):e[d]=e[d]()),l.isDynProp(b.tag,d)&&(e["."+d]=e[d]);if(l.isObj(e.style))for(var m in e.style)d=e.style[m],l.isFunc(d)&&(e.style[m]=d());l.isObj(e._hooks)&&(b.hooks=e._hooks,e._hooks=null);b.key=l.isVal(e._key)?e._key:l.isVal(e._ref)?e._ref:l.isVal(e.id)?e.id:l.isVal(e.name)?e.name:null;null!=e._ref&&(b.ref=e._ref);e._raw&&(b.raw=!0);null!=e._data&&(b.data=e._data);e._diff&&(b.diff=e._diff);e._ref=e._key=e._raw=e._data=e._diff=null}}else l.isVal(e)?
(b.type=l.TYPE_TEXT,b.body=e):l.isElem(e)&&(b.type=l.TYPE_ELEM,b.el=e,b.tag=e.nodeName.toLowerCase());null!==b.ref&&l.deepSet(c.refs,b.ref,b);b.parent=g;b.idx=k;b.ns=g&&g.ns?g.ns:"svg"===b.tag||"math"===b.tag?b.tag:null;a||b.diff||!l.isArr(b.body)||u(b,c);return b}function u(b,g){for(var k=0,c=b.body.length;k<c;k++){var a=b.body[k],e=null,h=null,d=!1,v=!1;l.isFunc(a)&&(a=a());if(null==a)d=!0;else{var n=l.isArr(a),u=n?!1:l.isObj(a);if(n)a.length?"string"==typeof a[0]&&""!==a[0]?(h=m(a,b,k,g),e=h.key):
l.isFunc(a[0])?e=w(a[1],a[2]):v=!0:d=!0;else if(u)if(l.isFunc(a.redraw))a.moveTo(b,k),h=a.node,e=a.view[1];else if(l.isElem(a))h=m(a,b,k,g);else{b.body[k--]=""+a;continue}else""===a?d=!0:0<k&&b.body[k-1].type===l.TYPE_TEXT?(b.body[k-1].body+=""+a,d=!0):h=m(""+a,b,k,g)}d||v?(v?l.insertArr(b.body,a,k,1):b.body.splice(k,1),c=b.body.length,k--):(null!==e&&(b.hasKeys=!0),b.body[k]=h||a)}b.body._init=!0}function z(b,g){if(D(g,b))return g.moved=!0,g.wasSame=!0,g;g&&(d(b,"willRecycle",g,b),B(g,b),d(b,"didRecycle",
g,b));if(l.isArr(b.body)){if(!b.body._init){for(var a=b;!a.vm;)a=a.parent;u(b,a.vm)}var c=0;b.body.forEach(function(a,e){var k=l.isArr(a);if(g){var h=C(a,b,g,c);if(null!==h){var d=h[0],h=h[1];d===c&&c++;d=g.body[d];d.vm?k?2===h?d.vm.moveTo(b,e,a[1]):1===h&&f(a[0],a[1],a[2],a[3],b,e):a.vm&&2===h&&a.vm===d.vm&&d.vm.moveTo(b,e):b.body[e]=z(a,d);return}}k?f(a[0],a[1],a[2],a[3],b,e):b.body[e]=z(a)})}return b}function p(b,g,a,c){for(var m=!b.el;a&&a._node.removed;)a=a.nextSibling;m&&d(b.vm,"willMount",
b.vm);if(b.type==l.TYPE_ELEM)if(m&&(b.el=g||(b.ns?K.createElementNS(F[b.ns],b.tag):K.createElement(b.tag)),b.props&&h(b)),l.isArr(b.body)){g=0;for(var e=b.el.firstChild;g<b.body.length;g++)e=p(b.body[g],null,e)}else l.isVal(b.body)&&(b.raw?b.el.innerHTML=b.body:m&&(b.el.textContent=b.body));else b.type==l.TYPE_TEXT&&m&&(b.el=K.createTextNode(b.body));b.el._node=b;g=b.parent;a!==b.el&&(c||g&&g.el)&&(g=m?"Insert":"Reinsert",d(b,"will"+g,b),(c||b.parent.el).insertBefore(b.el,a),d(b,"did"+g,b));m&&b.vm&&
b.vm.hooks&&!b.moved&&d(b.vm,"didMount",b.vm);return a!==b.el?a:a.nextSibling}function C(b,g,a,c,h){var e=l.isArr(b),d=e?w(b[1],b[2]):b.key,m=a.hasKeys,v=g.hasKeys;a=a.body;g=g.body;if(null!==d&&m)return b=l.keyedIdx(d,a,e?b[0]:null),-1<b?[b,2]:null;c=c||0;if(c>a.length-1)return null;h=0===h?0:h||a.length-1;for(d=null;c<=h;c++)if(m=a[c],null!==m&&m.el)if(e&&m.vm){if(m.vm.view[0]===b[0]){if(m.vm.view[1]===w(b[1],b[2]))return[c,2];!d&&v&&-1==l.keyedIdx(m.key,g,m.vm.view[0])&&(d=[c,1])}}else if(b.type===
m.type&&(b.type===l.TYPE_TEXT||null!==b.tag&&b.tag===m.tag)&&(null===m.key||!v||-1==l.keyedIdx(m.key,g,m.vm?m.vm.view[0]:null)))return[c,1];return d}function D(b,a){if(b&&b.diff&&a.diff&&b.diff[0]===a.diff[0]){var c=b.diff.slice(1).concat(a.diff.slice(1));return!a.diff[0].apply(null,c)}return!1}function B(b,a){a.el=b.el;b.el=null;a.el&&(a.el._node=a);if(a.type===l.TYPE_TEXT&&a.body!==b.body)a.el.nodeValue=a.body;else{h(a,b);var c=!l.isArr(a.body),d=!l.isArr(b.body);c&&a.body!==b.body?d&&a.el.firstChild?
a.el.firstChild.nodeValue=a.body:a.raw?a.el.innerHTML=a.body:a.el.textContent=a.body:d&&!c&&(a.el.textContent="");b.moved=!0}}function v(b,a,c,d){return function(c){var e,h=c.target._node,k=null;if(l.isFunc(b))e=b.call(a,c,h,d);else if(l.isArr(b))k=b.slice(1),e=b[0].apply(a,k.concat(c,h,d));else if(l.isObj(b))for(var m in b){var v=b[m];null!=v&&"_"!=m[0]&&c.target.matches(m)&&(l.isArr(v)?(k=v.slice(1),e=v[0].apply(a,k.concat(c,h,d))):l.isFunc(v)&&(e=v.call(a,c,h,d)))}!1===e&&(c.preventDefault(),c.stopPropagation());
d.opts.hasOwnProperty("watch")&&d.opts.watch.fire({type:"event",vm:d,node:h,event:c,data:k})}}function h(b,a){var c=!a;a=a||{};if(a.props||b.props){var d=a.props||{},h=b.props||{},e=d.style,m=h.style;if(l.isObj(e)||l.isObj(m))N(b.el,b.tag,e||{},m||{},O,y,b.ns,c,b),d.style=h.style=null;N(b.el,b.tag,d,h,P,H,b.ns,c,b);m&&(h.style=m)}}function N(b,a,c,d,h,e,m,v,n){for(var u in d)if(a=d[u],null!==a){var f="."===u[0]?b[u.substr(1)]:c[u];a===f||l.isArr(a)&&l.isArr(f)&&l.cmpArr(a,f)||h(b,u,a,m,v,n)}for(u in c)null!==
c[u]&&null==d[u]&&e(b,u,m,v)}function O(b,a,c){b.style[a]=l.autoPx(a,c)}function y(b,a){b.style[a]=""}function P(b,a,c,d,h,e){if("."===a[0])a=a.substr(1),"svg"===d?b[a].baseVal=c:b[a]=c;else if("class"===a)b.className=c;else if("id"===a)b[a]=c;else if(l.isEvProp(a)){for(d=e;!d.vm;)d=d.parent;b[a]=v(c,d.vm.opts.evctx||d.vm.model||null,e,d.vm)}else!1===c?H(b,a,d,h):b.setAttribute(a,!0===c?"":c)}function H(b,a,c,d){d||("."===a[0]?(a=a.substr(1),"svg"===c?b[a].baseVal=null:b[a]=null):"class"===a?b.className=
"":"id"===a||l.isEvProp(a)?b[a]=null:b.removeAttribute(a))}var F={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},K="undefined"==typeof document?{}:document,M={},I=[],L=[],J={useRaf:!0};x.view=f;x.view.config=function(b){J=b};var G=null;x.view.extend=function(b,a){G=!G||a?[]:G;G.push(b)};var l=x.utils;return x})(domvm);(function(x){var r=/^(?:img|br|input|col|link|meta|area|base|command|embed|hr|keygen|param|source|track|wbr)$/,w=x.utils;x.html=function(f){var c="";switch(f.type){case w.TYPE_ELEM:c+="<"+f.tag;if(f.props){var d=w.isVal(f.props.style)?f.props.style:"",n=w.isObj(f.props.style)?f.props.style:null;if(n)for(var a in n)null!==n[a]&&(d+=w.camelDash(a)+": "+w.autoPx(a,n[a])+"; ");for(a in f.props)w.isEvProp(a)||"."===a[0]||(n=f.props[a],w.isFunc(n)&&(n=n()),w.isObj(n)||(!0===n?c+=" "+a:!1!==n&&null!==n&&
"."!==a[0]&&(c+=" "+a+'="'+n+'"')));d.length&&(c+=' style="'+d.trim()+'"')}if(f.ns&&"svg"!==f.tag&&"math"!==f.tag&&!f.body)return c+"/>";c+=">";break;case w.TYPE_TEXT:return f.body}r.test(f.tag)||(w.isArr(f.body)?f.body.forEach(function(a){c+=x.html(a)}):c+=f.body||"",c+="</"+f.tag+">");return c}})(domvm);(function(x){var r=x.utils;x.watch=function(w){function f(){}function c(a,c,d,f,p){p=p||{};p.method=a.toUpperCase();"credentials"in p||(p.credentials="same-origin");null!==d&&(r.isArr(d)||r.isObj(d)?(p.headers=p.headers||new Headers,p.headers.set("Content-Type","application/json"),p.body=JSON.stringify(d)):p.body=""+d);var C=f,D=function(a){return Promise.reject(a)};f instanceof Array&&(C=f[0],f[1]&&(D=f[1]));var B={type:"fetch",fetch:{method:a,url:c,body:d}};f=fetch(c,p).then(function(a){if(200<=
a.status&&300>a.status)return a;var c=Error(a.status+": "+a.statusText);c.data=a;return Promise.reject(c)}).then(function(a){switch(a.headers.get("Content-Type").split("; ")[0]){case "application/json":return a.json();case "text/plain":return a.text();default:return a}}).then(C,D).then(function(a){!1!==a&&n.fire(B);return a},function(a){B.error=a;n.fire(B);return Promise.reject(a)});f._fetchArgs=[a,c,d,[C,D],p];return f}var d=[];r.isFunc(w)&&d.push(w);var n={on:function(a){d.push(a);return n},off:function(a){d.splice(d.indexOf(a),
1);return n},fire:r.raft(function(a){r.execAll(d,a);return n}),prop:function(a,d,u){var z=a,p=function(a,c,d){if(arguments.length&&a!==z){d=d||{type:"prop",prop:p,data:{old:z,"new":a}};u&&(a=u(d));if("undefined"==typeof a||a===z)return z;z=d.data["new"]=a;r.isFunc(c)?c(d):!1!==c&&n.fire(d)}return z};p._prop=!0;if(d&&d.then){p.update=f;if(d._fetchArgs){var C=d._fetchArgs[3];d._fetchArgs[3]=[function(a){return p(C[0]?C[0](a):a)},C[1]];p.update=function(){c.apply(null,d._fetchArgs)}}d.then(p)}return p.toString=
p},sync:function(a,c,d){var f=a,p=c;r.isFunc(f)||(f=function(c,d,m){if("string"==typeof a){var f,h;"e."==a.substr(0,2)?(f=c,h=a.substr(2)):(f=c.target,h=a)}return r.deepGet(f,h)});r.isArr(p)&&(p=function(a,d,f){var u=c[0],h=c[1];r.isFunc(h)&&(h=h(f.event,f.node,f.vm));var p=r.deepGet(u,h);a!==p&&(r.deepSet(u,h,a,d,f),r.isFunc(d)?d(f):!1!==d&&n.fire(f))});return function(a,c,m){var n={type:"sync",vm:m,node:c,event:a};p(f(a,c,m),d,n)}},fetch:c,get:function(a,d,f){f?a+=n.query(d):f=d;return c("get",
a,null,f)},"delete":function(a,d,f){f?a+=n.query(d):f=d;return c("delete",a,null,f)},post:function(a,d,f){return c("post",a,d,f)},put:function(a,d,f){return c("put",a,d,f)},patch:function(a,d,f){return c("patch",a,d,f)},query:function(a){if(!r.isObj(a))return"";var c=[],d=encodeURIComponent,f;for(f in a)c.push(d(f)+"="+d(a[f]));return c.length?"?"+c.join("&"):""}};return n}})(domvm);(function(x){function r(a,c,d,f,m,n){var v=null,h=null,r=null;if("/"==d[0]){r=d;h=!1;f={};n=r.split("#");c=n[0].split("?");v=c[0];n=n[1];c[1]&&(m={},c[1].split("&").map(function(a){a=a.split("=");m[a[0]]=null==a[1]?!0:a[1]}));var w,y;for(y in a){d=a[y];var x=d.path;if(w=v.match(d.regexPath)){h=y;-1!==x.indexOf(":")&&(f={},w.shift(),x.replace(/:([^\/]+)/g,function(a,c){f[c]=w.shift()}));break}}}else{h=d;d=a[h];var x=c+d.path,H=d.vars||{},r=-1!==x.indexOf(":")?v=x.replace(/:([^\/]+)/g,function(a,c){if((H[c]||
/^[^\/]+$/).test(f[c]))return f[c]+="";throw Error("Invalid value for route '"+x+"' segment '"+c+"': '"+f[c]+"'");}):v=x;if(m){var r=r+"?",F;for(F in m)r+=F+(!0!==m[F]?"="+m[F]:"")+"&";r=r.slice(0,-1)}r+=n?"#"+n:""}return{href:r,name:h,path:v,segs:f,hash:n,query:m}}function w(a,c){for(var d in a){var f=a[d];f.regexPath=new RegExp("^"+c+f.path.replace(/:([^\/]+)/g,function(a,c){var d=""+((f.vars||{})[c]||/[^\/]+/);return"("+d.substring(1,d.lastIndexOf("/"))+")"})+"$")}}var f=[],c=null,d=!1,n=null,
a=null,m="";x.route=function(u,x){function p(){var a=location,a=d?a.href.substr(a.origin.length):a.hash.substr(1)||"/";return r(B,m,a)}var C=null,D={href:function(a,c,f,n,p){var v=r(B,m,a,c,f,n);return d?(a=function(a){D["goto"](v,null,null,null,p);a.preventDefault()},a.href=v.href,a):"#"+v.href},config:function(c){(d=c.useHist)&&(m=c.root||"");n=c.willEnter||null;a=c.willExit||null;C=c.init||null},refresh:function(){D["goto"](p(),null,null,null,!0)},"goto":function(h,p,u,y,x){h.href||(h=r(B,m,h,
p,u,y));if(!1===h.name)console.log("Could not find route");else{p=null;for(y=0;y<f.length;y++)if(f[y].href===h.href){p=y;break}null===p&&(f.splice(c+1,1E4),f.push(h),p=f.length-1);h=f[c];y=f[p];var w=!0;u=!0;null!==c&&(a&&(w=!1!==a(h,y)),w&&(w=(w=B[h.name].onexit)?w.apply(null,(h?[h.segs,h.query,h.hash]:[]).concat(y)):!0));!1!==w&&(n&&(u=!1!==n(y,h)),u&&(u=B[y.name].onenter.apply(null,(y?[y.segs,y.query,y.hash]:[]).concat(h))),u&&(d?(v=!0,history[x?"replaceState":"pushState"](null,"title",y.href)):
(y="#"+y.href,location.hash!==y&&(v=!0,x?location.replace(y):location.hash=y)),c=p))}},location:function(){return null==c?p():f[c]}},B=u(D,x);w(B,m);var v=!1;window.onhashchange=window.onpopstate=function(a){if(d||"popstate"!=a.type)!d&&v?v=!1:D["goto"](p(),null,null,null,!0)};C&&C();return D}})(domvm);

@@ -7,3 +7,3 @@ {

"author": "Leon Sorokin <leeoniya@gmail.com>",
"version": "1.2.1",
"version": "1.2.2",
"main": "index.js",

@@ -10,0 +10,0 @@ "repository": {

@@ -70,3 +70,3 @@ domvm.js (DOM ViewModel)

Each module is a single js file in `/src`. The first 3 are the "core", the rest are optional and can be replaced by your own implementations. For development, just include them in order.
Each module is a single js file in `/src`. The first 3 are the "core", the rest are optional and can be replaced by your own implementations. For development, just include each via `<script>` tags.

@@ -559,3 +559,7 @@ 0. `domvm`: namespace & wrapper

// and `router.location()` to determine and render the appropriate views
}
},
// if provided, the funcs below will fire after a route is matched but before its handler is invoked.
// they can return `false` to prevent route's onenter/onexit handlers from firing
willEnter: function(to, from) {},
willExit: function(from, to) {},
});

@@ -562,0 +566,0 @@

@@ -11,5 +11,5 @@ /**

/**
* @preserve https://github.com/leeoniya/domvm (1.1.0)
* @preserve https://github.com/leeoniya/domvm (1.x-dev)
*/
(typeof global !== "undefined" ? global : this).domvm = {};

@@ -6,2 +6,4 @@ (function(domvm) {

useHist = false,
willEnter = null,
willExit = null,
root = "";

@@ -36,4 +38,9 @@

useHist = opts.useHist;
if (useHist)
root = opts.root || "";
willEnter = opts.willEnter || null;
willExit = opts.willExit || null;
init = opts.init || null;

@@ -46,4 +53,2 @@ },

goto: function(dest, segs, query, hash, repl) {
repl = repl || initial;
if (!dest.href)

@@ -76,35 +81,54 @@ dest = buildRoute(routes, root, dest, segs, query, hash);

var canExit = true;
var canEnter = true;
if (pos !== null) {
var onexit = routes[prev.name].onexit;
canExit = !onexit ? true : onexit.apply(null, (prev ? [prev.segs, prev.query, prev.hash] : []).concat(next));
if (willExit)
canExit = willExit(prev, next) !== false;
if (canExit) {
var onexit = routes[prev.name].onexit;
canExit = !onexit ? true : onexit.apply(null, (prev ? [prev.segs, prev.query, prev.hash] : []).concat(next));
}
else {
// revert nav?
}
}
if (canExit !== false) {
var onenter = routes[next.name].onenter;
var canEnter = onenter.apply(null, (next ? [next.segs, next.query, next.hash] : []).concat(prev));
if (willEnter)
canEnter = willEnter(next, prev) !== false;
if (canEnter === false) {
// revert nav?
if (canEnter) {
var onenter = routes[next.name].onenter;
canEnter = onenter.apply(null, (next ? [next.segs, next.query, next.hash] : []).concat(prev));
}
else {
if (useHist)
if (canEnter) {
if (useHist) {
gotoLocChg = true;
history[repl ? "replaceState" : "pushState"](null, "title", next.href);
}
else {
// if (repl)
// location.replace("#"+next.href);
// else
// location.hash = "#"+next.href;
var hash = "#"+next.href;
if (location.hash !== hash) {
gotoLocChg = true;
if (repl)
location.replace(hash);
else
location.hash = hash;
}
}
pos = toPos;
}
else {
// revert nav?
}
}
initial = false;
}
},
location: function() {
return initial ? routeFromLoc() : stack[pos];
return pos == null ? routeFromLoc() : stack[pos];
// return stack[pos];

@@ -116,4 +140,2 @@ },

var initial = true;
var routes = routeFn(api, imp);

@@ -123,5 +145,15 @@

// tmp flag that indicates that hash or location changed as result of a goto call rather than natively.
// prevents cyclic goto->hashchange->goto...
var gotoLocChg = false;
window.onhashchange = window.onpopstate = function(e) {
if (!useHist && e.type == "popstate")
return;
if (!useHist && gotoLocChg) {
gotoLocChg = false;
return;
}
api.goto(routeFromLoc(),null,null,null,true);

@@ -191,8 +223,7 @@ };

pathDef = root + rtDef.path,
segDef = rtDef.vars || {},
any = /^[^\/]+$/;
segDef = rtDef.vars || {};
if (pathDef.indexOf(":") !== -1) {
href = path = pathDef.replace(/:([^\/]+)/g, function(m, segName) {
if ((segDef[segName] || any).test(segs[segName]))
if ((segDef[segName] || /^[^\/]+$/).test(segs[segName]))
return (segs[segName] += "");

@@ -233,3 +264,4 @@

r.path.replace(/:([^\/]+)/g, function(m, name) {
var regExStr = ""+r.vars[name];
var segDef = r.vars || {};
var regExStr = ""+(segDef[name] || /[^\/]+/);
return "(" + regExStr.substring(1, regExStr.lastIndexOf("/")) + ")";

@@ -236,0 +268,0 @@ })

@@ -19,6 +19,11 @@ (function(domvm) {

var pendRedraws = [];
function drainDidHooks() {
var item;
while (item = didHooks.pop())
item[0].apply(null, item.slice(1));
var item, queue, queues = [didHooks, pendRedraws];
while (queue = queues.shift()) {
while (item = queue.shift())
item[0].apply(null, item.slice(1));
}
}

@@ -108,7 +113,3 @@

parent: null,
/*
html: function() {
return collectHtml(vm.node);
},
*/
body: [],
mount: function(parentEl, isRoot) {

@@ -232,2 +233,9 @@ var withEl = null;

function redraw(level, isRedrawRoot) {
isRedrawRoot = isRedrawRoot !== false;
if (isRedrawRoot && didHooks.length) {
pendRedraws.push([redraw, level, isRedrawRoot]);
return vm;
}
if (level) {

@@ -246,2 +254,3 @@ var targ = vm;

vm.refs = {}; // null?
vm.body = []; // null?

@@ -278,4 +287,6 @@ // vm.keyMap = {};

if (ancest.vm) {
if (!vm.parent)
if (!vm.parent) {
vm.parent = ancest.vm;
ancest.vm.body.push(vm);
}
if (unjRef !== null)

@@ -303,3 +314,3 @@ u.deepSet(ancest.vm.refs, unjRef, node);

if (isRedrawRoot !== false) {
if (isRedrawRoot) {
old && cleanNode(old);

@@ -306,0 +317,0 @@

@@ -33,3 +33,3 @@ (function(domvm) {

var okFn = cb,
errFn = noop;
errFn = function (err) { return Promise.reject(err); };

@@ -82,3 +82,3 @@ if (cb instanceof Array) {

api.fire(event);
return err;
return Promise.reject(err);
}

@@ -85,0 +85,0 @@ );

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc