Comparing version 1.2.3 to 1.2.4
/* | ||
https://github.com/leeoniya/domvm (1.2.3) | ||
https://github.com/leeoniya/domvm (1.2.4) | ||
*/ | ||
@@ -8,3 +8,3 @@ ("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, | ||
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, | ||
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,M];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 M.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)&& | ||
@@ -15,15 +15,15 @@ (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= | ||
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&& | ||
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)}));K.push(b)}function m(b,g,k,c,a){var e=b;b=0<K.length?K.pop():{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};b.el=b.key=b.vm=b.body=b.props=null;b.moved=b.wasSame=b.removed=!1;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])||e[1].redraw||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=N[e];t||(t=["",""],t={tag:(e.match(/^[-\w]+/)||["div"])[0],id:(e.match(/#([-\w]+)/)||t)[1],"class":(e.match(/\.([-\w.]+)/)||t)[1].replace(/\./g," ")},N[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?L.createElementNS(F[b.ns],b.tag):L.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=L.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){if(b.el)if(a.el=b.el,b.el=null,a.el&&(a.el._node=a),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))O(b.el,b.tag,e||{},m||{},P,y,b.ns,c,b),d.style=h.style=null;O(b.el,b.tag,d,h,Q,H,b.ns,c,b);m&&(h.style=m)}}function O(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 P(b,a,c){b.style[a]=l.autoPx(a,c)}function y(b,a){b.style[a]=""}function Q(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"},L="undefined"==typeof document?{}:document,N={},K=[],I=[],M=[],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<= | ||
@@ -30,0 +30,0 @@ 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), |
@@ -7,3 +7,3 @@ { | ||
"author": "Leon Sorokin <leeoniya@gmail.com>", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"main": "index.js", | ||
@@ -10,0 +10,0 @@ "repository": { |
@@ -16,2 +16,4 @@ (function(domvm) { | ||
var pool = []; | ||
// queue for did* hooks to ensure they all fire in same anim frame | ||
@@ -417,4 +419,6 @@ var didHooks = []; | ||
function removeNode(node, removeSelf) { | ||
if (node.el == null || !node.el.parentNode) | ||
if (node.el == null || !node.el.parentNode) { | ||
free(node); | ||
return; | ||
} | ||
@@ -439,2 +443,4 @@ if (removeSelf) { | ||
} | ||
free(node); | ||
} | ||
@@ -761,2 +767,4 @@ | ||
function graftNode(o, n) { | ||
if (!o.el) return; | ||
// move element over | ||
@@ -830,4 +838,4 @@ n.el = o.el; | ||
function procNode(raw, ownerVm) { | ||
var node = { | ||
function alloc() { | ||
var node = pool.length > 0 ? pool.pop() : { | ||
type: null, // elem, text, frag (todo) | ||
@@ -857,2 +865,23 @@ // name: null, // view name populated externally by createView | ||
node.el = | ||
node.key = | ||
node.vm = | ||
node.body = | ||
node.props = null; | ||
node.moved = | ||
node.wasSame = | ||
node.removed = false; | ||
return node; | ||
} | ||
function free(node) { | ||
// console.log(node.el); // hmm | ||
pool.push(node); | ||
} | ||
function procNode(raw, ownerVm) { | ||
var node = alloc(); | ||
// getters | ||
@@ -870,3 +899,3 @@ if (u.isFunc(raw)) | ||
if (u.isObj(raw[1]) && !u.isElem(raw[1])) { | ||
if (u.isObj(raw[1]) && !raw[1].redraw && !u.isElem(raw[1])) { | ||
node.props = raw[1]; | ||
@@ -873,0 +902,0 @@ bodyIdx = 2; |
function DBMon() { | ||
var dbDiff = function(mutOld, mutNew) { | ||
return mutOld !== mutNew; | ||
}; | ||
var queryDiff = function(oldQuery, newQuery) { | ||
return oldQuery !== newQuery || oldQuery.elapsed !== newQuery.elapsed; | ||
}; | ||
return function(vm, dbs) { | ||
@@ -15,3 +7,3 @@ return ["div", | ||
dbs.map(function(db) { | ||
return ["tr", { _diff: [dbDiff, db.lastMutationId] }, | ||
return ["tr", | ||
["td.dbname", db.dbname], | ||
@@ -22,3 +14,3 @@ ["td.query-count", | ||
db.lastSample.topFiveQueries.map(function(query) { | ||
return ["td.Query", { class: query.elapsedClassName, _diff: [queryDiff, query] }, | ||
return ["td.Query", { class: query.elapsedClassName }, | ||
["span", query.formatElapsed], | ||
@@ -25,0 +17,0 @@ [".popover.left", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
750353
73
12230
1