Comparing version 2.1.1 to 2.1.3
@@ -17,3 +17,3 @@ const rollup = require('rollup').rollup; | ||
build: "nano", | ||
contents: "+ `h`<br>+ `selectorTag`<br>+ `autoPx`<br>+ `defineElementSpread`<br>+ `diff`<br>+ `patch`<br>", | ||
contents: "+ `selectorTag`<br> + `autoPx`<br> + `diff`<br> + `patch`<br>", | ||
descr: "tpl conveniences:<br>`\"input[type=checkbox].some-class\"`<br>`{style: {width: 20}}`<br>`el(\"div\", el(\"span\", \"foo\")...)`<br><br>optims:<br>`vnode.patch({class: ..., style...})`<br>`vm.diff({vals:...then:...})`", | ||
@@ -132,3 +132,3 @@ }, | ||
let cmd = [ | ||
"java -jar compiler.jar --language_in=ECMASCRIPT6_STRICT --language_out ECMASCRIPT5_STRICT", | ||
"java -jar compiler.jar --language_in=ECMASCRIPT6_STRICT --language_out=ECMASCRIPT5_STRICT", | ||
"--js " + src, | ||
@@ -135,0 +135,0 @@ "--js_output_file " + dst, |
@@ -7,3 +7,3 @@ /** | ||
* A thin, fast, dependency-free vdom view layer | ||
* @preserve https://github.com/leeoniya/domvm (v2.1.1, client) | ||
* @preserve https://github.com/leeoniya/domvm (v2.1.3, client) | ||
*/ | ||
@@ -44,2 +44,6 @@ | ||
function isSet(val) { | ||
return val != null; | ||
} | ||
function isPlainObj(val) { | ||
@@ -66,6 +70,4 @@ return val != null && val.constructor == Object; // && typeof val == "object" | ||
function isElem(val) { | ||
return ENV_DOM && val instanceof HTMLElement; | ||
} | ||
function assignObj(targ) { | ||
@@ -447,6 +449,2 @@ var args = arguments; | ||
function isSet(val) { | ||
return val != null; | ||
} | ||
// (de)optimization flags | ||
@@ -962,3 +960,3 @@ | ||
// from_right: | ||
while(1) { | ||
while (1) { | ||
// if (rgtSib == lftEnd) | ||
@@ -1240,4 +1238,2 @@ // break converge; | ||
vm.api = {}; | ||
vm.view = view; | ||
@@ -1248,3 +1244,3 @@ vm.model = model; | ||
if (!view.prototype._isClass) { | ||
var out = view.call(vm, vm, model, key); // , opts | ||
var out = view.call(vm, vm, model, key, opts); | ||
@@ -1271,2 +1267,3 @@ if (isFunc(out)) | ||
} | ||
// remove this? | ||
@@ -1286,2 +1283,7 @@ if (opts) { | ||
var hooks = vm.hooks; | ||
if (hooks && hooks.didInit) | ||
{ hooks.didInit.call(vm, vm, model, key, opts); } | ||
// this.update(model, parent, idx, parentVm, false); | ||
@@ -1445,2 +1447,5 @@ | ||
if (vm.key !== false) | ||
{ vnew.key = vm.key; } | ||
// console.log(vm.key); | ||
@@ -1704,42 +1709,4 @@ | ||
// does not handle defineComment, defineText, defineSVG (ambiguous); use plain text vals or explicit factories in templates. | ||
// does not handle defineElementSpread (not available in all builds); use exlicit factories in templates. | ||
function h(a) { | ||
return ( | ||
isVal(a) ? defineElement : | ||
isFunc(a) ? defineView : // todo: es6 class constructor | ||
isElem(a) ? injectElement : | ||
a instanceof ViewModel ? injectView : | ||
noop | ||
).apply(null, arguments); | ||
} | ||
function defineElementSpread(tag) { | ||
var args = arguments; | ||
var len = args.length; | ||
var body, attrs; | ||
if (len > 1) { | ||
var bodyIdx = 1; | ||
if (isPlainObj(args[1])) { | ||
attrs = args[1]; | ||
bodyIdx = 2; | ||
} | ||
if (len == bodyIdx + 1 && (isVal(args[bodyIdx]) || isArr(args[bodyIdx]))) | ||
{ body = args[bodyIdx]; } | ||
else | ||
{ body = sliceArgs(args, bodyIdx); } | ||
} | ||
return initElementNode(tag, attrs, body); | ||
} | ||
// #destub: cssTag,autoPx | ||
nano.h = h; | ||
nano.defineElementSpread = defineElementSpread; | ||
ViewModelProto.events = null; | ||
@@ -1746,0 +1713,0 @@ ViewModelProto.emit = emit; |
/* | ||
https://github.com/leeoniya/domvm (v2.1.1, client) | ||
https://github.com/leeoniya/domvm (v2.1.3, client) | ||
*/ | ||
'use strict';(function(D,q){"object"===typeof exports&&"undefined"!==typeof module?module.exports=q():"function"===typeof define&&define.amd?define(q):D.domvm=q()})(this,function(){function D(){}function q(a){a=typeof a;return"string"===a||"number"===a}function w(a){return"function"===typeof a}function y(a){for(var b=arguments,c=1;c<b.length;c++)for(var d in b[c])a[d]=b[c][d];return a}function S(a,b){for(var c=[];b<a.length;b++)c.push(a[b]);return c}function sa(a,b){for(var c in a)if(a[c]!==b[c])return!1; | ||
return!0}function T(a,b){var c=a.length;if(b.length!=c)return!1;for(var d=0;d<c;d++)if(a[d]!==b[d])return!1;return!0}function U(a){function b(){c=0;a.apply(d,e)}if(!V)return a;var c,d,e;return function(){d=this;e=arguments;c||(c=V(b))}}function ta(a,b,c){return function(){return a.apply(c,b)}}function E(a,b){switch(b){case "value":case "checked":case "selected":case "selectedIndex":return!0}return!1}function r(a){for(a=a||u;null==a.vm&&a.parent;)a=a.parent;return a.vm}function W(a){z=a.is;X=a.val; | ||
Y=a.sub;Z=a.unsub}function F(a,b){var c=Y(a,function(a){c&&(null!=b.node&&b.redraw(),Z(c))});return X(a)}function aa(a,b){var c=(a.attrs||u).style;b=b?(b.attrs||u).style:null;if(null==c||q(c))a.el.style.cssText=c;else{for(var d in c){var e=c[d];z(e)&&(e=F(e,r(a)));if(null==b||null!=e&&e!==b[d]){var f=a.el.style,g=d,h;h=d;h=isNaN(e)||ua[h]?e:e+"px";f[g]=h}}if(b)for(var k in b)null==c[k]&&(a.el.style[k]="")}}function ba(a,b,c,d,e){if(a)e?(a=c.parent,a&&a.el&&a.el.offsetHeight):J.push([b,c,d]);else return b(c, | ||
d)}function n(a,b,c,d){var e=b.hooks[a];if(e){var f=0===a.lastIndexOf("did",0);return l(e)?e.map(function(a){return ba(f,a,b,c)}):ba(f,e,b,c,d)}}function v(){}function ca(a,b,c,d){var e=new v;e.type=1;null!=d&&(e.flags=d);null!=b&&(null!=b._key&&(e.key=b._key),null!=b._ref&&(e.ref=b._ref),null!=b._hooks&&(e.hooks=b._hooks),null!=b._raw&&(e.raw=b._raw),null!=b._data&&(e.data=b._data),null!=b._flags&&(e.flags=b._flags),null==e.key&&(null!=e.ref?e.key=e.ref:null!=b.id?e.key=b.id:null!=b.name&&(e.key= | ||
b.name)),e.attrs=b);b=da[a];if(null==b){var f,g,h;for(da[a]=b={tag:(f=a.match(/^[-\w]+/))?f[0]:"div",id:(g=a.match(/#([-\w]+)/))?g[1]:null,class:(h=a.match(/\.([-\w.]+)/))?h[1].replace(/\./g," "):null,attrs:null};f=va.exec(a);)null==b.attrs&&(b.attrs={}),b.attrs[f[1]]=f[2]||""}a=b;e.tag=a.tag;if(a.id||a.class||a.attrs){f=e.attrs||{};a.id&&null==f.id&&(f.id=a.id);a.class&&(e._class=a.class,f.class=a.class+(null!=f.class?" "+f.class:""));if(a.attrs)for(var k in a.attrs)null==f[k]&&(f[k]=a.attrs[k]); | ||
e.attrs=f}null!=c&&(e.body=c);return e}function ea(a){var b=a.hooks,c=a.vm;c&&c.hooks&&n("willUnmount",c);b=b&&n("willRemove",a);if(a.flags&2&&l(a.body))for(c=0;c<a.body.length;c++)ea(a.body[c]);return b}function K(a,b,c){var d=b._node,e=d.hooks,f=d.vm;if(d.flags&2&&l(d.body))for(var g=0;g<d.body.length;g++)K(b,d.body[g].el);a.removeChild(b);e&&n("didRemove",d,null,c);f&&f.hooks&&n("didUnmount",f,null,c)}function A(a,b){var c=ea(b._node);null!=c&&"object"===typeof c&&w(c.then)?c.then(ta(K,[a,b,!0])): | ||
K(a,b)}function m(a,b,c){var d=b._node,e=d.hooks,f=null!=b.parentNode,g=(b==c||!f)&&d.vm;g&&g.hooks&&n("willMount",g);e&&n(f?"willReinsert":"willInsert",d);a.insertBefore(b,c);e&&n(f?"didReinsert":"didInsert",d);g&&g.hooks&&n("didMount",g)}function fa(a,b,c){var d;for(d=a.target;null==d._node;)d=d.parentNode;d=d._node;var e=r(d);b=b.apply(null,c.concat(a,d,e));ga.onevent.apply(null,[a,d,e].concat(c));!1===b&&(a.preventDefault(),a.stopPropagation())}function ha(a,b){return function(c){fa(c,a,b)}}function wa(a){return function(b){for(var c in a)if(b.target.matches(c)){var d= | ||
a[c],e=l(d),f=e?d[0]:d,d=e?d.slice(1):[];fa(b,f,d)}}}function L(a,b,c,d){c!==d&&(a=a.el,l(c)?null!=d&&T(c,d)||(c=ha(c[0],c.slice(1)),a[b]=c):(c=w(c)&&c!=d?ha(c,[]):wa(c),a[b]=c))}function M(a,b,c,d){var e=a.el;null==c?a.el.removeAttribute(b):null!=a.ns?e.setAttribute(b,c):"class"==b?e.className=c:"id"==b||"boolean"==typeof c||d?e[b]=c:"."==b[0]?e[b.substr(1)]=c:e.setAttribute(b,c)}function ia(a,b){var c=a.attrs||u,d=b.attrs||u,e;for(e in c){var f=c[e],g=E(a.tag,e),h=g?a.el[e]:d[e];z(f)&&(c[e]=f=F(f, | ||
r(a)));f!==h&&("style"==e?aa(a,b):"_"==e[0]||(0===e.lastIndexOf("on",0)?L(a,e,f,h):M(a,e,f,g)))}for(e in d)e in c||"_"==e[0]||(b=a,d=e,E(a.tag,e)||0===e.lastIndexOf("on",0)?b.el[d]="":b.el.removeAttribute(d))}function G(a,b,c,d){if(4==a.type)b=a.model,c=a.key,d=a.opts,a=a.view;else if(a.prototype._isClass)return new a(b,c,d);return new B(a,b,c,d)}function ja(a){for(var b=0;b<a.body.length;b++){var c=a.body[b],d=c.type;3>=d?m(a.el,t(c)):4==d?(c=G(c.view,c.model,c.key,c.opts)._redraw(a,b,!1),m(a.el, | ||
t(c.node))):5==d&&(c=c.vm,c._redraw(a,b),m(a.el,c.node.el))}}function t(a,b){if(null==a.el)if(1==a.type){if(!b){b=a.tag;var c=a.ns;b=null!=c?H.createElementNS(c,b):H.createElement(b)}a.el=b;if(null!=a.attrs){b=a.attrs;for(var d in b){var c=b[d],e=E(a.tag,d);z(c)&&(b[d]=c=F(c,r(a)));"style"==d?aa(a):"_"==d[0]||(0===d.lastIndexOf("on",0)?L(a,d,c):null!=c&&M(a,d,c,e))}}l(a.body)?ja(a):null!=a.body&&""!==a.body&&(a.raw?a.el.innerHTML=a.body:a.el.textContent=a.body)}else 2==a.type?a.el=b||H.createTextNode(a.body): | ||
3==a.type&&(a.el=b||H.createComment(a.body));a.el._node=a;return a.el}function ka(a,b,c,d){c=c.previousSibling;d=d.nextSibling;a(c,d);return{lftSib:c?c.nextSibling:b.firstChild,rgtSib:d?d.previousSibling:b.lastChild}}function xa(a,b,c,d,e){var f=e.idx==c.idx+1,g=f?!1:b._node==e,h=f?!0:d._node==c;return g||h?ka(function(c,e){h&&m(a,d,b);g&&m(a,b,e)},a,b,d):null}function ya(a,b,c,d){return ka(function(c,f){for(var e=b;e!==f;e=e.nextSibling){b=c=e;for(var h=e.nextSibling;h!==f;h=h.nextSibling)0<d(c, | ||
h)&&(c=h);c!==e&&(m(a,c,b),e=c)}},a,b,c)}function za(a,b){return a._node.idx-b._node.idx}function la(a,b){var c=a.el,d=a.body,e=b.body;b=d[0];var f=d[d.length-1],g=(e[0]||u).el,e=(e[e.length-1]||u).el,h,k,l;a:for(;;){for(;;)if(g&&(k=g._node).parent!=a)h=g.nextSibling,null!=k.vm?k.vm.unmount(!0):A(c,g),g=h;else if(null==b)break a;else if(null==b.el)m(c,t(b),g),b=d[b.idx+1];else if(b.el===g)b=d[b.idx+1],g=g.nextSibling;else break;for(;;)if(e&&(l=e._node).parent!=a)h=e.previousSibling,null!=l.vm?l.vm.unmount(!0): | ||
A(c,e),e=h;else if(f==b)break a;else if(null==f.el)h=t(f),m(c,h,e?e.nextSibling:null),f=d[f.idx-1];else if(f.el===e)f=d[f.idx-1],e=e.previousSibling;else break;(h=xa(c,g,b,e,f))||(h=ya(c,g,e,za));g=h.lftSib;e=h.rgtSib}}function Aa(a,b,c,d){for(;c<b.length;c++){d=b[c];if(4==a.type&&null!=d.vm){var e=d.vm;if(e.view==a.view&&e.key==a.key)return d}if(d.el._node==d&&a.tag===d.tag&&a.type===d.type&&a.vm===d.vm&&(a.key===d.key||null==d.key))return d}return null}function Ba(a,b){a:{a=a.key;var c=0,d=b.length- | ||
1,e;if(2147483647>=d)for(;c<=d;)if(e=c+d>>1,b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;else for(;c<=d;)if(e=Math.floor((c+d)/2),b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;a=-1}return-1<a?b[a]:null}function N(a,b,c){b.hooks&&n("willRecycle",b,a);c=a.el=b.el;var d=b.body,e=a.body;c._node=a;if(2==a.type&&e!==d)c.nodeValue=e;else{null==a.attrs&&null==b.attrs||ia(a,b);var f=l(d),g=l(e);if(f)if(g){a.flags&4?(c=b.body.slice(),c.sort(Ca),d=Ba):(c=b.body,d=Aa);for(var h,e=0,f=a.body, | ||
g=0;g<f.length;g++){var k=f[g],m=k.type;3>=m?(h=d(k,c,e))&&N(k,h):4==m?(h=d(k,c,e))?h.vm._update(k.model,a,g):G(k.view,k.model,k.key,k.opts)._redraw(a,g,!1):5==m&&k.vm._update(k.model,a,g);a.list||null==h||h.idx!=e||e++}1!=a.type||a.flags&1||la(a,b)}else{if(e!==d)if(null!=e)a.raw?c.innerHTML=e:c.textContent=e;else for(;c.firstChild;)A(c,c.firstChild)}else g?(c.firstChild&&c.removeChild(c.firstChild),ja(a)):e!==d&&(a.raw?c.innerHTML=e:c.firstChild?c.firstChild.nodeValue=e:c.textContent=e);b.hooks&& | ||
n("didRecycle",b,a)}}function Ca(a,b){return a.key>b.key?1:a.key<b.key?-1:0}function ma(a){var b=new v;b.type=2;b.body=a;return b}function x(a,b,c,d){if(5!=a.type&&4!=a.type){a.parent=b;a.idx=c;a.vm=d;if(null!=a.ref){c=r(a);b=["refs"].concat(a.ref.split("."));for(var e;e=b.shift();)c[e]=0==b.length?a:c=c[e]||{}}if(a.hooks&&a.hooks.willRemove||d&&d.hooks&&d.hooks.willUnmount)for(d=a;d=d.parent;)d.flags|=2;if(l(a.body))for(d=a.body,b=0;b<d.length;b++)c=d[b],!1===c||null==c?d.splice(b--,1):l(c)?(e=b--, | ||
d.splice.apply(d,[e,1].concat(c))):(null==c.type&&(d[b]=c=ma(""+c)),2==c.type?null==c.body||""==c.body?d.splice(b--,1):0<b&&2==d[b-1].type?(d[b-1].body+=c.body,d.splice(b--,1)):x(c,a,b,null):x(c,a,b,null));else z(a.body)&&(a.body=F(a.body,r(a)))}}function B(a,b,c,d){var e=this;e.api={};e.view=a;e.model=b;e.key=null==c?b:c;a.prototype._isClass?(a=e.diff,null!=a&&a!=p.diff&&(e.diff=p.diff.bind(e),e.diff(a))):(a=a.call(e,e,b,c),w(a)?e.render=a:(a.diff&&(e.diff(a.diff),delete a.diff),y(e,a)));d&&(e.opts= | ||
d,d.hooks&&e.hook(d.hooks),d.diff&&e.diff(d.diff));e._redrawAsync=U(function(a){return e._redraw()});e._updateAsync=U(function(a){return e._update(a)})}function I(a){if(J.length)for(a=a.node,a&&a.el&&a.el.offsetHeight;a=J.shift();)a[0](a[1],a[2])}function O(a,b,c,d){var e,f;null==c?null!=b&&b.constructor==Object?e=b:f=b:(e=b,f=c);return ca(a,e,f,d)}function P(a,b,c,d){this.view=a;this.model=b;this.key=null==c?b:c;this.opts=d}function na(a,b,c,d){return new P(a,b,c,d)}function Q(a){this.vm=a}function oa(a){return new Q(a)} | ||
function pa(a){var b=new v;b.type=1;b.el=b.key=a;return b}function qa(a,b){a=a.body;if(l(a))for(var c=0;c<a.length;c++){var d=a[c];null!=d.vm?b.push(d.vm):qa(d,b)}return b}function ra(a,b){a.el=b;b._node=a;var c=a.attrs,d;for(d in c){var e=c[d],f=E(a.tag,d);"style"==d||"_"==d[0]||(0===d.lastIndexOf("on",0)?L(a,d,e):null!=e&&f&&M(a,d,e,f))}if(l(a.body)){b=b.firstChild;c=0;d=a.body[c];do 4==d.type?d=G(d.view,d.model,d.key,d.opts)._redraw(a,c,!1).node:5==d.type&&(d=d.node||d._redraw(a,c,!1).node),ra(d, | ||
b);while((b=b.nextSibling)&&(d=a.body[++c]))}}var R="undefined"!=typeof window,V=(R?window:{}).requestAnimationFrame,u={},l=Array.isArray,ua={animationIterationCount:!0,boxFlex:!0,boxFlexGroup:!0,columnCount:!0,counterIncrement:!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,tabSize:!0,transform:!0,transformOrigin:!0,widows:!0,zIndex:!0,zoom:!0},da={},va=/\[(\w+)(?:=(\w+))?\]/g,z=function(){return!1}, | ||
X=null,Y=null,Z=null,J=[],Da=v.prototype={constructor:v,type:null,vm:null,key:null,ref:null,data:null,hooks:null,raw:!1,ns:null,el:null,tag:null,attrs:null,body:null,flags:0,_class:null,idx:null,parent:null},H=R?document:null,ga={onevent:D},p=B.prototype={constructor:B,_isClass:!1,view:null,key:null,model:null,opts:null,node:null,hooks:null,render:null,parent:function(){return r(this.node.parent)},root:function(){for(var a=this.node;a.parent;)a=a.parent;return a.vm},api:null,refs:null,mount:function(a, | ||
b){if(b){for(;a.firstChild;)a.removeChild(a.firstChild);this._redraw(null,null,!1);a.nodeName.toLowerCase()!=this.node.tag?(t(this.node),m(a.parentNode,this.node.el,a),a.parentNode.removeChild(a)):m(a.parentNode,t(this.node,a),a)}else this._redraw(null,null),a&&m(a,this.node.el);a&&I(this);return this},unmount:function(a){var b=this.node;A(b.el.parentNode,b.el);a||I(this)},redraw:function(a){a?this._redraw():this._redrawAsync();return this},update:function(a,b){b?this._update(a):this._updateAsync(a); | ||
return this},_update:function(a,b,c,d){null!=a&&this.model!==a&&(this.hooks&&n("willUpdate",this,a),this.model=a);return this._redraw(b,c,d)},_redraw:function(a,b,c){var d=null==a,e=this.node&&this.node.el&&this.node.el.parentNode,f=this.node;if(e&&null!=this._diff&&this._diff())return f&&a&&(a.body[b]=f,f.idx=b,f.parent=a),this;e&&this.hooks&&n("willRedraw",this);this.refs=null;var g=this.render.call(this,this,this.model,this.key);this.node=g;a?(x(g,a,b,this),a.body[b]=g):f&&f.parent?(x(g,f.parent, | ||
f.idx,this),f.parent.body[f.idx]=g):x(g,null,null,this);!1!==c&&(f?f.tag!==g.tag?(f.vm=g.vm=null,a=f.el.parentNode,b=f.el.nextSibling,A(a,f.el),m(a,t(g),b),f.el=g.el,g.vm=this):N(g,f,d):t(g));e&&this.hooks&&n("didRedraw",this);d&&e&&I(this);return this},_redrawAsync:null,_updateAsync:null,hook:function(a){this.hooks=this.hooks||y({},this.hooks,a)}};P.prototype={constructor:P,type:4,view:null,model:null,key:null,opts:null};Q.prototype={constructor:Q,type:5,vm:null};var C={config:function(a){y(ga, | ||
a)},ViewModel:B,VNode:v,createView:G,defineElement:O,defineSvgElement:function(a,b,c,d){a=O(a,b,c,d);a.ns="http://www.w3.org/2000/svg";return a},defineText:ma,defineComment:function(a){var b=new v;b.type=3;b.body=a;return b},defineView:na,injectView:oa,injectElement:pa,FIXED_BODY:1,DEEP_REMOVE:2,KEYED_LIST:4};p._diff=null;p.diff=function(a){var b=this;if(w(a))var c=a;else var c=a.vals,d=a.then;var e=c.call(b,b,b.model,b.key,b.opts),f=l(e)?T:sa;b._diff=function(){var a=c.call(b,b,b.model,b.key,b.opts), | ||
h=f(e,a);h||(null!=d&&!1===d.call(b,b,e,a)&&(h=!0),e=a);return h}};Da.patch=function(a){var b;a:{if(null!=a.type){if(null!=this.vm){b=void 0;break a}x(a,this.parent,this.idx,null);this.parent.body[this.idx]=a;N(a,this);I(r(a))}else{b=Object.create(this);b.attrs=y({},this.attrs);a=y(this.attrs,a);if(null!=this._class){var c=a.class;a.class=null!=c&&""!=c?this._class+" "+c:this._class}ia(this,b)}b=void 0}return b};C.h=function(a){return(q(a)?O:w(a)?na:R&&a instanceof HTMLElement?pa:a instanceof B?oa: | ||
D).apply(null,arguments)};C.defineElementSpread=function(a){var b=arguments,c=b.length,d,e;if(1<c){d=1;var f=b[1];null!=f&&f.constructor==Object&&(e=b[1],d=2);d=c==d+1&&(q(b[d])||l(b[d]))?b[d]:S(b,d)}return ca(a,e,d)};p.events=null;p.emit=function(a){var b=arguments,c=this;do{var d=c.events;if(d=d?d[a]:null){d.apply(null,S(b,1));break}}while(c=c.parent())};p.on=function(a,b){null==this.events&&(this.events={});if(q(a))this.events[a]=b;else for(a in b=a,b)this.on(a,b[a])};p.body=function(){return qa(this.node, | ||
[])};"undefined"!=typeof flyd&&W({is:function(a){return flyd.isStream(a)},val:function(a){return a()},sub:function(a,b){return flyd.on(b,a)},unsub:function(a){return a.end(!0)}});C.streamCfg=W;C.prop=function(a,b,c,d){return function(e,f){"undefined"!=typeof e&&e!==a&&(a=e,!1!==f&&w(b)&&b.apply(c,d));return a}};p.attach=function(a){null==this.node&&this._redraw(null,null,!1);ra(this.node,a);return this};return C}); | ||
'use strict';(function(B,p){"object"===typeof exports&&"undefined"!==typeof module?module.exports=p():"function"===typeof define&&define.amd?define(p):B.domvm=p()})(this,function(){function B(a){a=typeof a;return"string"===a||"number"===a}function p(a){return"function"===typeof a}function y(a){for(var b=arguments,c=1;c<b.length;c++)for(var d in b[c])a[d]=b[c][d];return a}function la(a,b){for(var c=[];b<a.length;b++)c.push(a[b]);return c}function ma(a,b){for(var c in a)if(a[c]!==b[c])return!1;return!0} | ||
function P(a,b){var c=a.length;if(b.length!=c)return!1;for(var d=0;d<c;d++)if(a[d]!==b[d])return!1;return!0}function Q(a){function b(){c=0;a.apply(d,e)}if(!R)return a;var c,d,e;return function(){d=this;e=arguments;c||(c=R(b))}}function na(a,b,c){return function(){return a.apply(c,b)}}function C(a,b){switch(b){case "value":case "checked":case "selected":case "selectedIndex":return!0}return!1}function r(a){for(a=a||u;null==a.vm&&a.parent;)a=a.parent;return a.vm}function S(a){z=a.is;T=a.val;U=a.sub; | ||
V=a.unsub}function D(a,b){var c=U(a,function(a){c&&(null!=b.node&&b.redraw(),V(c))});return T(a)}function W(a,b){var c=(a.attrs||u).style;b=b?(b.attrs||u).style:null;if(null==c||B(c))a.el.style.cssText=c;else{for(var d in c){var e=c[d];z(e)&&(e=D(e,r(a)));if(null==b||null!=e&&e!==b[d]){var f=a.el.style,g=d,h;h=d;h=isNaN(e)||oa[h]?e:e+"px";f[g]=h}}if(b)for(var k in b)null==c[k]&&(a.el.style[k]="")}}function X(a,b,c,d,e){if(a)e?(a=c.parent,a&&a.el&&a.el.offsetHeight):I.push([b,c,d]);else return b(c, | ||
d)}function l(a,b,c,d){var e=b.hooks[a];if(e){var f=0===a.lastIndexOf("did",0);return n(e)?e.map(function(a){return X(f,a,b,c)}):X(f,e,b,c,d)}}function v(){}function Y(a){var b=a.hooks,c=a.vm;c&&c.hooks&&l("willUnmount",c);b=b&&l("willRemove",a);if(a.flags&2&&n(a.body))for(c=0;c<a.body.length;c++)Y(a.body[c]);return b}function J(a,b,c){var d=b._node,e=d.hooks,f=d.vm;if(d.flags&2&&n(d.body))for(var g=0;g<d.body.length;g++)J(b,d.body[g].el);a.removeChild(b);e&&l("didRemove",d,null,c);f&&f.hooks&&l("didUnmount", | ||
f,null,c)}function A(a,b){var c=Y(b._node);null!=c&&"object"===typeof c&&p(c.then)?c.then(na(J,[a,b,!0])):J(a,b)}function m(a,b,c){var d=b._node,e=d.hooks,f=null!=b.parentNode,g=(b==c||!f)&&d.vm;g&&g.hooks&&l("willMount",g);e&&l(f?"willReinsert":"willInsert",d);a.insertBefore(b,c);e&&l(f?"didReinsert":"didInsert",d);g&&g.hooks&&l("didMount",g)}function Z(a,b,c){var d;for(d=a.target;null==d._node;)d=d.parentNode;d=d._node;var e=r(d);b=b.apply(null,c.concat(a,d,e));aa.onevent.apply(null,[a,d,e].concat(c)); | ||
!1===b&&(a.preventDefault(),a.stopPropagation())}function ba(a,b){return function(c){Z(c,a,b)}}function pa(a){return function(b){for(var c in a)if(b.target.matches(c)){var d=a[c],e=n(d),f=e?d[0]:d,d=e?d.slice(1):[];Z(b,f,d)}}}function K(a,b,c,d){c!==d&&(a=a.el,n(c)?null!=d&&P(c,d)||(c=ba(c[0],c.slice(1)),a[b]=c):(c=p(c)&&c!=d?ba(c,[]):pa(c),a[b]=c))}function L(a,b,c,d){var e=a.el;null==c?a.el.removeAttribute(b):null!=a.ns?e.setAttribute(b,c):"class"==b?e.className=c:"id"==b||"boolean"==typeof c|| | ||
d?e[b]=c:"."==b[0]?e[b.substr(1)]=c:e.setAttribute(b,c)}function ca(a,b){var c=a.attrs||u,d=b.attrs||u,e;for(e in c){var f=c[e],g=C(a.tag,e),h=g?a.el[e]:d[e];z(f)&&(c[e]=f=D(f,r(a)));f!==h&&("style"==e?W(a,b):"_"==e[0]||(0===e.lastIndexOf("on",0)?K(a,e,f,h):L(a,e,f,g)))}for(e in d)e in c||"_"==e[0]||(b=a,d=e,C(a.tag,e)||0===e.lastIndexOf("on",0)?b.el[d]="":b.el.removeAttribute(d))}function E(a,b,c,d){if(4==a.type)b=a.model,c=a.key,d=a.opts,a=a.view;else if(a.prototype._isClass)return new a(b,c,d); | ||
return new F(a,b,c,d)}function da(a){for(var b=0;b<a.body.length;b++){var c=a.body[b],d=c.type;3>=d?m(a.el,t(c)):4==d?(c=E(c.view,c.model,c.key,c.opts)._redraw(a,b,!1),m(a.el,t(c.node))):5==d&&(c=c.vm,c._redraw(a,b),m(a.el,c.node.el))}}function t(a,b){if(null==a.el)if(1==a.type){if(!b){b=a.tag;var c=a.ns;b=null!=c?G.createElementNS(c,b):G.createElement(b)}a.el=b;if(null!=a.attrs){b=a.attrs;for(var d in b){var c=b[d],e=C(a.tag,d);z(c)&&(b[d]=c=D(c,r(a)));"style"==d?W(a):"_"==d[0]||(0===d.lastIndexOf("on", | ||
0)?K(a,d,c):null!=c&&L(a,d,c,e))}}n(a.body)?da(a):null!=a.body&&""!==a.body&&(a.raw?a.el.innerHTML=a.body:a.el.textContent=a.body)}else 2==a.type?a.el=b||G.createTextNode(a.body):3==a.type&&(a.el=b||G.createComment(a.body));a.el._node=a;return a.el}function ea(a,b,c,d){c=c.previousSibling;d=d.nextSibling;a(c,d);return{lftSib:c?c.nextSibling:b.firstChild,rgtSib:d?d.previousSibling:b.lastChild}}function qa(a,b,c,d,e){var f=e.idx==c.idx+1,g=f?!1:b._node==e,h=f?!0:d._node==c;return g||h?ea(function(c, | ||
e){h&&m(a,d,b);g&&m(a,b,e)},a,b,d):null}function ra(a,b,c,d){return ea(function(c,f){for(var e=b;e!==f;e=e.nextSibling){b=c=e;for(var h=e.nextSibling;h!==f;h=h.nextSibling)0<d(c,h)&&(c=h);c!==e&&(m(a,c,b),e=c)}},a,b,c)}function sa(a,b){return a._node.idx-b._node.idx}function fa(a,b){var c=a.el,d=a.body,e=b.body;b=d[0];var f=d[d.length-1],g=(e[0]||u).el,e=(e[e.length-1]||u).el,h,k,l;a:for(;;){for(;;)if(g&&(k=g._node).parent!=a)h=g.nextSibling,null!=k.vm?k.vm.unmount(!0):A(c,g),g=h;else if(null==b)break a; | ||
else if(null==b.el)m(c,t(b),g),b=d[b.idx+1];else if(b.el===g)b=d[b.idx+1],g=g.nextSibling;else break;for(;;)if(e&&(l=e._node).parent!=a)h=e.previousSibling,null!=l.vm?l.vm.unmount(!0):A(c,e),e=h;else if(f==b)break a;else if(null==f.el)h=t(f),m(c,h,e?e.nextSibling:null),f=d[f.idx-1];else if(f.el===e)f=d[f.idx-1],e=e.previousSibling;else break;(h=qa(c,g,b,e,f))||(h=ra(c,g,e,sa));g=h.lftSib;e=h.rgtSib}}function ta(a,b,c,d){for(;c<b.length;c++){d=b[c];if(4==a.type&&null!=d.vm){var e=d.vm;if(e.view==a.view&& | ||
e.key==a.key)return d}if(d.el._node==d&&a.tag===d.tag&&a.type===d.type&&a.vm===d.vm&&(a.key===d.key||null==d.key))return d}return null}function ua(a,b){a:{a=a.key;var c=0,d=b.length-1,e;if(2147483647>=d)for(;c<=d;)if(e=c+d>>1,b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;else for(;c<=d;)if(e=Math.floor((c+d)/2),b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;a=-1}return-1<a?b[a]:null}function M(a,b,c){b.hooks&&l("willRecycle",b,a);c=a.el=b.el;var d=b.body,e=a.body;c._node=a;if(2==a.type&& | ||
e!==d)c.nodeValue=e;else{null==a.attrs&&null==b.attrs||ca(a,b);var f=n(d),g=n(e);if(f)if(g){a.flags&4?(c=b.body.slice(),c.sort(va),d=ua):(c=b.body,d=ta);for(var h,e=0,f=a.body,g=0;g<f.length;g++){var k=f[g],m=k.type;3>=m?(h=d(k,c,e))&&M(k,h):4==m?(h=d(k,c,e))?h.vm._update(k.model,a,g):E(k.view,k.model,k.key,k.opts)._redraw(a,g,!1):5==m&&k.vm._update(k.model,a,g);a.list||null==h||h.idx!=e||e++}1!=a.type||a.flags&1||fa(a,b)}else{if(e!==d)if(null!=e)a.raw?c.innerHTML=e:c.textContent=e;else for(;c.firstChild;)A(c, | ||
c.firstChild)}else g?(c.firstChild&&c.removeChild(c.firstChild),da(a)):e!==d&&(a.raw?c.innerHTML=e:c.firstChild?c.firstChild.nodeValue=e:c.textContent=e);b.hooks&&l("didRecycle",b,a)}}function va(a,b){return a.key>b.key?1:a.key<b.key?-1:0}function ga(a){var b=new v;b.type=2;b.body=a;return b}function w(a,b,c,d){if(5!=a.type&&4!=a.type){a.parent=b;a.idx=c;a.vm=d;if(null!=a.ref){c=r(a);b=["refs"].concat(a.ref.split("."));for(var e;e=b.shift();)c[e]=0==b.length?a:c=c[e]||{}}if(a.hooks&&a.hooks.willRemove|| | ||
d&&d.hooks&&d.hooks.willUnmount)for(d=a;d=d.parent;)d.flags|=2;if(n(a.body))for(d=a.body,b=0;b<d.length;b++)c=d[b],!1===c||null==c?d.splice(b--,1):n(c)?(e=b--,d.splice.apply(d,[e,1].concat(c))):(null==c.type&&(d[b]=c=ga(""+c)),2==c.type?null==c.body||""==c.body?d.splice(b--,1):0<b&&2==d[b-1].type?(d[b-1].body+=c.body,d.splice(b--,1)):w(c,a,b,null):w(c,a,b,null));else z(a.body)&&(a.body=D(a.body,r(a)))}}function F(a,b,c,d){var e=this;e.view=a;e.model=b;e.key=null==c?b:c;a.prototype._isClass?(a=e.diff, | ||
null!=a&&a!=q.diff&&(e.diff=q.diff.bind(e),e.diff(a))):(a=a.call(e,e,b,c,d),p(a)?e.render=a:(a.diff&&(e.diff(a.diff),delete a.diff),y(e,a)));d&&(e.opts=d,d.hooks&&e.hook(d.hooks),d.diff&&e.diff(d.diff));e._redrawAsync=Q(function(a){return e._redraw()});e._updateAsync=Q(function(a){return e._update(a)});(a=e.hooks)&&a.didInit&&a.didInit.call(e,e,b,c,d)}function H(a){if(I.length)for(a=a.node,a&&a.el&&a.el.offsetHeight;a=I.shift();)a[0](a[1],a[2])}function ha(a,b,c,d){var e,f;null==c?null!=b&&b.constructor== | ||
Object?e=b:f=b:(e=b,f=c);c=e;b=new v;b.type=1;null!=d&&(b.flags=d);null!=c&&(null!=c._key&&(b.key=c._key),null!=c._ref&&(b.ref=c._ref),null!=c._hooks&&(b.hooks=c._hooks),null!=c._raw&&(b.raw=c._raw),null!=c._data&&(b.data=c._data),null!=c._flags&&(b.flags=c._flags),null==b.key&&(null!=b.ref?b.key=b.ref:null!=c.id?b.key=c.id:null!=c.name&&(b.key=c.name)),b.attrs=c);d=ia[a];if(null==d){var g,h,k;for(ia[a]=d={tag:(g=a.match(/^[-\w]+/))?g[0]:"div",id:(h=a.match(/#([-\w]+)/))?h[1]:null,class:(k=a.match(/\.([-\w.]+)/))? | ||
k[1].replace(/\./g," "):null,attrs:null};g=wa.exec(a);)null==d.attrs&&(d.attrs={}),d.attrs[g[1]]=g[2]||""}a=d;b.tag=a.tag;if(a.id||a.class||a.attrs){g=b.attrs||{};a.id&&null==g.id&&(g.id=a.id);a.class&&(b._class=a.class,g.class=a.class+(null!=g.class?" "+g.class:""));if(a.attrs)for(var l in a.attrs)null!=g[l]||(g[l]=a.attrs[l]);b.attrs=g}null!=f&&(b.body=f);return b}function N(a,b,c,d){this.view=a;this.model=b;this.key=null==c?b:c;this.opts=d}function O(a){this.vm=a}function ja(a,b){a=a.body;if(n(a))for(var c= | ||
0;c<a.length;c++){var d=a[c];null!=d.vm?b.push(d.vm):ja(d,b)}return b}function ka(a,b){a.el=b;b._node=a;var c=a.attrs,d;for(d in c){var e=c[d],f=C(a.tag,d);"style"==d||"_"==d[0]||(0===d.lastIndexOf("on",0)?K(a,d,e):null!=e&&f&&L(a,d,e,f))}if(n(a.body)){b=b.firstChild;c=0;d=a.body[c];do 4==d.type?d=E(d.view,d.model,d.key,d.opts)._redraw(a,c,!1).node:5==d.type&&(d=d.node||d._redraw(a,c,!1).node),ka(d,b);while((b=b.nextSibling)&&(d=a.body[++c]))}}var x="undefined"!=typeof window,R=(x?window:{}).requestAnimationFrame, | ||
u={},n=Array.isArray,oa={animationIterationCount:!0,boxFlex:!0,boxFlexGroup:!0,columnCount:!0,counterIncrement:!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,tabSize:!0,transform:!0,transformOrigin:!0,widows:!0,zIndex:!0,zoom:!0},ia={},wa=/\[(\w+)(?:=(\w+))?\]/g,z=function(){return!1},T=null,U=null,V=null,I=[],xa=v.prototype={constructor:v,type:null,vm:null,key:null,ref:null,data:null, | ||
hooks:null,raw:!1,ns:null,el:null,tag:null,attrs:null,body:null,flags:0,_class:null,idx:null,parent:null},G=x?document:null,aa={onevent:function(){}},q=F.prototype={constructor:F,_isClass:!1,view:null,key:null,model:null,opts:null,node:null,hooks:null,render:null,parent:function(){return r(this.node.parent)},root:function(){for(var a=this.node;a.parent;)a=a.parent;return a.vm},api:null,refs:null,mount:function(a,b){if(b){for(;a.firstChild;)a.removeChild(a.firstChild);this._redraw(null,null,!1);a.nodeName.toLowerCase()!= | ||
this.node.tag?(t(this.node),m(a.parentNode,this.node.el,a),a.parentNode.removeChild(a)):m(a.parentNode,t(this.node,a),a)}else this._redraw(null,null),a&&m(a,this.node.el);a&&H(this);return this},unmount:function(a){var b=this.node;A(b.el.parentNode,b.el);a||H(this)},redraw:function(a){a?this._redraw():this._redrawAsync();return this},update:function(a,b){b?this._update(a):this._updateAsync(a);return this},_update:function(a,b,c,d){null!=a&&this.model!==a&&(this.hooks&&l("willUpdate",this,a),this.model= | ||
a);return this._redraw(b,c,d)},_redraw:function(a,b,c){var d=null==a,e=this.node&&this.node.el&&this.node.el.parentNode,f=this.node;if(e&&null!=this._diff&&this._diff())return f&&a&&(a.body[b]=f,f.idx=b,f.parent=a),this;e&&this.hooks&&l("willRedraw",this);this.refs=null;var g=this.render.call(this,this,this.model,this.key);!1!==this.key&&(g.key=this.key);this.node=g;a?(w(g,a,b,this),a.body[b]=g):f&&f.parent?(w(g,f.parent,f.idx,this),f.parent.body[f.idx]=g):w(g,null,null,this);!1!==c&&(f?f.tag!==g.tag? | ||
(f.vm=g.vm=null,a=f.el.parentNode,b=f.el.nextSibling,A(a,f.el),m(a,t(g),b),f.el=g.el,g.vm=this):M(g,f,d):t(g));e&&this.hooks&&l("didRedraw",this);d&&e&&H(this);return this},_redrawAsync:null,_updateAsync:null,hook:function(a){this.hooks=this.hooks||y({},this.hooks,a)}};N.prototype={constructor:N,type:4,view:null,model:null,key:null,opts:null};O.prototype={constructor:O,type:5,vm:null};x={config:function(a){y(aa,a)},ViewModel:F,VNode:v,createView:E,defineElement:ha,defineSvgElement:function(a, | ||
b,c,d){a=ha(a,b,c,d);a.ns="http://www.w3.org/2000/svg";return a},defineText:ga,defineComment:function(a){var b=new v;b.type=3;b.body=a;return b},defineView:function(a,b,c,d){return new N(a,b,c,d)},injectView:function(a){return new O(a)},injectElement:function(a){var b=new v;b.type=1;b.el=b.key=a;return b},FIXED_BODY:1,DEEP_REMOVE:2,KEYED_LIST:4};q._diff=null;q.diff=function(a){var b=this;if(p(a))var c=a;else var c=a.vals,d=a.then;var e=c.call(b,b,b.model,b.key,b.opts),f=n(e)?P:ma;b._diff=function(){var a= | ||
c.call(b,b,b.model,b.key,b.opts),h=f(e,a);h||(null!=d&&!1===d.call(b,b,e,a)&&(h=!0),e=a);return h}};xa.patch=function(a){var b;a:{if(null!=a.type){if(null!=this.vm){b=void 0;break a}w(a,this.parent,this.idx,null);this.parent.body[this.idx]=a;M(a,this);H(r(a))}else{b=Object.create(this);b.attrs=y({},this.attrs);a=y(this.attrs,a);if(null!=this._class){var c=a.class;a.class=null!=c&&""!=c?this._class+" "+c:this._class}ca(this,b)}b=void 0}return b};q.events=null;q.emit=function(a){var b=arguments,c=this; | ||
do{var d=c.events;if(d=d?d[a]:null){d.apply(null,la(b,1));break}}while(c=c.parent())};q.on=function(a,b){null==this.events&&(this.events={});if(B(a))this.events[a]=b;else for(a in b=a,b)this.on(a,b[a])};q.body=function(){return ja(this.node,[])};"undefined"!=typeof flyd&&S({is:function(a){return flyd.isStream(a)},val:function(a){return a()},sub:function(a,b){return flyd.on(b,a)},unsub:function(a){return a.end(!0)}});x.streamCfg=S;x.prop=function(a,b,c,d){return function(e,f){"undefined"!=typeof e&& | ||
e!==a&&(a=e,!1!==f&&p(b)&&b.apply(c,d));return a}};q.attach=function(a){null==this.node&&this._redraw(null,null,!1);ka(this.node,a);return this};return x}); |
@@ -7,3 +7,3 @@ /** | ||
* A thin, fast, dependency-free vdom view layer | ||
* @preserve https://github.com/leeoniya/domvm (v2.1.1, full) | ||
* @preserve https://github.com/leeoniya/domvm (v2.1.3, full) | ||
*/ | ||
@@ -44,2 +44,6 @@ | ||
function isSet(val) { | ||
return val != null; | ||
} | ||
function isPlainObj(val) { | ||
@@ -66,6 +70,4 @@ return val != null && val.constructor == Object; // && typeof val == "object" | ||
function isElem(val) { | ||
return ENV_DOM && val instanceof HTMLElement; | ||
} | ||
function assignObj(targ) { | ||
@@ -447,6 +449,2 @@ var args = arguments; | ||
function isSet(val) { | ||
return val != null; | ||
} | ||
// (de)optimization flags | ||
@@ -962,3 +960,3 @@ | ||
// from_right: | ||
while(1) { | ||
while (1) { | ||
// if (rgtSib == lftEnd) | ||
@@ -1240,4 +1238,2 @@ // break converge; | ||
vm.api = {}; | ||
vm.view = view; | ||
@@ -1248,3 +1244,3 @@ vm.model = model; | ||
if (!view.prototype._isClass) { | ||
var out = view.call(vm, vm, model, key); // , opts | ||
var out = view.call(vm, vm, model, key, opts); | ||
@@ -1271,2 +1267,3 @@ if (isFunc(out)) | ||
} | ||
// remove this? | ||
@@ -1286,2 +1283,7 @@ if (opts) { | ||
var hooks = vm.hooks; | ||
if (hooks && hooks.didInit) | ||
{ hooks.didInit.call(vm, vm, model, key, opts); } | ||
// this.update(model, parent, idx, parentVm, false); | ||
@@ -1445,2 +1447,5 @@ | ||
if (vm.key !== false) | ||
{ vnew.key = vm.key; } | ||
// console.log(vm.key); | ||
@@ -1704,42 +1709,4 @@ | ||
// does not handle defineComment, defineText, defineSVG (ambiguous); use plain text vals or explicit factories in templates. | ||
// does not handle defineElementSpread (not available in all builds); use exlicit factories in templates. | ||
function h(a) { | ||
return ( | ||
isVal(a) ? defineElement : | ||
isFunc(a) ? defineView : // todo: es6 class constructor | ||
isElem(a) ? injectElement : | ||
a instanceof ViewModel ? injectView : | ||
noop | ||
).apply(null, arguments); | ||
} | ||
function defineElementSpread(tag) { | ||
var args = arguments; | ||
var len = args.length; | ||
var body, attrs; | ||
if (len > 1) { | ||
var bodyIdx = 1; | ||
if (isPlainObj(args[1])) { | ||
attrs = args[1]; | ||
bodyIdx = 2; | ||
} | ||
if (len == bodyIdx + 1 && (isVal(args[bodyIdx]) || isArr(args[bodyIdx]))) | ||
{ body = args[bodyIdx]; } | ||
else | ||
{ body = sliceArgs(args, bodyIdx); } | ||
} | ||
return initElementNode(tag, attrs, body); | ||
} | ||
// #destub: cssTag,autoPx | ||
nano.h = h; | ||
nano.defineElementSpread = defineElementSpread; | ||
ViewModelProto.events = null; | ||
@@ -1746,0 +1713,0 @@ ViewModelProto.emit = emit; |
/* | ||
https://github.com/leeoniya/domvm (v2.1.1, full) | ||
https://github.com/leeoniya/domvm (v2.1.3, full) | ||
*/ | ||
'use strict';(function(G,q){"object"===typeof exports&&"undefined"!==typeof module?module.exports=q():"function"===typeof define&&define.amd?define(q):G.domvm=q()})(this,function(){function G(){}function q(a){a=typeof a;return"string"===a||"number"===a}function w(a){return"function"===typeof a}function y(a){for(var b=arguments,c=1;c<b.length;c++)for(var d in b[c])a[d]=b[c][d];return a}function U(a,b){for(var c=[];b<a.length;b++)c.push(a[b]);return c}function xa(a,b){for(var c in a)if(a[c]!==b[c])return!1; | ||
return!0}function V(a,b){var c=a.length;if(b.length!=c)return!1;for(var d=0;d<c;d++)if(a[d]!==b[d])return!1;return!0}function W(a){function b(){c=0;a.apply(d,e)}if(!X)return a;var c,d,e;return function(){d=this;e=arguments;c||(c=X(b))}}function ya(a,b,c){return function(){return a.apply(c,b)}}function z(a,b){switch(b){case "value":case "checked":case "selected":case "selectedIndex":return!0}return!1}function r(a){for(a=a||u;null==a.vm&&a.parent;)a=a.parent;return a.vm}function Y(a,b){return isNaN(b)|| | ||
za[a]?b:b+"px"}function Z(a){A=a.is;aa=a.val;ba=a.sub;ca=a.unsub}function H(a,b){var c=ba(a,function(a){c&&(null!=b.node&&b.redraw(),ca(c))});return aa(a)}function da(a,b){var c=(a.attrs||u).style;b=b?(b.attrs||u).style:null;if(null==c||q(c))a.el.style.cssText=c;else{for(var d in c){var e=c[d];A(e)&&(e=H(e,r(a)));if(null==b||null!=e&&e!==b[d])a.el.style[d]=Y(d,e)}if(b)for(var f in b)null==c[f]&&(a.el.style[f]="")}}function ea(a,b,c,d,e){if(a)e?(a=c.parent,a&&a.el&&a.el.offsetHeight):K.push([b,c,d]); | ||
else return b(c,d)}function n(a,b,c,d){var e=b.hooks[a];if(e){var f=0===a.lastIndexOf("did",0);return k(e)?e.map(function(a){return ea(f,a,b,c)}):ea(f,e,b,c,d)}}function v(){}function fa(a,b,c,d){var e=new v;e.type=1;null!=d&&(e.flags=d);null!=b&&(null!=b._key&&(e.key=b._key),null!=b._ref&&(e.ref=b._ref),null!=b._hooks&&(e.hooks=b._hooks),null!=b._raw&&(e.raw=b._raw),null!=b._data&&(e.data=b._data),null!=b._flags&&(e.flags=b._flags),null==e.key&&(null!=e.ref?e.key=e.ref:null!=b.id?e.key=b.id:null!= | ||
b.name&&(e.key=b.name)),e.attrs=b);b=ga[a];if(null==b){var f,g,h;for(ga[a]=b={tag:(f=a.match(/^[-\w]+/))?f[0]:"div",id:(g=a.match(/#([-\w]+)/))?g[1]:null,class:(h=a.match(/\.([-\w.]+)/))?h[1].replace(/\./g," "):null,attrs:null};f=Aa.exec(a);)null==b.attrs&&(b.attrs={}),b.attrs[f[1]]=f[2]||""}a=b;e.tag=a.tag;if(a.id||a.class||a.attrs){f=e.attrs||{};a.id&&null==f.id&&(f.id=a.id);a.class&&(e._class=a.class,f.class=a.class+(null!=f.class?" "+f.class:""));if(a.attrs)for(var l in a.attrs)null==f[l]&&(f[l]= | ||
a.attrs[l]);e.attrs=f}null!=c&&(e.body=c);return e}function ha(a){var b=a.hooks,c=a.vm;c&&c.hooks&&n("willUnmount",c);b=b&&n("willRemove",a);if(a.flags&2&&k(a.body))for(c=0;c<a.body.length;c++)ha(a.body[c]);return b}function L(a,b,c){var d=b._node,e=d.hooks,f=d.vm;if(d.flags&2&&k(d.body))for(var g=0;g<d.body.length;g++)L(b,d.body[g].el);a.removeChild(b);e&&n("didRemove",d,null,c);f&&f.hooks&&n("didUnmount",f,null,c)}function B(a,b){var c=ha(b._node);null!=c&&"object"===typeof c&&w(c.then)?c.then(ya(L, | ||
[a,b,!0])):L(a,b)}function m(a,b,c){var d=b._node,e=d.hooks,f=null!=b.parentNode,g=(b==c||!f)&&d.vm;g&&g.hooks&&n("willMount",g);e&&n(f?"willReinsert":"willInsert",d);a.insertBefore(b,c);e&&n(f?"didReinsert":"didInsert",d);g&&g.hooks&&n("didMount",g)}function ia(a,b,c){var d;for(d=a.target;null==d._node;)d=d.parentNode;d=d._node;var e=r(d);b=b.apply(null,c.concat(a,d,e));ja.onevent.apply(null,[a,d,e].concat(c));!1===b&&(a.preventDefault(),a.stopPropagation())}function ka(a,b){return function(c){ia(c, | ||
a,b)}}function Ba(a){return function(b){for(var c in a)if(b.target.matches(c)){var d=a[c],e=k(d),f=e?d[0]:d,d=e?d.slice(1):[];ia(b,f,d)}}}function M(a,b,c,d){c!==d&&(a=a.el,k(c)?null!=d&&V(c,d)||(c=ka(c[0],c.slice(1)),a[b]=c):(c=w(c)&&c!=d?ka(c,[]):Ba(c),a[b]=c))}function N(a,b,c,d){var e=a.el;null==c?a.el.removeAttribute(b):null!=a.ns?e.setAttribute(b,c):"class"==b?e.className=c:"id"==b||"boolean"==typeof c||d?e[b]=c:"."==b[0]?e[b.substr(1)]=c:e.setAttribute(b,c)}function la(a,b){var c=a.attrs|| | ||
u,d=b.attrs||u,e;for(e in c){var f=c[e],g=z(a.tag,e),h=g?a.el[e]:d[e];A(f)&&(c[e]=f=H(f,r(a)));f!==h&&("style"==e?da(a,b):"_"==e[0]||(0===e.lastIndexOf("on",0)?M(a,e,f,h):N(a,e,f,g)))}for(e in d)e in c||"_"==e[0]||(b=a,d=e,z(a.tag,e)||0===e.lastIndexOf("on",0)?b.el[d]="":b.el.removeAttribute(d))}function C(a,b,c,d){if(4==a.type)b=a.model,c=a.key,d=a.opts,a=a.view;else if(a.prototype._isClass)return new a(b,c,d);return new D(a,b,c,d)}function ma(a){for(var b=0;b<a.body.length;b++){var c=a.body[b], | ||
d=c.type;3>=d?m(a.el,t(c)):4==d?(c=C(c.view,c.model,c.key,c.opts)._redraw(a,b,!1),m(a.el,t(c.node))):5==d&&(c=c.vm,c._redraw(a,b),m(a.el,c.node.el))}}function t(a,b){if(null==a.el)if(1==a.type){if(!b){b=a.tag;var c=a.ns;b=null!=c?I.createElementNS(c,b):I.createElement(b)}a.el=b;if(null!=a.attrs){b=a.attrs;for(var d in b){var c=b[d],e=z(a.tag,d);A(c)&&(b[d]=c=H(c,r(a)));"style"==d?da(a):"_"==d[0]||(0===d.lastIndexOf("on",0)?M(a,d,c):null!=c&&N(a,d,c,e))}}k(a.body)?ma(a):null!=a.body&&""!==a.body&& | ||
(a.raw?a.el.innerHTML=a.body:a.el.textContent=a.body)}else 2==a.type?a.el=b||I.createTextNode(a.body):3==a.type&&(a.el=b||I.createComment(a.body));a.el._node=a;return a.el}function na(a,b,c,d){c=c.previousSibling;d=d.nextSibling;a(c,d);return{lftSib:c?c.nextSibling:b.firstChild,rgtSib:d?d.previousSibling:b.lastChild}}function Ca(a,b,c,d,e){var f=e.idx==c.idx+1,g=f?!1:b._node==e,h=f?!0:d._node==c;return g||h?na(function(c,e){h&&m(a,d,b);g&&m(a,b,e)},a,b,d):null}function Da(a,b,c,d){return na(function(c, | ||
f){for(var e=b;e!==f;e=e.nextSibling){b=c=e;for(var h=e.nextSibling;h!==f;h=h.nextSibling)0<d(c,h)&&(c=h);c!==e&&(m(a,c,b),e=c)}},a,b,c)}function Ea(a,b){return a._node.idx-b._node.idx}function oa(a,b){var c=a.el,d=a.body,e=b.body;b=d[0];var f=d[d.length-1],g=(e[0]||u).el,e=(e[e.length-1]||u).el,h,l,k;a:for(;;){for(;;)if(g&&(l=g._node).parent!=a)h=g.nextSibling,null!=l.vm?l.vm.unmount(!0):B(c,g),g=h;else if(null==b)break a;else if(null==b.el)m(c,t(b),g),b=d[b.idx+1];else if(b.el===g)b=d[b.idx+1], | ||
g=g.nextSibling;else break;for(;;)if(e&&(k=e._node).parent!=a)h=e.previousSibling,null!=k.vm?k.vm.unmount(!0):B(c,e),e=h;else if(f==b)break a;else if(null==f.el)h=t(f),m(c,h,e?e.nextSibling:null),f=d[f.idx-1];else if(f.el===e)f=d[f.idx-1],e=e.previousSibling;else break;(h=Ca(c,g,b,e,f))||(h=Da(c,g,e,Ea));g=h.lftSib;e=h.rgtSib}}function Fa(a,b,c,d){for(;c<b.length;c++){d=b[c];if(4==a.type&&null!=d.vm){var e=d.vm;if(e.view==a.view&&e.key==a.key)return d}if(d.el._node==d&&a.tag===d.tag&&a.type===d.type&& | ||
a.vm===d.vm&&(a.key===d.key||null==d.key))return d}return null}function Ga(a,b){a:{a=a.key;var c=0,d=b.length-1,e;if(2147483647>=d)for(;c<=d;)if(e=c+d>>1,b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;else for(;c<=d;)if(e=Math.floor((c+d)/2),b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;a=-1}return-1<a?b[a]:null}function O(a,b,c){b.hooks&&n("willRecycle",b,a);c=a.el=b.el;var d=b.body,e=a.body;c._node=a;if(2==a.type&&e!==d)c.nodeValue=e;else{null==a.attrs&&null==b.attrs||la(a,b);var f= | ||
k(d),g=k(e);if(f)if(g){a.flags&4?(c=b.body.slice(),c.sort(Ha),d=Ga):(c=b.body,d=Fa);for(var h,e=0,f=a.body,g=0;g<f.length;g++){var l=f[g],m=l.type;3>=m?(h=d(l,c,e))&&O(l,h):4==m?(h=d(l,c,e))?h.vm._update(l.model,a,g):C(l.view,l.model,l.key,l.opts)._redraw(a,g,!1):5==m&&l.vm._update(l.model,a,g);a.list||null==h||h.idx!=e||e++}1!=a.type||a.flags&1||oa(a,b)}else{if(e!==d)if(null!=e)a.raw?c.innerHTML=e:c.textContent=e;else for(;c.firstChild;)B(c,c.firstChild)}else g?(c.firstChild&&c.removeChild(c.firstChild), | ||
ma(a)):e!==d&&(a.raw?c.innerHTML=e:c.firstChild?c.firstChild.nodeValue=e:c.textContent=e);b.hooks&&n("didRecycle",b,a)}}function Ha(a,b){return a.key>b.key?1:a.key<b.key?-1:0}function pa(a){var b=new v;b.type=2;b.body=a;return b}function x(a,b,c,d){if(5!=a.type&&4!=a.type){a.parent=b;a.idx=c;a.vm=d;if(null!=a.ref){c=r(a);b=["refs"].concat(a.ref.split("."));for(var e;e=b.shift();)c[e]=0==b.length?a:c=c[e]||{}}if(a.hooks&&a.hooks.willRemove||d&&d.hooks&&d.hooks.willUnmount)for(d=a;d=d.parent;)d.flags|= | ||
2;if(k(a.body))for(d=a.body,b=0;b<d.length;b++)c=d[b],!1===c||null==c?d.splice(b--,1):k(c)?(e=b--,d.splice.apply(d,[e,1].concat(c))):(null==c.type&&(d[b]=c=pa(""+c)),2==c.type?null==c.body||""==c.body?d.splice(b--,1):0<b&&2==d[b-1].type?(d[b-1].body+=c.body,d.splice(b--,1)):x(c,a,b,null):x(c,a,b,null));else A(a.body)&&(a.body=H(a.body,r(a)))}}function D(a,b,c,d){var e=this;e.api={};e.view=a;e.model=b;e.key=null==c?b:c;a.prototype._isClass?(a=e.diff,null!=a&&a!=p.diff&&(e.diff=p.diff.bind(e),e.diff(a))): | ||
(a=a.call(e,e,b,c),w(a)?e.render=a:(a.diff&&(e.diff(a.diff),delete a.diff),y(e,a)));d&&(e.opts=d,d.hooks&&e.hook(d.hooks),d.diff&&e.diff(d.diff));e._redrawAsync=W(function(a){return e._redraw()});e._updateAsync=W(function(a){return e._update(a)})}function J(a){if(K.length)for(a=a.node,a&&a.el&&a.el.offsetHeight;a=K.shift();)a[0](a[1],a[2])}function P(a,b,c,d){var e,f;null==c?null!=b&&b.constructor==Object?e=b:f=b:(e=b,f=c);return fa(a,e,f,d)}function Q(a,b,c,d){this.view=a;this.model=b;this.key=null== | ||
c?b:c;this.opts=d}function qa(a,b,c,d){return new Q(a,b,c,d)}function R(a){this.vm=a}function ra(a){return new R(a)}function sa(a){var b=new v;b.type=1;b.el=b.key=a;return b}function ta(a,b){a=a.body;if(k(a))for(var c=0;c<a.length;c++){var d=a[c];null!=d.vm?b.push(d.vm):ta(d,b)}return b}function ua(a,b){a.el=b;b._node=a;var c=a.attrs,d;for(d in c){var e=c[d],f=z(a.tag,d);"style"==d||"_"==d[0]||(0===d.lastIndexOf("on",0)?M(a,d,e):null!=e&&f&&N(a,d,e,f))}if(k(a.body)){b=b.firstChild;c=0;d=a.body[c]; | ||
do 4==d.type?d=C(d.view,d.model,d.key,d.opts)._redraw(a,c,!1).node:5==d.type&&(d=d.node||d._redraw(a,c,!1).node),ua(d,b);while((b=b.nextSibling)&&(d=a.body[++c]))}}function E(a){a=null==a?"":""+a;for(var b=0,c="";b<a.length;b++)switch(a[b]){case "&":c+="&";break;case "<":c+="<";break;case ">":c+=">";break;default:c+=a[b]}return c}function va(a){a=null==a?"":""+a;for(var b=0,c="";b<a.length;b++)c+='"'==a[b]?""":a[b];return c}function S(a,b){var c,d;switch(a.type){case 4:c=C(a.view,a.model, | ||
a.key,a.opts).html(b);break;case 5:c=a.vm.html();break;case 1:if(null!=a.el&&null==a.tag){c=a.el.outerHTML;break}c="<"+a.tag;if(null!=a.attrs){for(var e in a.attrs)if(!(0===e.lastIndexOf("on",0)||"."==e[0]||"_"==e[0]||!1===b&&z(a.tag,e))){var f=a.attrs[e];if("style"==e&&null!=f)if("object"==typeof f){d=void 0;var g="";for(d in f)null!==f[d]&&(g+=d.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()+": "+Y(d,f[d])+"; ");d=g}else d=f;else!0===f?c+=" "+E(e)+'=""':!1!==f&&null!=f&&(c+=" "+E(e)+'="'+va(f)+ | ||
'"')}null!=d&&(c+=' style="'+va(d.trim())+'"')}if(null==a.body&&null!=a.ns&&"svg"!==a.tag)return c+"/>";c+=">";if(!Ia[a.tag]){if(k(a.body)){e=c;c=a.body;d="";for(f=0;f<c.length;f++)d+=S(c[f],b);c=e+d}else c+=a.raw?a.body:E(a.body);c+="</"+a.tag+">"}break;case 2:c=E(a.body);break;case 3:c="\x3c!--"+E(a.body)+"--\x3e"}return c}var T="undefined"!=typeof window,X=(T?window:{}).requestAnimationFrame,u={},k=Array.isArray,za={animationIterationCount:!0,boxFlex:!0,boxFlexGroup:!0,columnCount:!0,counterIncrement:!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,tabSize:!0,transform:!0,transformOrigin:!0,widows:!0,zIndex:!0,zoom:!0},ga={},Aa=/\[(\w+)(?:=(\w+))?\]/g,A=function(){return!1},aa=null,ba=null,ca=null,K=[],wa=v.prototype={constructor:v,type:null,vm:null,key:null,ref:null,data:null,hooks:null,raw:!1,ns:null,el:null,tag:null,attrs:null,body:null,flags:0,_class:null,idx:null,parent:null},I=T? | ||
document:null,ja={onevent:G},p=D.prototype={constructor:D,_isClass:!1,view:null,key:null,model:null,opts:null,node:null,hooks:null,render:null,parent:function(){return r(this.node.parent)},root:function(){for(var a=this.node;a.parent;)a=a.parent;return a.vm},api:null,refs:null,mount:function(a,b){if(b){for(;a.firstChild;)a.removeChild(a.firstChild);this._redraw(null,null,!1);a.nodeName.toLowerCase()!=this.node.tag?(t(this.node),m(a.parentNode,this.node.el,a),a.parentNode.removeChild(a)):m(a.parentNode, | ||
t(this.node,a),a)}else this._redraw(null,null),a&&m(a,this.node.el);a&&J(this);return this},unmount:function(a){var b=this.node;B(b.el.parentNode,b.el);a||J(this)},redraw:function(a){a?this._redraw():this._redrawAsync();return this},update:function(a,b){b?this._update(a):this._updateAsync(a);return this},_update:function(a,b,c,d){null!=a&&this.model!==a&&(this.hooks&&n("willUpdate",this,a),this.model=a);return this._redraw(b,c,d)},_redraw:function(a,b,c){var d=null==a,e=this.node&&this.node.el&&this.node.el.parentNode, | ||
f=this.node;if(e&&null!=this._diff&&this._diff())return f&&a&&(a.body[b]=f,f.idx=b,f.parent=a),this;e&&this.hooks&&n("willRedraw",this);this.refs=null;var g=this.render.call(this,this,this.model,this.key);this.node=g;a?(x(g,a,b,this),a.body[b]=g):f&&f.parent?(x(g,f.parent,f.idx,this),f.parent.body[f.idx]=g):x(g,null,null,this);!1!==c&&(f?f.tag!==g.tag?(f.vm=g.vm=null,a=f.el.parentNode,b=f.el.nextSibling,B(a,f.el),m(a,t(g),b),f.el=g.el,g.vm=this):O(g,f,d):t(g));e&&this.hooks&&n("didRedraw",this);d&& | ||
e&&J(this);return this},_redrawAsync:null,_updateAsync:null,hook:function(a){this.hooks=this.hooks||y({},this.hooks,a)}};Q.prototype={constructor:Q,type:4,view:null,model:null,key:null,opts:null};R.prototype={constructor:R,type:5,vm:null};var F={config:function(a){y(ja,a)},ViewModel:D,VNode:v,createView:C,defineElement:P,defineSvgElement:function(a,b,c,d){a=P(a,b,c,d);a.ns="http://www.w3.org/2000/svg";return a},defineText:pa,defineComment:function(a){var b=new v;b.type=3;b.body= | ||
a;return b},defineView:qa,injectView:ra,injectElement:sa,FIXED_BODY:1,DEEP_REMOVE:2,KEYED_LIST:4};p._diff=null;p.diff=function(a){var b=this;if(w(a))var c=a;else var c=a.vals,d=a.then;var e=c.call(b,b,b.model,b.key,b.opts),f=k(e)?V:xa;b._diff=function(){var a=c.call(b,b,b.model,b.key,b.opts),h=f(e,a);h||(null!=d&&!1===d.call(b,b,e,a)&&(h=!0),e=a);return h}};wa.patch=function(a){var b;a:{if(null!=a.type){if(null!=this.vm){b=void 0;break a}x(a,this.parent,this.idx,null);this.parent.body[this.idx]=a; | ||
O(a,this);J(r(a))}else{b=Object.create(this);b.attrs=y({},this.attrs);a=y(this.attrs,a);if(null!=this._class){var c=a.class;a.class=null!=c&&""!=c?this._class+" "+c:this._class}la(this,b)}b=void 0}return b};F.h=function(a){return(q(a)?P:w(a)?qa:T&&a instanceof HTMLElement?sa:a instanceof D?ra:G).apply(null,arguments)};F.defineElementSpread=function(a){var b=arguments,c=b.length,d,e;if(1<c){d=1;var f=b[1];null!=f&&f.constructor==Object&&(e=b[1],d=2);d=c==d+1&&(q(b[d])||k(b[d]))?b[d]:U(b,d)}return fa(a, | ||
e,d)};p.events=null;p.emit=function(a){var b=arguments,c=this;do{var d=c.events;if(d=d?d[a]:null){d.apply(null,U(b,1));break}}while(c=c.parent())};p.on=function(a,b){null==this.events&&(this.events={});if(q(a))this.events[a]=b;else for(a in b=a,b)this.on(a,b[a])};p.body=function(){return ta(this.node,[])};"undefined"!=typeof flyd&&Z({is:function(a){return flyd.isStream(a)},val:function(a){return a()},sub:function(a,b){return flyd.on(b,a)},unsub:function(a){return a.end(!0)}});F.streamCfg=Z;F.prop= | ||
function(a,b,c,d){return function(e,f){"undefined"!=typeof e&&e!==a&&(a=e,!1!==f&&w(b)&&b.apply(c,d));return a}};p.attach=function(a){null==this.node&&this._redraw(null,null,!1);ua(this.node,a);return this};p.html=function(a){null==this.node&&this._redraw(null,null,!1);return S(this.node,a)};wa.html=function(a){return S(this,a)};var Ia={area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0};return F}); | ||
'use strict';(function(E,q){"object"===typeof exports&&"undefined"!==typeof module?module.exports=q():"function"===typeof define&&define.amd?define(q):E.domvm=q()})(this,function(){function E(a){a=typeof a;return"string"===a||"number"===a}function q(a){return"function"===typeof a}function y(a){for(var b=arguments,c=1;c<b.length;c++)for(var d in b[c])a[d]=b[c][d];return a}function qa(a,b){for(var c=[];b<a.length;b++)c.push(a[b]);return c}function ra(a,b){for(var c in a)if(a[c]!==b[c])return!1;return!0} | ||
function R(a,b){var c=a.length;if(b.length!=c)return!1;for(var d=0;d<c;d++)if(a[d]!==b[d])return!1;return!0}function S(a){function b(){c=0;a.apply(d,e)}if(!T)return a;var c,d,e;return function(){d=this;e=arguments;c||(c=T(b))}}function sa(a,b,c){return function(){return a.apply(c,b)}}function z(a,b){switch(b){case "value":case "checked":case "selected":case "selectedIndex":return!0}return!1}function r(a){for(a=a||u;null==a.vm&&a.parent;)a=a.parent;return a.vm}function U(a,b){return isNaN(b)||ta[a]? | ||
b:b+"px"}function V(a){A=a.is;W=a.val;X=a.sub;Y=a.unsub}function F(a,b){var c=X(a,function(a){c&&(null!=b.node&&b.redraw(),Y(c))});return W(a)}function Z(a,b){var c=(a.attrs||u).style;b=b?(b.attrs||u).style:null;if(null==c||E(c))a.el.style.cssText=c;else{for(var d in c){var e=c[d];A(e)&&(e=F(e,r(a)));if(null==b||null!=e&&e!==b[d])a.el.style[d]=U(d,e)}if(b)for(var f in b)null==c[f]&&(a.el.style[f]="")}}function aa(a,b,c,d,e){if(a)e?(a=c.parent,a&&a.el&&a.el.offsetHeight):J.push([b,c,d]);else return b(c, | ||
d)}function n(a,b,c,d){var e=b.hooks[a];if(e){var f=0===a.lastIndexOf("did",0);return k(e)?e.map(function(a){return aa(f,a,b,c)}):aa(f,e,b,c,d)}}function v(){}function ba(a){var b=a.hooks,c=a.vm;c&&c.hooks&&n("willUnmount",c);b=b&&n("willRemove",a);if(a.flags&2&&k(a.body))for(c=0;c<a.body.length;c++)ba(a.body[c]);return b}function K(a,b,c){var d=b._node,e=d.hooks,f=d.vm;if(d.flags&2&&k(d.body))for(var g=0;g<d.body.length;g++)K(b,d.body[g].el);a.removeChild(b);e&&n("didRemove",d,null,c);f&&f.hooks&& | ||
n("didUnmount",f,null,c)}function B(a,b){var c=ba(b._node);null!=c&&"object"===typeof c&&q(c.then)?c.then(sa(K,[a,b,!0])):K(a,b)}function l(a,b,c){var d=b._node,e=d.hooks,f=null!=b.parentNode,g=(b==c||!f)&&d.vm;g&&g.hooks&&n("willMount",g);e&&n(f?"willReinsert":"willInsert",d);a.insertBefore(b,c);e&&n(f?"didReinsert":"didInsert",d);g&&g.hooks&&n("didMount",g)}function ca(a,b,c){var d;for(d=a.target;null==d._node;)d=d.parentNode;d=d._node;var e=r(d);b=b.apply(null,c.concat(a,d,e));da.onevent.apply(null, | ||
[a,d,e].concat(c));!1===b&&(a.preventDefault(),a.stopPropagation())}function ea(a,b){return function(c){ca(c,a,b)}}function ua(a){return function(b){for(var c in a)if(b.target.matches(c)){var d=a[c],e=k(d),f=e?d[0]:d,d=e?d.slice(1):[];ca(b,f,d)}}}function L(a,b,c,d){c!==d&&(a=a.el,k(c)?null!=d&&R(c,d)||(c=ea(c[0],c.slice(1)),a[b]=c):(c=q(c)&&c!=d?ea(c,[]):ua(c),a[b]=c))}function M(a,b,c,d){var e=a.el;null==c?a.el.removeAttribute(b):null!=a.ns?e.setAttribute(b,c):"class"==b?e.className=c:"id"==b|| | ||
"boolean"==typeof c||d?e[b]=c:"."==b[0]?e[b.substr(1)]=c:e.setAttribute(b,c)}function fa(a,b){var c=a.attrs||u,d=b.attrs||u,e;for(e in c){var f=c[e],g=z(a.tag,e),h=g?a.el[e]:d[e];A(f)&&(c[e]=f=F(f,r(a)));f!==h&&("style"==e?Z(a,b):"_"==e[0]||(0===e.lastIndexOf("on",0)?L(a,e,f,h):M(a,e,f,g)))}for(e in d)e in c||"_"==e[0]||(b=a,d=e,z(a.tag,e)||0===e.lastIndexOf("on",0)?b.el[d]="":b.el.removeAttribute(d))}function C(a,b,c,d){if(4==a.type)b=a.model,c=a.key,d=a.opts,a=a.view;else if(a.prototype._isClass)return new a(b, | ||
c,d);return new G(a,b,c,d)}function ga(a){for(var b=0;b<a.body.length;b++){var c=a.body[b],d=c.type;3>=d?l(a.el,t(c)):4==d?(c=C(c.view,c.model,c.key,c.opts)._redraw(a,b,!1),l(a.el,t(c.node))):5==d&&(c=c.vm,c._redraw(a,b),l(a.el,c.node.el))}}function t(a,b){if(null==a.el)if(1==a.type){if(!b){b=a.tag;var c=a.ns;b=null!=c?H.createElementNS(c,b):H.createElement(b)}a.el=b;if(null!=a.attrs){b=a.attrs;for(var d in b){var c=b[d],e=z(a.tag,d);A(c)&&(b[d]=c=F(c,r(a)));"style"==d?Z(a):"_"==d[0]||(0===d.lastIndexOf("on", | ||
0)?L(a,d,c):null!=c&&M(a,d,c,e))}}k(a.body)?ga(a):null!=a.body&&""!==a.body&&(a.raw?a.el.innerHTML=a.body:a.el.textContent=a.body)}else 2==a.type?a.el=b||H.createTextNode(a.body):3==a.type&&(a.el=b||H.createComment(a.body));a.el._node=a;return a.el}function ha(a,b,c,d){c=c.previousSibling;d=d.nextSibling;a(c,d);return{lftSib:c?c.nextSibling:b.firstChild,rgtSib:d?d.previousSibling:b.lastChild}}function va(a,b,c,d,e){var f=e.idx==c.idx+1,g=f?!1:b._node==e,h=f?!0:d._node==c;return g||h?ha(function(c, | ||
e){h&&l(a,d,b);g&&l(a,b,e)},a,b,d):null}function wa(a,b,c,d){return ha(function(c,f){for(var e=b;e!==f;e=e.nextSibling){b=c=e;for(var h=e.nextSibling;h!==f;h=h.nextSibling)0<d(c,h)&&(c=h);c!==e&&(l(a,c,b),e=c)}},a,b,c)}function xa(a,b){return a._node.idx-b._node.idx}function ia(a,b){var c=a.el,d=a.body,e=b.body;b=d[0];var f=d[d.length-1],g=(e[0]||u).el,e=(e[e.length-1]||u).el,h,m,k;a:for(;;){for(;;)if(g&&(m=g._node).parent!=a)h=g.nextSibling,null!=m.vm?m.vm.unmount(!0):B(c,g),g=h;else if(null==b)break a; | ||
else if(null==b.el)l(c,t(b),g),b=d[b.idx+1];else if(b.el===g)b=d[b.idx+1],g=g.nextSibling;else break;for(;;)if(e&&(k=e._node).parent!=a)h=e.previousSibling,null!=k.vm?k.vm.unmount(!0):B(c,e),e=h;else if(f==b)break a;else if(null==f.el)h=t(f),l(c,h,e?e.nextSibling:null),f=d[f.idx-1];else if(f.el===e)f=d[f.idx-1],e=e.previousSibling;else break;(h=va(c,g,b,e,f))||(h=wa(c,g,e,xa));g=h.lftSib;e=h.rgtSib}}function ya(a,b,c,d){for(;c<b.length;c++){d=b[c];if(4==a.type&&null!=d.vm){var e=d.vm;if(e.view==a.view&& | ||
e.key==a.key)return d}if(d.el._node==d&&a.tag===d.tag&&a.type===d.type&&a.vm===d.vm&&(a.key===d.key||null==d.key))return d}return null}function za(a,b){a:{a=a.key;var c=0,d=b.length-1,e;if(2147483647>=d)for(;c<=d;)if(e=c+d>>1,b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;else for(;c<=d;)if(e=Math.floor((c+d)/2),b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;a=-1}return-1<a?b[a]:null}function N(a,b,c){b.hooks&&n("willRecycle",b,a);c=a.el=b.el;var d=b.body,e=a.body;c._node=a;if(2==a.type&& | ||
e!==d)c.nodeValue=e;else{null==a.attrs&&null==b.attrs||fa(a,b);var f=k(d),g=k(e);if(f)if(g){a.flags&4?(c=b.body.slice(),c.sort(Aa),d=za):(c=b.body,d=ya);for(var h,e=0,f=a.body,g=0;g<f.length;g++){var m=f[g],l=m.type;3>=l?(h=d(m,c,e))&&N(m,h):4==l?(h=d(m,c,e))?h.vm._update(m.model,a,g):C(m.view,m.model,m.key,m.opts)._redraw(a,g,!1):5==l&&m.vm._update(m.model,a,g);a.list||null==h||h.idx!=e||e++}1!=a.type||a.flags&1||ia(a,b)}else{if(e!==d)if(null!=e)a.raw?c.innerHTML=e:c.textContent=e;else for(;c.firstChild;)B(c, | ||
c.firstChild)}else g?(c.firstChild&&c.removeChild(c.firstChild),ga(a)):e!==d&&(a.raw?c.innerHTML=e:c.firstChild?c.firstChild.nodeValue=e:c.textContent=e);b.hooks&&n("didRecycle",b,a)}}function Aa(a,b){return a.key>b.key?1:a.key<b.key?-1:0}function ja(a){var b=new v;b.type=2;b.body=a;return b}function w(a,b,c,d){if(5!=a.type&&4!=a.type){a.parent=b;a.idx=c;a.vm=d;if(null!=a.ref){c=r(a);b=["refs"].concat(a.ref.split("."));for(var e;e=b.shift();)c[e]=0==b.length?a:c=c[e]||{}}if(a.hooks&&a.hooks.willRemove|| | ||
d&&d.hooks&&d.hooks.willUnmount)for(d=a;d=d.parent;)d.flags|=2;if(k(a.body))for(d=a.body,b=0;b<d.length;b++)c=d[b],!1===c||null==c?d.splice(b--,1):k(c)?(e=b--,d.splice.apply(d,[e,1].concat(c))):(null==c.type&&(d[b]=c=ja(""+c)),2==c.type?null==c.body||""==c.body?d.splice(b--,1):0<b&&2==d[b-1].type?(d[b-1].body+=c.body,d.splice(b--,1)):w(c,a,b,null):w(c,a,b,null));else A(a.body)&&(a.body=F(a.body,r(a)))}}function G(a,b,c,d){var e=this;e.view=a;e.model=b;e.key=null==c?b:c;a.prototype._isClass?(a=e.diff, | ||
null!=a&&a!=p.diff&&(e.diff=p.diff.bind(e),e.diff(a))):(a=a.call(e,e,b,c,d),q(a)?e.render=a:(a.diff&&(e.diff(a.diff),delete a.diff),y(e,a)));d&&(e.opts=d,d.hooks&&e.hook(d.hooks),d.diff&&e.diff(d.diff));e._redrawAsync=S(function(a){return e._redraw()});e._updateAsync=S(function(a){return e._update(a)});(a=e.hooks)&&a.didInit&&a.didInit.call(e,e,b,c,d)}function I(a){if(J.length)for(a=a.node,a&&a.el&&a.el.offsetHeight;a=J.shift();)a[0](a[1],a[2])}function ka(a,b,c,d){var e,f;null==c?null!=b&&b.constructor== | ||
Object?e=b:f=b:(e=b,f=c);c=e;b=new v;b.type=1;null!=d&&(b.flags=d);null!=c&&(null!=c._key&&(b.key=c._key),null!=c._ref&&(b.ref=c._ref),null!=c._hooks&&(b.hooks=c._hooks),null!=c._raw&&(b.raw=c._raw),null!=c._data&&(b.data=c._data),null!=c._flags&&(b.flags=c._flags),null==b.key&&(null!=b.ref?b.key=b.ref:null!=c.id?b.key=c.id:null!=c.name&&(b.key=c.name)),b.attrs=c);d=la[a];if(null==d){var g,h,k;for(la[a]=d={tag:(g=a.match(/^[-\w]+/))?g[0]:"div",id:(h=a.match(/#([-\w]+)/))?h[1]:null,class:(k=a.match(/\.([-\w.]+)/))? | ||
k[1].replace(/\./g," "):null,attrs:null};g=Ba.exec(a);)null==d.attrs&&(d.attrs={}),d.attrs[g[1]]=g[2]||""}a=d;b.tag=a.tag;if(a.id||a.class||a.attrs){g=b.attrs||{};a.id&&null==g.id&&(g.id=a.id);a.class&&(b._class=a.class,g.class=a.class+(null!=g.class?" "+g.class:""));if(a.attrs)for(var l in a.attrs)null!=g[l]||(g[l]=a.attrs[l]);b.attrs=g}null!=f&&(b.body=f);return b}function O(a,b,c,d){this.view=a;this.model=b;this.key=null==c?b:c;this.opts=d}function P(a){this.vm=a}function ma(a,b){a=a.body;if(k(a))for(var c= | ||
0;c<a.length;c++){var d=a[c];null!=d.vm?b.push(d.vm):ma(d,b)}return b}function na(a,b){a.el=b;b._node=a;var c=a.attrs,d;for(d in c){var e=c[d],f=z(a.tag,d);"style"==d||"_"==d[0]||(0===d.lastIndexOf("on",0)?L(a,d,e):null!=e&&f&&M(a,d,e,f))}if(k(a.body)){b=b.firstChild;c=0;d=a.body[c];do 4==d.type?d=C(d.view,d.model,d.key,d.opts)._redraw(a,c,!1).node:5==d.type&&(d=d.node||d._redraw(a,c,!1).node),na(d,b);while((b=b.nextSibling)&&(d=a.body[++c]))}}function D(a){a=null==a?"":""+a;for(var b=0,c="";b<a.length;b++)switch(a[b]){case "&":c+= | ||
"&";break;case "<":c+="<";break;case ">":c+=">";break;default:c+=a[b]}return c}function oa(a){a=null==a?"":""+a;for(var b=0,c="";b<a.length;b++)c+='"'==a[b]?""":a[b];return c}function Q(a,b){var c,d;switch(a.type){case 4:c=C(a.view,a.model,a.key,a.opts).html(b);break;case 5:c=a.vm.html();break;case 1:if(null!=a.el&&null==a.tag){c=a.el.outerHTML;break}c="<"+a.tag;if(null!=a.attrs){for(var e in a.attrs)if(!(0===e.lastIndexOf("on",0)||"."==e[0]||"_"==e[0]||!1===b&&z(a.tag,e))){var f=a.attrs[e]; | ||
if("style"==e&&null!=f)if("object"==typeof f){d=void 0;var g="";for(d in f)null!==f[d]&&(g+=d.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()+": "+U(d,f[d])+"; ");d=g}else d=f;else!0===f?c+=" "+D(e)+'=""':!1!==f&&null!=f&&(c+=" "+D(e)+'="'+oa(f)+'"')}null!=d&&(c+=' style="'+oa(d.trim())+'"')}if(null==a.body&&null!=a.ns&&"svg"!==a.tag)return c+"/>";c+=">";if(!Ca[a.tag]){if(k(a.body)){e=c;c=a.body;d="";for(f=0;f<c.length;f++)d+=Q(c[f],b);c=e+d}else c+=a.raw?a.body:D(a.body);c+="</"+a.tag+">"}break; | ||
case 2:c=D(a.body);break;case 3:c="\x3c!--"+D(a.body)+"--\x3e"}return c}var x="undefined"!=typeof window,T=(x?window:{}).requestAnimationFrame,u={},k=Array.isArray,ta={animationIterationCount:!0,boxFlex:!0,boxFlexGroup:!0,columnCount:!0,counterIncrement:!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,tabSize:!0,transform:!0,transformOrigin:!0,widows:!0,zIndex:!0,zoom:!0},la={},Ba=/\[(\w+)(?:=(\w+))?\]/g, | ||
A=function(){return!1},W=null,X=null,Y=null,J=[],pa=v.prototype={constructor:v,type:null,vm:null,key:null,ref:null,data:null,hooks:null,raw:!1,ns:null,el:null,tag:null,attrs:null,body:null,flags:0,_class:null,idx:null,parent:null},H=x?document:null,da={onevent:function(){}},p=G.prototype={constructor:G,_isClass:!1,view:null,key:null,model:null,opts:null,node:null,hooks:null,render:null,parent:function(){return r(this.node.parent)},root:function(){for(var a=this.node;a.parent;)a=a.parent;return a.vm}, | ||
api:null,refs:null,mount:function(a,b){if(b){for(;a.firstChild;)a.removeChild(a.firstChild);this._redraw(null,null,!1);a.nodeName.toLowerCase()!=this.node.tag?(t(this.node),l(a.parentNode,this.node.el,a),a.parentNode.removeChild(a)):l(a.parentNode,t(this.node,a),a)}else this._redraw(null,null),a&&l(a,this.node.el);a&&I(this);return this},unmount:function(a){var b=this.node;B(b.el.parentNode,b.el);a||I(this)},redraw:function(a){a?this._redraw():this._redrawAsync();return this},update:function(a,b){b? | ||
this._update(a):this._updateAsync(a);return this},_update:function(a,b,c,d){null!=a&&this.model!==a&&(this.hooks&&n("willUpdate",this,a),this.model=a);return this._redraw(b,c,d)},_redraw:function(a,b,c){var d=null==a,e=this.node&&this.node.el&&this.node.el.parentNode,f=this.node;if(e&&null!=this._diff&&this._diff())return f&&a&&(a.body[b]=f,f.idx=b,f.parent=a),this;e&&this.hooks&&n("willRedraw",this);this.refs=null;var g=this.render.call(this,this,this.model,this.key);!1!==this.key&&(g.key=this.key); | ||
this.node=g;a?(w(g,a,b,this),a.body[b]=g):f&&f.parent?(w(g,f.parent,f.idx,this),f.parent.body[f.idx]=g):w(g,null,null,this);!1!==c&&(f?f.tag!==g.tag?(f.vm=g.vm=null,a=f.el.parentNode,b=f.el.nextSibling,B(a,f.el),l(a,t(g),b),f.el=g.el,g.vm=this):N(g,f,d):t(g));e&&this.hooks&&n("didRedraw",this);d&&e&&I(this);return this},_redrawAsync:null,_updateAsync:null,hook:function(a){this.hooks=this.hooks||y({},this.hooks,a)}};O.prototype={constructor:O,type:4,view:null,model:null,key:null,opts:null};P.prototype= | ||
{constructor:P,type:5,vm:null};x={config:function(a){y(da,a)},ViewModel:G,VNode:v,createView:C,defineElement:ka,defineSvgElement:function(a,b,c,d){a=ka(a,b,c,d);a.ns="http://www.w3.org/2000/svg";return a},defineText:ja,defineComment:function(a){var b=new v;b.type=3;b.body=a;return b},defineView:function(a,b,c,d){return new O(a,b,c,d)},injectView:function(a){return new P(a)},injectElement:function(a){var b=new v;b.type=1;b.el=b.key=a;return b},FIXED_BODY:1,DEEP_REMOVE:2,KEYED_LIST:4}; | ||
p._diff=null;p.diff=function(a){var b=this;if(q(a))var c=a;else var c=a.vals,d=a.then;var e=c.call(b,b,b.model,b.key,b.opts),f=k(e)?R:ra;b._diff=function(){var a=c.call(b,b,b.model,b.key,b.opts),h=f(e,a);h||(null!=d&&!1===d.call(b,b,e,a)&&(h=!0),e=a);return h}};pa.patch=function(a){var b;a:{if(null!=a.type){if(null!=this.vm){b=void 0;break a}w(a,this.parent,this.idx,null);this.parent.body[this.idx]=a;N(a,this);I(r(a))}else{b=Object.create(this);b.attrs=y({},this.attrs);a=y(this.attrs,a);if(null!= | ||
this._class){var c=a.class;a.class=null!=c&&""!=c?this._class+" "+c:this._class}fa(this,b)}b=void 0}return b};p.events=null;p.emit=function(a){var b=arguments,c=this;do{var d=c.events;if(d=d?d[a]:null){d.apply(null,qa(b,1));break}}while(c=c.parent())};p.on=function(a,b){null==this.events&&(this.events={});if(E(a))this.events[a]=b;else for(a in b=a,b)this.on(a,b[a])};p.body=function(){return ma(this.node,[])};"undefined"!=typeof flyd&&V({is:function(a){return flyd.isStream(a)},val:function(a){return a()}, | ||
sub:function(a,b){return flyd.on(b,a)},unsub:function(a){return a.end(!0)}});x.streamCfg=V;x.prop=function(a,b,c,d){return function(e,f){"undefined"!=typeof e&&e!==a&&(a=e,!1!==f&&q(b)&&b.apply(c,d));return a}};p.attach=function(a){null==this.node&&this._redraw(null,null,!1);na(this.node,a);return this};p.html=function(a){null==this.node&&this._redraw(null,null,!1);return Q(this.node,a)};pa.html=function(a){return Q(this,a)};var Ca={area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,hr:!0,img:!0,input:!0, | ||
keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0};return x}); |
@@ -7,3 +7,3 @@ /** | ||
* A thin, fast, dependency-free vdom view layer | ||
* @preserve https://github.com/leeoniya/domvm (v2.1.1, micro) | ||
* @preserve https://github.com/leeoniya/domvm (v2.1.3, micro) | ||
*/ | ||
@@ -44,2 +44,6 @@ | ||
function isSet(val) { | ||
return val != null; | ||
} | ||
function isPlainObj(val) { | ||
@@ -66,6 +70,4 @@ return val != null && val.constructor == Object; // && typeof val == "object" | ||
function isElem(val) { | ||
return ENV_DOM && val instanceof HTMLElement; | ||
} | ||
function assignObj(targ) { | ||
@@ -419,6 +421,2 @@ var args = arguments; | ||
function isSet(val) { | ||
return val != null; | ||
} | ||
// (de)optimization flags | ||
@@ -934,3 +932,3 @@ | ||
// from_right: | ||
while(1) { | ||
while (1) { | ||
// if (rgtSib == lftEnd) | ||
@@ -1212,4 +1210,2 @@ // break converge; | ||
vm.api = {}; | ||
vm.view = view; | ||
@@ -1220,3 +1216,3 @@ vm.model = model; | ||
if (!view.prototype._isClass) { | ||
var out = view.call(vm, vm, model, key); // , opts | ||
var out = view.call(vm, vm, model, key, opts); | ||
@@ -1243,2 +1239,3 @@ if (isFunc(out)) | ||
} | ||
// remove this? | ||
@@ -1258,2 +1255,7 @@ if (opts) { | ||
var hooks = vm.hooks; | ||
if (hooks && hooks.didInit) | ||
{ hooks.didInit.call(vm, vm, model, key, opts); } | ||
// this.update(model, parent, idx, parentVm, false); | ||
@@ -1417,2 +1419,5 @@ | ||
if (vm.key !== false) | ||
{ vnew.key = vm.key; } | ||
// console.log(vm.key); | ||
@@ -1676,42 +1681,4 @@ | ||
// does not handle defineComment, defineText, defineSVG (ambiguous); use plain text vals or explicit factories in templates. | ||
// does not handle defineElementSpread (not available in all builds); use exlicit factories in templates. | ||
function h(a) { | ||
return ( | ||
isVal(a) ? defineElement : | ||
isFunc(a) ? defineView : // todo: es6 class constructor | ||
isElem(a) ? injectElement : | ||
a instanceof ViewModel ? injectView : | ||
noop | ||
).apply(null, arguments); | ||
} | ||
function defineElementSpread(tag) { | ||
var args = arguments; | ||
var len = args.length; | ||
var body, attrs; | ||
if (len > 1) { | ||
var bodyIdx = 1; | ||
if (isPlainObj(args[1])) { | ||
attrs = args[1]; | ||
bodyIdx = 2; | ||
} | ||
if (len == bodyIdx + 1 && (isVal(args[bodyIdx]) || isArr(args[bodyIdx]))) | ||
{ body = args[bodyIdx]; } | ||
else | ||
{ body = sliceArgs(args, bodyIdx); } | ||
} | ||
return initElementNode(tag, attrs, body); | ||
} | ||
// #destub: cssTag,autoPx | ||
nano.h = h; | ||
nano.defineElementSpread = defineElementSpread; | ||
ViewModelProto.events = null; | ||
@@ -1718,0 +1685,0 @@ ViewModelProto.emit = emit; |
/* | ||
https://github.com/leeoniya/domvm (v2.1.1, micro) | ||
https://github.com/leeoniya/domvm (v2.1.3, micro) | ||
*/ | ||
'use strict';(function(A,p){"object"===typeof exports&&"undefined"!==typeof module?module.exports=p():"function"===typeof define&&define.amd?define(p):A.domvm=p()})(this,function(){function A(){}function p(a){a=typeof a;return"string"===a||"number"===a}function w(a){return"function"===typeof a}function x(a){for(var b=arguments,c=1;c<b.length;c++)for(var d in b[c])a[d]=b[c][d];return a}function O(a,b){for(var c=[];b<a.length;b++)c.push(a[b]);return c}function la(a,b){for(var c in a)if(a[c]!==b[c])return!1; | ||
return!0}function P(a,b){var c=a.length;if(b.length!=c)return!1;for(var d=0;d<c;d++)if(a[d]!==b[d])return!1;return!0}function Q(a){function b(){c=0;a.apply(d,e)}if(!R)return a;var c,d,e;return function(){d=this;e=arguments;c||(c=R(b))}}function ma(a,b,c){return function(){return a.apply(c,b)}}function E(a,b){switch(b){case "value":case "checked":case "selected":case "selectedIndex":return!0}return!1}function B(a){for(a=a||t;null==a.vm&&a.parent;)a=a.parent;return a.vm}function S(a,b){var c=(a.attrs|| | ||
t).style;b=b?(b.attrs||t).style:null;if(null==c||p(c))a.el.style.cssText=c;else{for(var d in c){var e=c[d];if(null==b||null!=e&&e!==b[d]){var f=a.el.style,g=d,h;h=d;h=isNaN(e)||na[h]?e:e+"px";f[g]=h}}if(b)for(var k in b)null==c[k]&&(a.el.style[k]="")}}function T(a,b,c,d,e){if(a)e?(a=c.parent,a&&a.el&&a.el.offsetHeight):F.push([b,c,d]);else return b(c,d)}function l(a,b,c,d){var e=b.hooks[a];if(e){var f=0===a.lastIndexOf("did",0);return n(e)?e.map(function(a){return T(f,a,b,c)}):T(f,e,b,c,d)}}function u(){} | ||
function U(a,b,c,d){var e=new u;e.type=1;null!=d&&(e.flags=d);null!=b&&(null!=b._key&&(e.key=b._key),null!=b._ref&&(e.ref=b._ref),null!=b._hooks&&(e.hooks=b._hooks),null!=b._raw&&(e.raw=b._raw),null!=b._data&&(e.data=b._data),null!=b._flags&&(e.flags=b._flags),null==e.key&&(null!=e.ref?e.key=e.ref:null!=b.id?e.key=b.id:null!=b.name&&(e.key=b.name)),e.attrs=b);b=V[a];if(null==b){var f,g,h;for(V[a]=b={tag:(f=a.match(/^[-\w]+/))?f[0]:"div",id:(g=a.match(/#([-\w]+)/))?g[1]:null,class:(h=a.match(/\.([-\w.]+)/))? | ||
h[1].replace(/\./g," "):null,attrs:null};f=oa.exec(a);)null==b.attrs&&(b.attrs={}),b.attrs[f[1]]=f[2]||""}a=b;e.tag=a.tag;if(a.id||a.class||a.attrs){f=e.attrs||{};a.id&&null==f.id&&(f.id=a.id);a.class&&(e._class=a.class,f.class=a.class+(null!=f.class?" "+f.class:""));if(a.attrs)for(var k in a.attrs)null==f[k]&&(f[k]=a.attrs[k]);e.attrs=f}null!=c&&(e.body=c);return e}function W(a){var b=a.hooks,c=a.vm;c&&c.hooks&&l("willUnmount",c);b=b&&l("willRemove",a);if(a.flags&2&&n(a.body))for(c=0;c<a.body.length;c++)W(a.body[c]); | ||
return b}function G(a,b,c){var d=b._node,e=d.hooks,f=d.vm;if(d.flags&2&&n(d.body))for(var g=0;g<d.body.length;g++)G(b,d.body[g].el);a.removeChild(b);e&&l("didRemove",d,null,c);f&&f.hooks&&l("didUnmount",f,null,c)}function y(a,b){var c=W(b._node);null!=c&&"object"===typeof c&&w(c.then)?c.then(ma(G,[a,b,!0])):G(a,b)}function m(a,b,c){var d=b._node,e=d.hooks,f=null!=b.parentNode,g=(b==c||!f)&&d.vm;g&&g.hooks&&l("willMount",g);e&&l(f?"willReinsert":"willInsert",d);a.insertBefore(b,c);e&&l(f?"didReinsert": | ||
"didInsert",d);g&&g.hooks&&l("didMount",g)}function X(a,b,c){var d;for(d=a.target;null==d._node;)d=d.parentNode;d=d._node;var e=B(d);b=b.apply(null,c.concat(a,d,e));Y.onevent.apply(null,[a,d,e].concat(c));!1===b&&(a.preventDefault(),a.stopPropagation())}function Z(a,b){return function(c){X(c,a,b)}}function pa(a){return function(b){for(var c in a)if(b.target.matches(c)){var d=a[c],e=n(d),f=e?d[0]:d,d=e?d.slice(1):[];X(b,f,d)}}}function aa(a,b,c,d){c!==d&&(a=a.el,n(c)?null!=d&&P(c,d)||(c=Z(c[0],c.slice(1)), | ||
a[b]=c):(c=w(c)&&c!=d?Z(c,[]):pa(c),a[b]=c))}function ba(a,b,c,d){var e=a.el;null==c?a.el.removeAttribute(b):null!=a.ns?e.setAttribute(b,c):"class"==b?e.className=c:"id"==b||"boolean"==typeof c||d?e[b]=c:"."==b[0]?e[b.substr(1)]=c:e.setAttribute(b,c)}function ca(a,b){var c=a.attrs||t,d=b.attrs||t,e;for(e in c){var f=c[e],g=E(a.tag,e),h=g?a.el[e]:d[e];f!==h&&("style"==e?S(a,b):"_"==e[0]||(0===e.lastIndexOf("on",0)?aa(a,e,f,h):ba(a,e,f,g)))}for(e in d)e in c||"_"==e[0]||(b=a,d=e,E(a.tag,e)||0===e.lastIndexOf("on", | ||
0)?b.el[d]="":b.el.removeAttribute(d))}function H(a,b,c,d){if(4==a.type)b=a.model,c=a.key,d=a.opts,a=a.view;else if(a.prototype._isClass)return new a(b,c,d);return new z(a,b,c,d)}function da(a){for(var b=0;b<a.body.length;b++){var c=a.body[b],d=c.type;3>=d?m(a.el,q(c)):4==d?(c=H(c.view,c.model,c.key,c.opts)._redraw(a,b,!1),m(a.el,q(c.node))):5==d&&(c=c.vm,c._redraw(a,b),m(a.el,c.node.el))}}function q(a,b){if(null==a.el)if(1==a.type){if(!b){b=a.tag;var c=a.ns;b=null!=c?C.createElementNS(c,b):C.createElement(b)}a.el= | ||
b;if(null!=a.attrs){b=a.attrs;for(var d in b){var c=b[d],e=E(a.tag,d);"style"==d?S(a):"_"==d[0]||(0===d.lastIndexOf("on",0)?aa(a,d,c):null!=c&&ba(a,d,c,e))}}n(a.body)?da(a):null!=a.body&&""!==a.body&&(a.raw?a.el.innerHTML=a.body:a.el.textContent=a.body)}else 2==a.type?a.el=b||C.createTextNode(a.body):3==a.type&&(a.el=b||C.createComment(a.body));a.el._node=a;return a.el}function ea(a,b,c,d){c=c.previousSibling;d=d.nextSibling;a(c,d);return{lftSib:c?c.nextSibling:b.firstChild,rgtSib:d?d.previousSibling: | ||
b.lastChild}}function qa(a,b,c,d,e){var f=e.idx==c.idx+1,g=f?!1:b._node==e,h=f?!0:d._node==c;return g||h?ea(function(c,e){h&&m(a,d,b);g&&m(a,b,e)},a,b,d):null}function ra(a,b,c,d){return ea(function(c,f){for(var e=b;e!==f;e=e.nextSibling){b=c=e;for(var h=e.nextSibling;h!==f;h=h.nextSibling)0<d(c,h)&&(c=h);c!==e&&(m(a,c,b),e=c)}},a,b,c)}function sa(a,b){return a._node.idx-b._node.idx}function fa(a,b){var c=a.el,d=a.body,e=b.body;b=d[0];var f=d[d.length-1],g=(e[0]||t).el,e=(e[e.length-1]||t).el,h,k, | ||
l;a:for(;;){for(;;)if(g&&(k=g._node).parent!=a)h=g.nextSibling,null!=k.vm?k.vm.unmount(!0):y(c,g),g=h;else if(null==b)break a;else if(null==b.el)m(c,q(b),g),b=d[b.idx+1];else if(b.el===g)b=d[b.idx+1],g=g.nextSibling;else break;for(;;)if(e&&(l=e._node).parent!=a)h=e.previousSibling,null!=l.vm?l.vm.unmount(!0):y(c,e),e=h;else if(f==b)break a;else if(null==f.el)h=q(f),m(c,h,e?e.nextSibling:null),f=d[f.idx-1];else if(f.el===e)f=d[f.idx-1],e=e.previousSibling;else break;(h=qa(c,g,b,e,f))||(h=ra(c,g,e, | ||
sa));g=h.lftSib;e=h.rgtSib}}function ta(a,b,c,d){for(;c<b.length;c++){d=b[c];if(4==a.type&&null!=d.vm){var e=d.vm;if(e.view==a.view&&e.key==a.key)return d}if(d.el._node==d&&a.tag===d.tag&&a.type===d.type&&a.vm===d.vm&&(a.key===d.key||null==d.key))return d}return null}function ua(a,b){a:{a=a.key;var c=0,d=b.length-1,e;if(2147483647>=d)for(;c<=d;)if(e=c+d>>1,b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;else for(;c<=d;)if(e=Math.floor((c+d)/2),b[e].key===a){a=e;break a}else b[e].key<a?c=e+1: | ||
d=e-1;a=-1}return-1<a?b[a]:null}function I(a,b,c){b.hooks&&l("willRecycle",b,a);c=a.el=b.el;var d=b.body,e=a.body;c._node=a;if(2==a.type&&e!==d)c.nodeValue=e;else{null==a.attrs&&null==b.attrs||ca(a,b);var f=n(d),g=n(e);if(f)if(g){a.flags&4?(c=b.body.slice(),c.sort(va),d=ua):(c=b.body,d=ta);for(var h,e=0,f=a.body,g=0;g<f.length;g++){var k=f[g],m=k.type;3>=m?(h=d(k,c,e))&&I(k,h):4==m?(h=d(k,c,e))?h.vm._update(k.model,a,g):H(k.view,k.model,k.key,k.opts)._redraw(a,g,!1):5==m&&k.vm._update(k.model,a,g); | ||
a.list||null==h||h.idx!=e||e++}1!=a.type||a.flags&1||fa(a,b)}else{if(e!==d)if(null!=e)a.raw?c.innerHTML=e:c.textContent=e;else for(;c.firstChild;)y(c,c.firstChild)}else g?(c.firstChild&&c.removeChild(c.firstChild),da(a)):e!==d&&(a.raw?c.innerHTML=e:c.firstChild?c.firstChild.nodeValue=e:c.textContent=e);b.hooks&&l("didRecycle",b,a)}}function va(a,b){return a.key>b.key?1:a.key<b.key?-1:0}function ga(a){var b=new u;b.type=2;b.body=a;return b}function v(a,b,c,d){if(5!=a.type&&4!=a.type){a.parent=b;a.idx= | ||
c;a.vm=d;if(null!=a.ref){c=B(a);b=["refs"].concat(a.ref.split("."));for(var e;e=b.shift();)c[e]=0==b.length?a:c=c[e]||{}}if(a.hooks&&a.hooks.willRemove||d&&d.hooks&&d.hooks.willUnmount)for(d=a;d=d.parent;)d.flags|=2;if(n(a.body))for(d=a.body,b=0;b<d.length;b++)c=d[b],!1===c||null==c?d.splice(b--,1):n(c)?(e=b--,d.splice.apply(d,[e,1].concat(c))):(null==c.type&&(d[b]=c=ga(""+c)),2==c.type?null==c.body||""==c.body?d.splice(b--,1):0<b&&2==d[b-1].type?(d[b-1].body+=c.body,d.splice(b--,1)):v(c,a,b,null): | ||
v(c,a,b,null))}}function z(a,b,c,d){var e=this;e.api={};e.view=a;e.model=b;e.key=null==c?b:c;a.prototype._isClass?(a=e.diff,null!=a&&a!=r.diff&&(e.diff=r.diff.bind(e),e.diff(a))):(a=a.call(e,e,b,c),w(a)?e.render=a:(a.diff&&(e.diff(a.diff),delete a.diff),x(e,a)));d&&(e.opts=d,d.hooks&&e.hook(d.hooks),d.diff&&e.diff(d.diff));e._redrawAsync=Q(function(a){return e._redraw()});e._updateAsync=Q(function(a){return e._update(a)})}function D(a){if(F.length)for(a=a.node,a&&a.el&&a.el.offsetHeight;a=F.shift();)a[0](a[1], | ||
a[2])}function J(a,b,c,d){var e,f;null==c?null!=b&&b.constructor==Object?e=b:f=b:(e=b,f=c);return U(a,e,f,d)}function K(a,b,c,d){this.view=a;this.model=b;this.key=null==c?b:c;this.opts=d}function ha(a,b,c,d){return new K(a,b,c,d)}function L(a){this.vm=a}function ia(a){return new L(a)}function ja(a){var b=new u;b.type=1;b.el=b.key=a;return b}function ka(a,b){a=a.body;if(n(a))for(var c=0;c<a.length;c++){var d=a[c];null!=d.vm?b.push(d.vm):ka(d,b)}return b}var M="undefined"!=typeof window,R=(M?window: | ||
{}).requestAnimationFrame,t={},n=Array.isArray,na={animationIterationCount:!0,boxFlex:!0,boxFlexGroup:!0,columnCount:!0,counterIncrement:!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,tabSize:!0,transform:!0,transformOrigin:!0,widows:!0,zIndex:!0,zoom:!0},V={},oa=/\[(\w+)(?:=(\w+))?\]/g,F=[],wa=u.prototype={constructor:u,type:null,vm:null,key:null,ref:null,data:null,hooks:null,raw:!1, | ||
ns:null,el:null,tag:null,attrs:null,body:null,flags:0,_class:null,idx:null,parent:null},C=M?document:null,Y={onevent:A},r=z.prototype={constructor:z,_isClass:!1,view:null,key:null,model:null,opts:null,node:null,hooks:null,render:null,parent:function(){return B(this.node.parent)},root:function(){for(var a=this.node;a.parent;)a=a.parent;return a.vm},api:null,refs:null,mount:function(a,b){if(b){for(;a.firstChild;)a.removeChild(a.firstChild);this._redraw(null,null,!1);a.nodeName.toLowerCase()!=this.node.tag? | ||
(q(this.node),m(a.parentNode,this.node.el,a),a.parentNode.removeChild(a)):m(a.parentNode,q(this.node,a),a)}else this._redraw(null,null),a&&m(a,this.node.el);a&&D(this);return this},unmount:function(a){var b=this.node;y(b.el.parentNode,b.el);a||D(this)},redraw:function(a){a?this._redraw():this._redrawAsync();return this},update:function(a,b){b?this._update(a):this._updateAsync(a);return this},_update:function(a,b,c,d){null!=a&&this.model!==a&&(this.hooks&&l("willUpdate",this,a),this.model=a);return this._redraw(b, | ||
c,d)},_redraw:function(a,b,c){var d=null==a,e=this.node&&this.node.el&&this.node.el.parentNode,f=this.node;if(e&&null!=this._diff&&this._diff())return f&&a&&(a.body[b]=f,f.idx=b,f.parent=a),this;e&&this.hooks&&l("willRedraw",this);this.refs=null;var g=this.render.call(this,this,this.model,this.key);this.node=g;a?(v(g,a,b,this),a.body[b]=g):f&&f.parent?(v(g,f.parent,f.idx,this),f.parent.body[f.idx]=g):v(g,null,null,this);!1!==c&&(f?f.tag!==g.tag?(f.vm=g.vm=null,a=f.el.parentNode,b=f.el.nextSibling, | ||
y(a,f.el),m(a,q(g),b),f.el=g.el,g.vm=this):I(g,f,d):q(g));e&&this.hooks&&l("didRedraw",this);d&&e&&D(this);return this},_redrawAsync:null,_updateAsync:null,hook:function(a){this.hooks=this.hooks||x({},this.hooks,a)}};K.prototype={constructor:K,type:4,view:null,model:null,key:null,opts:null};L.prototype={constructor:L,type:5,vm:null};var N={config:function(a){x(Y,a)},ViewModel:z,VNode:u,createView:H,defineElement:J,defineSvgElement:function(a,b,c,d){a=J(a,b,c,d);a.ns="http://www.w3.org/2000/svg"; | ||
return a},defineText:ga,defineComment:function(a){var b=new u;b.type=3;b.body=a;return b},defineView:ha,injectView:ia,injectElement:ja,FIXED_BODY:1,DEEP_REMOVE:2,KEYED_LIST:4};r._diff=null;r.diff=function(a){var b=this;if(w(a))var c=a;else var c=a.vals,d=a.then;var e=c.call(b,b,b.model,b.key,b.opts),f=n(e)?P:la;b._diff=function(){var a=c.call(b,b,b.model,b.key,b.opts),h=f(e,a);h||(null!=d&&!1===d.call(b,b,e,a)&&(h=!0),e=a);return h}};wa.patch=function(a){var b;a:{if(null!=a.type){if(null!=this.vm){b= | ||
void 0;break a}v(a,this.parent,this.idx,null);this.parent.body[this.idx]=a;I(a,this);D(B(a))}else{b=Object.create(this);b.attrs=x({},this.attrs);a=x(this.attrs,a);if(null!=this._class){var c=a.class;a.class=null!=c&&""!=c?this._class+" "+c:this._class}ca(this,b)}b=void 0}return b};N.h=function(a){return(p(a)?J:w(a)?ha:M&&a instanceof HTMLElement?ja:a instanceof z?ia:A).apply(null,arguments)};N.defineElementSpread=function(a){var b=arguments,c=b.length,d,e;if(1<c){d=1;var f=b[1];null!=f&&f.constructor== | ||
Object&&(e=b[1],d=2);d=c==d+1&&(p(b[d])||n(b[d]))?b[d]:O(b,d)}return U(a,e,d)};r.events=null;r.emit=function(a){var b=arguments,c=this;do{var d=c.events;if(d=d?d[a]:null){d.apply(null,O(b,1));break}}while(c=c.parent())};r.on=function(a,b){null==this.events&&(this.events={});if(p(a))this.events[a]=b;else for(a in b=a,b)this.on(a,b[a])};r.body=function(){return ka(this.node,[])};return N}); | ||
'use strict';(function(y,p){"object"===typeof exports&&"undefined"!==typeof module?module.exports=p():"function"===typeof define&&define.amd?define(p):y.domvm=p()})(this,function(){function y(a){a=typeof a;return"string"===a||"number"===a}function p(a){return"function"===typeof a}function w(a){for(var b=arguments,c=1;c<b.length;c++)for(var d in b[c])a[d]=b[c][d];return a}function ea(a,b){for(var c=[];b<a.length;b++)c.push(a[b]);return c}function fa(a,b){for(var c in a)if(a[c]!==b[c])return!1;return!0} | ||
function L(a,b){var c=a.length;if(b.length!=c)return!1;for(var d=0;d<c;d++)if(a[d]!==b[d])return!1;return!0}function M(a){function b(){c=0;a.apply(d,e)}if(!N)return a;var c,d,e;return function(){d=this;e=arguments;c||(c=N(b))}}function ga(a,b,c){return function(){return a.apply(c,b)}}function E(a,b){switch(b){case "value":case "checked":case "selected":case "selectedIndex":return!0}return!1}function z(a){for(a=a||t;null==a.vm&&a.parent;)a=a.parent;return a.vm}function O(a,b){var c=(a.attrs||t).style; | ||
b=b?(b.attrs||t).style:null;if(null==c||y(c))a.el.style.cssText=c;else{for(var d in c){var e=c[d];if(null==b||null!=e&&e!==b[d]){var g=a.el.style,f=d,h;h=d;h=isNaN(e)||ha[h]?e:e+"px";g[f]=h}}if(b)for(var k in b)null==c[k]&&(a.el.style[k]="")}}function P(a,b,c,d,e){if(a)e?(a=c.parent,a&&a.el&&a.el.offsetHeight):F.push([b,c,d]);else return b(c,d)}function l(a,b,c,d){var e=b.hooks[a];if(e){var g=0===a.lastIndexOf("did",0);return n(e)?e.map(function(a){return P(g,a,b,c)}):P(g,e,b,c,d)}}function u(){} | ||
function Q(a){var b=a.hooks,c=a.vm;c&&c.hooks&&l("willUnmount",c);b=b&&l("willRemove",a);if(a.flags&2&&n(a.body))for(c=0;c<a.body.length;c++)Q(a.body[c]);return b}function G(a,b,c){var d=b._node,e=d.hooks,g=d.vm;if(d.flags&2&&n(d.body))for(var f=0;f<d.body.length;f++)G(b,d.body[f].el);a.removeChild(b);e&&l("didRemove",d,null,c);g&&g.hooks&&l("didUnmount",g,null,c)}function x(a,b){var c=Q(b._node);null!=c&&"object"===typeof c&&p(c.then)?c.then(ga(G,[a,b,!0])):G(a,b)}function m(a,b,c){var d=b._node, | ||
e=d.hooks,g=null!=b.parentNode,f=(b==c||!g)&&d.vm;f&&f.hooks&&l("willMount",f);e&&l(g?"willReinsert":"willInsert",d);a.insertBefore(b,c);e&&l(g?"didReinsert":"didInsert",d);f&&f.hooks&&l("didMount",f)}function R(a,b,c){var d;for(d=a.target;null==d._node;)d=d.parentNode;d=d._node;var e=z(d);b=b.apply(null,c.concat(a,d,e));S.onevent.apply(null,[a,d,e].concat(c));!1===b&&(a.preventDefault(),a.stopPropagation())}function T(a,b){return function(c){R(c,a,b)}}function ia(a){return function(b){for(var c in a)if(b.target.matches(c)){var d= | ||
a[c],e=n(d),g=e?d[0]:d,d=e?d.slice(1):[];R(b,g,d)}}}function U(a,b,c,d){c!==d&&(a=a.el,n(c)?null!=d&&L(c,d)||(c=T(c[0],c.slice(1)),a[b]=c):(c=p(c)&&c!=d?T(c,[]):ia(c),a[b]=c))}function V(a,b,c,d){var e=a.el;null==c?a.el.removeAttribute(b):null!=a.ns?e.setAttribute(b,c):"class"==b?e.className=c:"id"==b||"boolean"==typeof c||d?e[b]=c:"."==b[0]?e[b.substr(1)]=c:e.setAttribute(b,c)}function W(a,b){var c=a.attrs||t,d=b.attrs||t,e;for(e in c){var g=c[e],f=E(a.tag,e),h=f?a.el[e]:d[e];g!==h&&("style"==e? | ||
O(a,b):"_"==e[0]||(0===e.lastIndexOf("on",0)?U(a,e,g,h):V(a,e,g,f)))}for(e in d)e in c||"_"==e[0]||(b=a,d=e,E(a.tag,e)||0===e.lastIndexOf("on",0)?b.el[d]="":b.el.removeAttribute(d))}function H(a,b,c,d){if(4==a.type)b=a.model,c=a.key,d=a.opts,a=a.view;else if(a.prototype._isClass)return new a(b,c,d);return new A(a,b,c,d)}function X(a){for(var b=0;b<a.body.length;b++){var c=a.body[b],d=c.type;3>=d?m(a.el,q(c)):4==d?(c=H(c.view,c.model,c.key,c.opts)._redraw(a,b,!1),m(a.el,q(c.node))):5==d&&(c=c.vm,c._redraw(a, | ||
b),m(a.el,c.node.el))}}function q(a,b){if(null==a.el)if(1==a.type){if(!b){b=a.tag;var c=a.ns;b=null!=c?B.createElementNS(c,b):B.createElement(b)}a.el=b;if(null!=a.attrs){b=a.attrs;for(var d in b){var c=b[d],e=E(a.tag,d);"style"==d?O(a):"_"==d[0]||(0===d.lastIndexOf("on",0)?U(a,d,c):null!=c&&V(a,d,c,e))}}n(a.body)?X(a):null!=a.body&&""!==a.body&&(a.raw?a.el.innerHTML=a.body:a.el.textContent=a.body)}else 2==a.type?a.el=b||B.createTextNode(a.body):3==a.type&&(a.el=b||B.createComment(a.body));a.el._node= | ||
a;return a.el}function Y(a,b,c,d){c=c.previousSibling;d=d.nextSibling;a(c,d);return{lftSib:c?c.nextSibling:b.firstChild,rgtSib:d?d.previousSibling:b.lastChild}}function ja(a,b,c,d,e){var g=e.idx==c.idx+1,f=g?!1:b._node==e,h=g?!0:d._node==c;return f||h?Y(function(c,e){h&&m(a,d,b);f&&m(a,b,e)},a,b,d):null}function ka(a,b,c,d){return Y(function(c,g){for(var e=b;e!==g;e=e.nextSibling){b=c=e;for(var h=e.nextSibling;h!==g;h=h.nextSibling)0<d(c,h)&&(c=h);c!==e&&(m(a,c,b),e=c)}},a,b,c)}function la(a,b){return a._node.idx- | ||
b._node.idx}function Z(a,b){var c=a.el,d=a.body,e=b.body;b=d[0];var g=d[d.length-1],f=(e[0]||t).el,e=(e[e.length-1]||t).el,h,k,l;a:for(;;){for(;;)if(f&&(k=f._node).parent!=a)h=f.nextSibling,null!=k.vm?k.vm.unmount(!0):x(c,f),f=h;else if(null==b)break a;else if(null==b.el)m(c,q(b),f),b=d[b.idx+1];else if(b.el===f)b=d[b.idx+1],f=f.nextSibling;else break;for(;;)if(e&&(l=e._node).parent!=a)h=e.previousSibling,null!=l.vm?l.vm.unmount(!0):x(c,e),e=h;else if(g==b)break a;else if(null==g.el)h=q(g),m(c,h, | ||
e?e.nextSibling:null),g=d[g.idx-1];else if(g.el===e)g=d[g.idx-1],e=e.previousSibling;else break;(h=ja(c,f,b,e,g))||(h=ka(c,f,e,la));f=h.lftSib;e=h.rgtSib}}function ma(a,b,c,d){for(;c<b.length;c++){d=b[c];if(4==a.type&&null!=d.vm){var e=d.vm;if(e.view==a.view&&e.key==a.key)return d}if(d.el._node==d&&a.tag===d.tag&&a.type===d.type&&a.vm===d.vm&&(a.key===d.key||null==d.key))return d}return null}function na(a,b){a:{a=a.key;var c=0,d=b.length-1,e;if(2147483647>=d)for(;c<=d;)if(e=c+d>>1,b[e].key===a){a= | ||
e;break a}else b[e].key<a?c=e+1:d=e-1;else for(;c<=d;)if(e=Math.floor((c+d)/2),b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;a=-1}return-1<a?b[a]:null}function I(a,b,c){b.hooks&&l("willRecycle",b,a);c=a.el=b.el;var d=b.body,e=a.body;c._node=a;if(2==a.type&&e!==d)c.nodeValue=e;else{null==a.attrs&&null==b.attrs||W(a,b);var g=n(d),f=n(e);if(g)if(f){a.flags&4?(c=b.body.slice(),c.sort(oa),d=na):(c=b.body,d=ma);for(var h,e=0,g=a.body,f=0;f<g.length;f++){var k=g[f],m=k.type;3>=m?(h=d(k,c,e))&&I(k, | ||
h):4==m?(h=d(k,c,e))?h.vm._update(k.model,a,f):H(k.view,k.model,k.key,k.opts)._redraw(a,f,!1):5==m&&k.vm._update(k.model,a,f);a.list||null==h||h.idx!=e||e++}1!=a.type||a.flags&1||Z(a,b)}else{if(e!==d)if(null!=e)a.raw?c.innerHTML=e:c.textContent=e;else for(;c.firstChild;)x(c,c.firstChild)}else f?(c.firstChild&&c.removeChild(c.firstChild),X(a)):e!==d&&(a.raw?c.innerHTML=e:c.firstChild?c.firstChild.nodeValue=e:c.textContent=e);b.hooks&&l("didRecycle",b,a)}}function oa(a,b){return a.key>b.key?1:a.key< | ||
b.key?-1:0}function aa(a){var b=new u;b.type=2;b.body=a;return b}function v(a,b,c,d){if(5!=a.type&&4!=a.type){a.parent=b;a.idx=c;a.vm=d;if(null!=a.ref){c=z(a);b=["refs"].concat(a.ref.split("."));for(var e;e=b.shift();)c[e]=0==b.length?a:c=c[e]||{}}if(a.hooks&&a.hooks.willRemove||d&&d.hooks&&d.hooks.willUnmount)for(d=a;d=d.parent;)d.flags|=2;if(n(a.body))for(d=a.body,b=0;b<d.length;b++)c=d[b],!1===c||null==c?d.splice(b--,1):n(c)?(e=b--,d.splice.apply(d,[e,1].concat(c))):(null==c.type&&(d[b]=c=aa(""+ | ||
c)),2==c.type?null==c.body||""==c.body?d.splice(b--,1):0<b&&2==d[b-1].type?(d[b-1].body+=c.body,d.splice(b--,1)):v(c,a,b,null):v(c,a,b,null))}}function A(a,b,c,d){var e=this;e.view=a;e.model=b;e.key=null==c?b:c;a.prototype._isClass?(a=e.diff,null!=a&&a!=r.diff&&(e.diff=r.diff.bind(e),e.diff(a))):(a=a.call(e,e,b,c,d),p(a)?e.render=a:(a.diff&&(e.diff(a.diff),delete a.diff),w(e,a)));d&&(e.opts=d,d.hooks&&e.hook(d.hooks),d.diff&&e.diff(d.diff));e._redrawAsync=M(function(a){return e._redraw()});e._updateAsync= | ||
M(function(a){return e._update(a)});(a=e.hooks)&&a.didInit&&a.didInit.call(e,e,b,c,d)}function C(a){if(F.length)for(a=a.node,a&&a.el&&a.el.offsetHeight;a=F.shift();)a[0](a[1],a[2])}function ba(a,b,c,d){var e,g;null==c?null!=b&&b.constructor==Object?e=b:g=b:(e=b,g=c);c=e;b=new u;b.type=1;null!=d&&(b.flags=d);null!=c&&(null!=c._key&&(b.key=c._key),null!=c._ref&&(b.ref=c._ref),null!=c._hooks&&(b.hooks=c._hooks),null!=c._raw&&(b.raw=c._raw),null!=c._data&&(b.data=c._data),null!=c._flags&&(b.flags=c._flags), | ||
null==b.key&&(null!=b.ref?b.key=b.ref:null!=c.id?b.key=c.id:null!=c.name&&(b.key=c.name)),b.attrs=c);d=ca[a];if(null==d){var f,h,k;for(ca[a]=d={tag:(f=a.match(/^[-\w]+/))?f[0]:"div",id:(h=a.match(/#([-\w]+)/))?h[1]:null,class:(k=a.match(/\.([-\w.]+)/))?k[1].replace(/\./g," "):null,attrs:null};f=pa.exec(a);)null==d.attrs&&(d.attrs={}),d.attrs[f[1]]=f[2]||""}a=d;b.tag=a.tag;if(a.id||a.class||a.attrs){f=b.attrs||{};a.id&&null==f.id&&(f.id=a.id);a.class&&(b._class=a.class,f.class=a.class+(null!=f.class? | ||
" "+f.class:""));if(a.attrs)for(var l in a.attrs)null!=f[l]||(f[l]=a.attrs[l]);b.attrs=f}null!=g&&(b.body=g);return b}function J(a,b,c,d){this.view=a;this.model=b;this.key=null==c?b:c;this.opts=d}function K(a){this.vm=a}function da(a,b){a=a.body;if(n(a))for(var c=0;c<a.length;c++){var d=a[c];null!=d.vm?b.push(d.vm):da(d,b)}return b}var D="undefined"!=typeof window,N=(D?window:{}).requestAnimationFrame,t={},n=Array.isArray,ha={animationIterationCount:!0,boxFlex:!0,boxFlexGroup:!0,columnCount:!0,counterIncrement:!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,tabSize:!0,transform:!0,transformOrigin:!0,widows:!0,zIndex:!0,zoom:!0},ca={},pa=/\[(\w+)(?:=(\w+))?\]/g,F=[],qa=u.prototype={constructor:u,type:null,vm:null,key:null,ref:null,data:null,hooks:null,raw:!1,ns:null,el:null,tag:null,attrs:null,body:null,flags:0,_class:null,idx:null,parent:null},B=D?document:null,S={onevent:function(){}},r=A.prototype= | ||
{constructor:A,_isClass:!1,view:null,key:null,model:null,opts:null,node:null,hooks:null,render:null,parent:function(){return z(this.node.parent)},root:function(){for(var a=this.node;a.parent;)a=a.parent;return a.vm},api:null,refs:null,mount:function(a,b){if(b){for(;a.firstChild;)a.removeChild(a.firstChild);this._redraw(null,null,!1);a.nodeName.toLowerCase()!=this.node.tag?(q(this.node),m(a.parentNode,this.node.el,a),a.parentNode.removeChild(a)):m(a.parentNode,q(this.node,a),a)}else this._redraw(null, | ||
null),a&&m(a,this.node.el);a&&C(this);return this},unmount:function(a){var b=this.node;x(b.el.parentNode,b.el);a||C(this)},redraw:function(a){a?this._redraw():this._redrawAsync();return this},update:function(a,b){b?this._update(a):this._updateAsync(a);return this},_update:function(a,b,c,d){null!=a&&this.model!==a&&(this.hooks&&l("willUpdate",this,a),this.model=a);return this._redraw(b,c,d)},_redraw:function(a,b,c){var d=null==a,e=this.node&&this.node.el&&this.node.el.parentNode,g=this.node;if(e&& | ||
null!=this._diff&&this._diff())return g&&a&&(a.body[b]=g,g.idx=b,g.parent=a),this;e&&this.hooks&&l("willRedraw",this);this.refs=null;var f=this.render.call(this,this,this.model,this.key);!1!==this.key&&(f.key=this.key);this.node=f;a?(v(f,a,b,this),a.body[b]=f):g&&g.parent?(v(f,g.parent,g.idx,this),g.parent.body[g.idx]=f):v(f,null,null,this);!1!==c&&(g?g.tag!==f.tag?(g.vm=f.vm=null,a=g.el.parentNode,b=g.el.nextSibling,x(a,g.el),m(a,q(f),b),g.el=f.el,f.vm=this):I(f,g,d):q(f));e&&this.hooks&&l("didRedraw", | ||
this);d&&e&&C(this);return this},_redrawAsync:null,_updateAsync:null,hook:function(a){this.hooks=this.hooks||w({},this.hooks,a)}};J.prototype={constructor:J,type:4,view:null,model:null,key:null,opts:null};K.prototype={constructor:K,type:5,vm:null};D={config:function(a){w(S,a)},ViewModel:A,VNode:u,createView:H,defineElement:ba,defineSvgElement:function(a,b,c,d){a=ba(a,b,c,d);a.ns="http://www.w3.org/2000/svg";return a},defineText:aa,defineComment:function(a){var b=new u;b.type= | ||
3;b.body=a;return b},defineView:function(a,b,c,d){return new J(a,b,c,d)},injectView:function(a){return new K(a)},injectElement:function(a){var b=new u;b.type=1;b.el=b.key=a;return b},FIXED_BODY:1,DEEP_REMOVE:2,KEYED_LIST:4};r._diff=null;r.diff=function(a){var b=this;if(p(a))var c=a;else var c=a.vals,d=a.then;var e=c.call(b,b,b.model,b.key,b.opts),g=n(e)?L:fa;b._diff=function(){var a=c.call(b,b,b.model,b.key,b.opts),h=g(e,a);h||(null!=d&&!1===d.call(b,b,e,a)&&(h=!0),e=a);return h}};qa.patch=function(a){var b; | ||
a:{if(null!=a.type){if(null!=this.vm){b=void 0;break a}v(a,this.parent,this.idx,null);this.parent.body[this.idx]=a;I(a,this);C(z(a))}else{b=Object.create(this);b.attrs=w({},this.attrs);a=w(this.attrs,a);if(null!=this._class){var c=a.class;a.class=null!=c&&""!=c?this._class+" "+c:this._class}W(this,b)}b=void 0}return b};r.events=null;r.emit=function(a){var b=arguments,c=this;do{var d=c.events;if(d=d?d[a]:null){d.apply(null,ea(b,1));break}}while(c=c.parent())};r.on=function(a,b){null==this.events&& | ||
(this.events={});if(y(a))this.events[a]=b;else for(a in b=a,b)this.on(a,b[a])};r.body=function(){return da(this.node,[])};return D}); |
@@ -7,3 +7,3 @@ /** | ||
* A thin, fast, dependency-free vdom view layer | ||
* @preserve https://github.com/leeoniya/domvm (v2.1.1, mini) | ||
* @preserve https://github.com/leeoniya/domvm (v2.1.3, mini) | ||
*/ | ||
@@ -44,2 +44,6 @@ | ||
function isSet(val) { | ||
return val != null; | ||
} | ||
function isPlainObj(val) { | ||
@@ -66,6 +70,4 @@ return val != null && val.constructor == Object; // && typeof val == "object" | ||
function isElem(val) { | ||
return ENV_DOM && val instanceof HTMLElement; | ||
} | ||
function assignObj(targ) { | ||
@@ -447,6 +449,2 @@ var args = arguments; | ||
function isSet(val) { | ||
return val != null; | ||
} | ||
// (de)optimization flags | ||
@@ -962,3 +960,3 @@ | ||
// from_right: | ||
while(1) { | ||
while (1) { | ||
// if (rgtSib == lftEnd) | ||
@@ -1240,4 +1238,2 @@ // break converge; | ||
vm.api = {}; | ||
vm.view = view; | ||
@@ -1248,3 +1244,3 @@ vm.model = model; | ||
if (!view.prototype._isClass) { | ||
var out = view.call(vm, vm, model, key); // , opts | ||
var out = view.call(vm, vm, model, key, opts); | ||
@@ -1271,2 +1267,3 @@ if (isFunc(out)) | ||
} | ||
// remove this? | ||
@@ -1286,2 +1283,7 @@ if (opts) { | ||
var hooks = vm.hooks; | ||
if (hooks && hooks.didInit) | ||
{ hooks.didInit.call(vm, vm, model, key, opts); } | ||
// this.update(model, parent, idx, parentVm, false); | ||
@@ -1445,2 +1447,5 @@ | ||
if (vm.key !== false) | ||
{ vnew.key = vm.key; } | ||
// console.log(vm.key); | ||
@@ -1704,42 +1709,4 @@ | ||
// does not handle defineComment, defineText, defineSVG (ambiguous); use plain text vals or explicit factories in templates. | ||
// does not handle defineElementSpread (not available in all builds); use exlicit factories in templates. | ||
function h(a) { | ||
return ( | ||
isVal(a) ? defineElement : | ||
isFunc(a) ? defineView : // todo: es6 class constructor | ||
isElem(a) ? injectElement : | ||
a instanceof ViewModel ? injectView : | ||
noop | ||
).apply(null, arguments); | ||
} | ||
function defineElementSpread(tag) { | ||
var args = arguments; | ||
var len = args.length; | ||
var body, attrs; | ||
if (len > 1) { | ||
var bodyIdx = 1; | ||
if (isPlainObj(args[1])) { | ||
attrs = args[1]; | ||
bodyIdx = 2; | ||
} | ||
if (len == bodyIdx + 1 && (isVal(args[bodyIdx]) || isArr(args[bodyIdx]))) | ||
{ body = args[bodyIdx]; } | ||
else | ||
{ body = sliceArgs(args, bodyIdx); } | ||
} | ||
return initElementNode(tag, attrs, body); | ||
} | ||
// #destub: cssTag,autoPx | ||
nano.h = h; | ||
nano.defineElementSpread = defineElementSpread; | ||
ViewModelProto.events = null; | ||
@@ -1746,0 +1713,0 @@ ViewModelProto.emit = emit; |
/* | ||
https://github.com/leeoniya/domvm (v2.1.1, mini) | ||
https://github.com/leeoniya/domvm (v2.1.3, mini) | ||
*/ | ||
'use strict';(function(D,p){"object"===typeof exports&&"undefined"!==typeof module?module.exports=p():"function"===typeof define&&define.amd?define(p):D.domvm=p()})(this,function(){function D(){}function p(a){a=typeof a;return"string"===a||"number"===a}function w(a){return"function"===typeof a}function y(a){for(var b=arguments,c=1;c<b.length;c++)for(var d in b[c])a[d]=b[c][d];return a}function Q(a,b){for(var c=[];b<a.length;b++)c.push(a[b]);return c}function ra(a,b){for(var c in a)if(a[c]!==b[c])return!1; | ||
return!0}function R(a,b){var c=a.length;if(b.length!=c)return!1;for(var d=0;d<c;d++)if(a[d]!==b[d])return!1;return!0}function S(a){function b(){c=0;a.apply(d,e)}if(!T)return a;var c,d,e;return function(){d=this;e=arguments;c||(c=T(b))}}function sa(a,b,c){return function(){return a.apply(c,b)}}function H(a,b){switch(b){case "value":case "checked":case "selected":case "selectedIndex":return!0}return!1}function q(a){for(a=a||u;null==a.vm&&a.parent;)a=a.parent;return a.vm}function U(a){z=a.is;V=a.val; | ||
W=a.sub;X=a.unsub}function E(a,b){var c=W(a,function(a){c&&(null!=b.node&&b.redraw(),X(c))});return V(a)}function Y(a,b){var c=(a.attrs||u).style;b=b?(b.attrs||u).style:null;if(null==c||p(c))a.el.style.cssText=c;else{for(var d in c){var e=c[d];z(e)&&(e=E(e,q(a)));if(null==b||null!=e&&e!==b[d]){var f=a.el.style,g=d,h;h=d;h=isNaN(e)||ta[h]?e:e+"px";f[g]=h}}if(b)for(var k in b)null==c[k]&&(a.el.style[k]="")}}function Z(a,b,c,d,e){if(a)e?(a=c.parent,a&&a.el&&a.el.offsetHeight):I.push([b,c,d]);else return b(c, | ||
d)}function l(a,b,c,d){var e=b.hooks[a];if(e){var f=0===a.lastIndexOf("did",0);return n(e)?e.map(function(a){return Z(f,a,b,c)}):Z(f,e,b,c,d)}}function v(){}function aa(a,b,c,d){var e=new v;e.type=1;null!=d&&(e.flags=d);null!=b&&(null!=b._key&&(e.key=b._key),null!=b._ref&&(e.ref=b._ref),null!=b._hooks&&(e.hooks=b._hooks),null!=b._raw&&(e.raw=b._raw),null!=b._data&&(e.data=b._data),null!=b._flags&&(e.flags=b._flags),null==e.key&&(null!=e.ref?e.key=e.ref:null!=b.id?e.key=b.id:null!=b.name&&(e.key=b.name)), | ||
e.attrs=b);b=ba[a];if(null==b){var f,g,h;for(ba[a]=b={tag:(f=a.match(/^[-\w]+/))?f[0]:"div",id:(g=a.match(/#([-\w]+)/))?g[1]:null,class:(h=a.match(/\.([-\w.]+)/))?h[1].replace(/\./g," "):null,attrs:null};f=ua.exec(a);)null==b.attrs&&(b.attrs={}),b.attrs[f[1]]=f[2]||""}a=b;e.tag=a.tag;if(a.id||a.class||a.attrs){f=e.attrs||{};a.id&&null==f.id&&(f.id=a.id);a.class&&(e._class=a.class,f.class=a.class+(null!=f.class?" "+f.class:""));if(a.attrs)for(var k in a.attrs)null==f[k]&&(f[k]=a.attrs[k]);e.attrs= | ||
f}null!=c&&(e.body=c);return e}function ca(a){var b=a.hooks,c=a.vm;c&&c.hooks&&l("willUnmount",c);b=b&&l("willRemove",a);if(a.flags&2&&n(a.body))for(c=0;c<a.body.length;c++)ca(a.body[c]);return b}function J(a,b,c){var d=b._node,e=d.hooks,f=d.vm;if(d.flags&2&&n(d.body))for(var g=0;g<d.body.length;g++)J(b,d.body[g].el);a.removeChild(b);e&&l("didRemove",d,null,c);f&&f.hooks&&l("didUnmount",f,null,c)}function A(a,b){var c=ca(b._node);null!=c&&"object"===typeof c&&w(c.then)?c.then(sa(J,[a,b,!0])):J(a, | ||
b)}function m(a,b,c){var d=b._node,e=d.hooks,f=null!=b.parentNode,g=(b==c||!f)&&d.vm;g&&g.hooks&&l("willMount",g);e&&l(f?"willReinsert":"willInsert",d);a.insertBefore(b,c);e&&l(f?"didReinsert":"didInsert",d);g&&g.hooks&&l("didMount",g)}function da(a,b,c){var d;for(d=a.target;null==d._node;)d=d.parentNode;d=d._node;var e=q(d);b=b.apply(null,c.concat(a,d,e));ea.onevent.apply(null,[a,d,e].concat(c));!1===b&&(a.preventDefault(),a.stopPropagation())}function fa(a,b){return function(c){da(c,a,b)}}function va(a){return function(b){for(var c in a)if(b.target.matches(c)){var d= | ||
a[c],e=n(d),f=e?d[0]:d,d=e?d.slice(1):[];da(b,f,d)}}}function ga(a,b,c,d){c!==d&&(a=a.el,n(c)?null!=d&&R(c,d)||(c=fa(c[0],c.slice(1)),a[b]=c):(c=w(c)&&c!=d?fa(c,[]):va(c),a[b]=c))}function ha(a,b,c,d){var e=a.el;null==c?a.el.removeAttribute(b):null!=a.ns?e.setAttribute(b,c):"class"==b?e.className=c:"id"==b||"boolean"==typeof c||d?e[b]=c:"."==b[0]?e[b.substr(1)]=c:e.setAttribute(b,c)}function ia(a,b){var c=a.attrs||u,d=b.attrs||u,e;for(e in c){var f=c[e],g=H(a.tag,e),h=g?a.el[e]:d[e];z(f)&&(c[e]=f= | ||
E(f,q(a)));f!==h&&("style"==e?Y(a,b):"_"==e[0]||(0===e.lastIndexOf("on",0)?ga(a,e,f,h):ha(a,e,f,g)))}for(e in d)e in c||"_"==e[0]||(b=a,d=e,H(a.tag,e)||0===e.lastIndexOf("on",0)?b.el[d]="":b.el.removeAttribute(d))}function K(a,b,c,d){if(4==a.type)b=a.model,c=a.key,d=a.opts,a=a.view;else if(a.prototype._isClass)return new a(b,c,d);return new B(a,b,c,d)}function ja(a){for(var b=0;b<a.body.length;b++){var c=a.body[b],d=c.type;3>=d?m(a.el,r(c)):4==d?(c=K(c.view,c.model,c.key,c.opts)._redraw(a,b,!1),m(a.el, | ||
r(c.node))):5==d&&(c=c.vm,c._redraw(a,b),m(a.el,c.node.el))}}function r(a,b){if(null==a.el)if(1==a.type){if(!b){b=a.tag;var c=a.ns;b=null!=c?F.createElementNS(c,b):F.createElement(b)}a.el=b;if(null!=a.attrs){b=a.attrs;for(var d in b){var c=b[d],e=H(a.tag,d);z(c)&&(b[d]=c=E(c,q(a)));"style"==d?Y(a):"_"==d[0]||(0===d.lastIndexOf("on",0)?ga(a,d,c):null!=c&&ha(a,d,c,e))}}n(a.body)?ja(a):null!=a.body&&""!==a.body&&(a.raw?a.el.innerHTML=a.body:a.el.textContent=a.body)}else 2==a.type?a.el=b||F.createTextNode(a.body): | ||
3==a.type&&(a.el=b||F.createComment(a.body));a.el._node=a;return a.el}function ka(a,b,c,d){c=c.previousSibling;d=d.nextSibling;a(c,d);return{lftSib:c?c.nextSibling:b.firstChild,rgtSib:d?d.previousSibling:b.lastChild}}function wa(a,b,c,d,e){var f=e.idx==c.idx+1,g=f?!1:b._node==e,h=f?!0:d._node==c;return g||h?ka(function(c,e){h&&m(a,d,b);g&&m(a,b,e)},a,b,d):null}function xa(a,b,c,d){return ka(function(c,f){for(var e=b;e!==f;e=e.nextSibling){b=c=e;for(var h=e.nextSibling;h!==f;h=h.nextSibling)0<d(c, | ||
h)&&(c=h);c!==e&&(m(a,c,b),e=c)}},a,b,c)}function ya(a,b){return a._node.idx-b._node.idx}function la(a,b){var c=a.el,d=a.body,e=b.body;b=d[0];var f=d[d.length-1],g=(e[0]||u).el,e=(e[e.length-1]||u).el,h,k,l;a:for(;;){for(;;)if(g&&(k=g._node).parent!=a)h=g.nextSibling,null!=k.vm?k.vm.unmount(!0):A(c,g),g=h;else if(null==b)break a;else if(null==b.el)m(c,r(b),g),b=d[b.idx+1];else if(b.el===g)b=d[b.idx+1],g=g.nextSibling;else break;for(;;)if(e&&(l=e._node).parent!=a)h=e.previousSibling,null!=l.vm?l.vm.unmount(!0): | ||
A(c,e),e=h;else if(f==b)break a;else if(null==f.el)h=r(f),m(c,h,e?e.nextSibling:null),f=d[f.idx-1];else if(f.el===e)f=d[f.idx-1],e=e.previousSibling;else break;(h=wa(c,g,b,e,f))||(h=xa(c,g,e,ya));g=h.lftSib;e=h.rgtSib}}function za(a,b,c,d){for(;c<b.length;c++){d=b[c];if(4==a.type&&null!=d.vm){var e=d.vm;if(e.view==a.view&&e.key==a.key)return d}if(d.el._node==d&&a.tag===d.tag&&a.type===d.type&&a.vm===d.vm&&(a.key===d.key||null==d.key))return d}return null}function Aa(a,b){a:{a=a.key;var c=0,d=b.length- | ||
1,e;if(2147483647>=d)for(;c<=d;)if(e=c+d>>1,b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;else for(;c<=d;)if(e=Math.floor((c+d)/2),b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;a=-1}return-1<a?b[a]:null}function L(a,b,c){b.hooks&&l("willRecycle",b,a);c=a.el=b.el;var d=b.body,e=a.body;c._node=a;if(2==a.type&&e!==d)c.nodeValue=e;else{null==a.attrs&&null==b.attrs||ia(a,b);var f=n(d),g=n(e);if(f)if(g){a.flags&4?(c=b.body.slice(),c.sort(Ba),d=Aa):(c=b.body,d=za);for(var h,e=0,f=a.body, | ||
g=0;g<f.length;g++){var k=f[g],m=k.type;3>=m?(h=d(k,c,e))&&L(k,h):4==m?(h=d(k,c,e))?h.vm._update(k.model,a,g):K(k.view,k.model,k.key,k.opts)._redraw(a,g,!1):5==m&&k.vm._update(k.model,a,g);a.list||null==h||h.idx!=e||e++}1!=a.type||a.flags&1||la(a,b)}else{if(e!==d)if(null!=e)a.raw?c.innerHTML=e:c.textContent=e;else for(;c.firstChild;)A(c,c.firstChild)}else g?(c.firstChild&&c.removeChild(c.firstChild),ja(a)):e!==d&&(a.raw?c.innerHTML=e:c.firstChild?c.firstChild.nodeValue=e:c.textContent=e);b.hooks&& | ||
l("didRecycle",b,a)}}function Ba(a,b){return a.key>b.key?1:a.key<b.key?-1:0}function ma(a){var b=new v;b.type=2;b.body=a;return b}function x(a,b,c,d){if(5!=a.type&&4!=a.type){a.parent=b;a.idx=c;a.vm=d;if(null!=a.ref){c=q(a);b=["refs"].concat(a.ref.split("."));for(var e;e=b.shift();)c[e]=0==b.length?a:c=c[e]||{}}if(a.hooks&&a.hooks.willRemove||d&&d.hooks&&d.hooks.willUnmount)for(d=a;d=d.parent;)d.flags|=2;if(n(a.body))for(d=a.body,b=0;b<d.length;b++)c=d[b],!1===c||null==c?d.splice(b--,1):n(c)?(e=b--, | ||
d.splice.apply(d,[e,1].concat(c))):(null==c.type&&(d[b]=c=ma(""+c)),2==c.type?null==c.body||""==c.body?d.splice(b--,1):0<b&&2==d[b-1].type?(d[b-1].body+=c.body,d.splice(b--,1)):x(c,a,b,null):x(c,a,b,null));else z(a.body)&&(a.body=E(a.body,q(a)))}}function B(a,b,c,d){var e=this;e.api={};e.view=a;e.model=b;e.key=null==c?b:c;a.prototype._isClass?(a=e.diff,null!=a&&a!=t.diff&&(e.diff=t.diff.bind(e),e.diff(a))):(a=a.call(e,e,b,c),w(a)?e.render=a:(a.diff&&(e.diff(a.diff),delete a.diff),y(e,a)));d&&(e.opts= | ||
d,d.hooks&&e.hook(d.hooks),d.diff&&e.diff(d.diff));e._redrawAsync=S(function(a){return e._redraw()});e._updateAsync=S(function(a){return e._update(a)})}function G(a){if(I.length)for(a=a.node,a&&a.el&&a.el.offsetHeight;a=I.shift();)a[0](a[1],a[2])}function M(a,b,c,d){var e,f;null==c?null!=b&&b.constructor==Object?e=b:f=b:(e=b,f=c);return aa(a,e,f,d)}function N(a,b,c,d){this.view=a;this.model=b;this.key=null==c?b:c;this.opts=d}function na(a,b,c,d){return new N(a,b,c,d)}function O(a){this.vm=a}function oa(a){return new O(a)} | ||
function pa(a){var b=new v;b.type=1;b.el=b.key=a;return b}function qa(a,b){a=a.body;if(n(a))for(var c=0;c<a.length;c++){var d=a[c];null!=d.vm?b.push(d.vm):qa(d,b)}return b}var P="undefined"!=typeof window,T=(P?window:{}).requestAnimationFrame,u={},n=Array.isArray,ta={animationIterationCount:!0,boxFlex:!0,boxFlexGroup:!0,columnCount:!0,counterIncrement:!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,tabSize:!0,transform:!0,transformOrigin:!0,widows:!0,zIndex:!0,zoom:!0},ba={},ua=/\[(\w+)(?:=(\w+))?\]/g,z=function(){return!1},V=null,W=null,X=null,I=[],Ca=v.prototype={constructor:v,type:null,vm:null,key:null,ref:null,data:null,hooks:null,raw:!1,ns:null,el:null,tag:null,attrs:null,body:null,flags:0,_class:null,idx:null,parent:null},F=P?document:null,ea={onevent:D},t=B.prototype={constructor:B,_isClass:!1,view:null,key:null,model:null,opts:null,node:null,hooks:null,render:null,parent:function(){return q(this.node.parent)}, | ||
root:function(){for(var a=this.node;a.parent;)a=a.parent;return a.vm},api:null,refs:null,mount:function(a,b){if(b){for(;a.firstChild;)a.removeChild(a.firstChild);this._redraw(null,null,!1);a.nodeName.toLowerCase()!=this.node.tag?(r(this.node),m(a.parentNode,this.node.el,a),a.parentNode.removeChild(a)):m(a.parentNode,r(this.node,a),a)}else this._redraw(null,null),a&&m(a,this.node.el);a&&G(this);return this},unmount:function(a){var b=this.node;A(b.el.parentNode,b.el);a||G(this)},redraw:function(a){a? | ||
this._redraw():this._redrawAsync();return this},update:function(a,b){b?this._update(a):this._updateAsync(a);return this},_update:function(a,b,c,d){null!=a&&this.model!==a&&(this.hooks&&l("willUpdate",this,a),this.model=a);return this._redraw(b,c,d)},_redraw:function(a,b,c){var d=null==a,e=this.node&&this.node.el&&this.node.el.parentNode,f=this.node;if(e&&null!=this._diff&&this._diff())return f&&a&&(a.body[b]=f,f.idx=b,f.parent=a),this;e&&this.hooks&&l("willRedraw",this);this.refs=null;var g=this.render.call(this, | ||
this,this.model,this.key);this.node=g;a?(x(g,a,b,this),a.body[b]=g):f&&f.parent?(x(g,f.parent,f.idx,this),f.parent.body[f.idx]=g):x(g,null,null,this);!1!==c&&(f?f.tag!==g.tag?(f.vm=g.vm=null,a=f.el.parentNode,b=f.el.nextSibling,A(a,f.el),m(a,r(g),b),f.el=g.el,g.vm=this):L(g,f,d):r(g));e&&this.hooks&&l("didRedraw",this);d&&e&&G(this);return this},_redrawAsync:null,_updateAsync:null,hook:function(a){this.hooks=this.hooks||y({},this.hooks,a)}};N.prototype={constructor:N,type:4,view:null,model:null,key:null, | ||
opts:null};O.prototype={constructor:O,type:5,vm:null};var C={config:function(a){y(ea,a)},ViewModel:B,VNode:v,createView:K,defineElement:M,defineSvgElement:function(a,b,c,d){a=M(a,b,c,d);a.ns="http://www.w3.org/2000/svg";return a},defineText:ma,defineComment:function(a){var b=new v;b.type=3;b.body=a;return b},defineView:na,injectView:oa,injectElement:pa,FIXED_BODY:1,DEEP_REMOVE:2,KEYED_LIST:4};t._diff=null;t.diff=function(a){var b=this;if(w(a))var c=a;else var c=a.vals,d=a.then; | ||
var e=c.call(b,b,b.model,b.key,b.opts),f=n(e)?R:ra;b._diff=function(){var a=c.call(b,b,b.model,b.key,b.opts),h=f(e,a);h||(null!=d&&!1===d.call(b,b,e,a)&&(h=!0),e=a);return h}};Ca.patch=function(a){var b;a:{if(null!=a.type){if(null!=this.vm){b=void 0;break a}x(a,this.parent,this.idx,null);this.parent.body[this.idx]=a;L(a,this);G(q(a))}else{b=Object.create(this);b.attrs=y({},this.attrs);a=y(this.attrs,a);if(null!=this._class){var c=a.class;a.class=null!=c&&""!=c?this._class+" "+c:this._class}ia(this, | ||
b)}b=void 0}return b};C.h=function(a){return(p(a)?M:w(a)?na:P&&a instanceof HTMLElement?pa:a instanceof B?oa:D).apply(null,arguments)};C.defineElementSpread=function(a){var b=arguments,c=b.length,d,e;if(1<c){d=1;var f=b[1];null!=f&&f.constructor==Object&&(e=b[1],d=2);d=c==d+1&&(p(b[d])||n(b[d]))?b[d]:Q(b,d)}return aa(a,e,d)};t.events=null;t.emit=function(a){var b=arguments,c=this;do{var d=c.events;if(d=d?d[a]:null){d.apply(null,Q(b,1));break}}while(c=c.parent())};t.on=function(a,b){null==this.events&& | ||
(this.events={});if(p(a))this.events[a]=b;else for(a in b=a,b)this.on(a,b[a])};t.body=function(){return qa(this.node,[])};"undefined"!=typeof flyd&&U({is:function(a){return flyd.isStream(a)},val:function(a){return a()},sub:function(a,b){return flyd.on(b,a)},unsub:function(a){return a.end(!0)}});C.streamCfg=U;C.prop=function(a,b,c,d){return function(e,f){"undefined"!=typeof e&&e!==a&&(a=e,!1!==f&&w(b)&&b.apply(c,d));return a}};return C}); | ||
'use strict';(function(B,p){"object"===typeof exports&&"undefined"!==typeof module?module.exports=p():"function"===typeof define&&define.amd?define(p):B.domvm=p()})(this,function(){function B(a){a=typeof a;return"string"===a||"number"===a}function p(a){return"function"===typeof a}function y(a){for(var b=arguments,c=1;c<b.length;c++)for(var d in b[c])a[d]=b[c][d];return a}function ka(a,b){for(var c=[];b<a.length;b++)c.push(a[b]);return c}function la(a,b){for(var c in a)if(a[c]!==b[c])return!1;return!0} | ||
function N(a,b){var c=a.length;if(b.length!=c)return!1;for(var d=0;d<c;d++)if(a[d]!==b[d])return!1;return!0}function O(a){function b(){c=0;a.apply(d,e)}if(!P)return a;var c,d,e;return function(){d=this;e=arguments;c||(c=P(b))}}function ma(a,b,c){return function(){return a.apply(c,b)}}function G(a,b){switch(b){case "value":case "checked":case "selected":case "selectedIndex":return!0}return!1}function q(a){for(a=a||u;null==a.vm&&a.parent;)a=a.parent;return a.vm}function Q(a){z=a.is;R=a.val;S=a.sub; | ||
T=a.unsub}function C(a,b){var c=S(a,function(a){c&&(null!=b.node&&b.redraw(),T(c))});return R(a)}function U(a,b){var c=(a.attrs||u).style;b=b?(b.attrs||u).style:null;if(null==c||B(c))a.el.style.cssText=c;else{for(var d in c){var e=c[d];z(e)&&(e=C(e,q(a)));if(null==b||null!=e&&e!==b[d]){var g=a.el.style,f=d,h;h=d;h=isNaN(e)||na[h]?e:e+"px";g[f]=h}}if(b)for(var k in b)null==c[k]&&(a.el.style[k]="")}}function V(a,b,c,d,e){if(a)e?(a=c.parent,a&&a.el&&a.el.offsetHeight):H.push([b,c,d]);else return b(c, | ||
d)}function l(a,b,c,d){var e=b.hooks[a];if(e){var g=0===a.lastIndexOf("did",0);return n(e)?e.map(function(a){return V(g,a,b,c)}):V(g,e,b,c,d)}}function v(){}function W(a){var b=a.hooks,c=a.vm;c&&c.hooks&&l("willUnmount",c);b=b&&l("willRemove",a);if(a.flags&2&&n(a.body))for(c=0;c<a.body.length;c++)W(a.body[c]);return b}function I(a,b,c){var d=b._node,e=d.hooks,g=d.vm;if(d.flags&2&&n(d.body))for(var f=0;f<d.body.length;f++)I(b,d.body[f].el);a.removeChild(b);e&&l("didRemove",d,null,c);g&&g.hooks&&l("didUnmount", | ||
g,null,c)}function A(a,b){var c=W(b._node);null!=c&&"object"===typeof c&&p(c.then)?c.then(ma(I,[a,b,!0])):I(a,b)}function m(a,b,c){var d=b._node,e=d.hooks,g=null!=b.parentNode,f=(b==c||!g)&&d.vm;f&&f.hooks&&l("willMount",f);e&&l(g?"willReinsert":"willInsert",d);a.insertBefore(b,c);e&&l(g?"didReinsert":"didInsert",d);f&&f.hooks&&l("didMount",f)}function X(a,b,c){var d;for(d=a.target;null==d._node;)d=d.parentNode;d=d._node;var e=q(d);b=b.apply(null,c.concat(a,d,e));Y.onevent.apply(null,[a,d,e].concat(c)); | ||
!1===b&&(a.preventDefault(),a.stopPropagation())}function Z(a,b){return function(c){X(c,a,b)}}function oa(a){return function(b){for(var c in a)if(b.target.matches(c)){var d=a[c],e=n(d),g=e?d[0]:d,d=e?d.slice(1):[];X(b,g,d)}}}function aa(a,b,c,d){c!==d&&(a=a.el,n(c)?null!=d&&N(c,d)||(c=Z(c[0],c.slice(1)),a[b]=c):(c=p(c)&&c!=d?Z(c,[]):oa(c),a[b]=c))}function ba(a,b,c,d){var e=a.el;null==c?a.el.removeAttribute(b):null!=a.ns?e.setAttribute(b,c):"class"==b?e.className=c:"id"==b||"boolean"==typeof c||d? | ||
e[b]=c:"."==b[0]?e[b.substr(1)]=c:e.setAttribute(b,c)}function ca(a,b){var c=a.attrs||u,d=b.attrs||u,e;for(e in c){var g=c[e],f=G(a.tag,e),h=f?a.el[e]:d[e];z(g)&&(c[e]=g=C(g,q(a)));g!==h&&("style"==e?U(a,b):"_"==e[0]||(0===e.lastIndexOf("on",0)?aa(a,e,g,h):ba(a,e,g,f)))}for(e in d)e in c||"_"==e[0]||(b=a,d=e,G(a.tag,e)||0===e.lastIndexOf("on",0)?b.el[d]="":b.el.removeAttribute(d))}function J(a,b,c,d){if(4==a.type)b=a.model,c=a.key,d=a.opts,a=a.view;else if(a.prototype._isClass)return new a(b,c,d); | ||
return new D(a,b,c,d)}function da(a){for(var b=0;b<a.body.length;b++){var c=a.body[b],d=c.type;3>=d?m(a.el,r(c)):4==d?(c=J(c.view,c.model,c.key,c.opts)._redraw(a,b,!1),m(a.el,r(c.node))):5==d&&(c=c.vm,c._redraw(a,b),m(a.el,c.node.el))}}function r(a,b){if(null==a.el)if(1==a.type){if(!b){b=a.tag;var c=a.ns;b=null!=c?E.createElementNS(c,b):E.createElement(b)}a.el=b;if(null!=a.attrs){b=a.attrs;for(var d in b){var c=b[d],e=G(a.tag,d);z(c)&&(b[d]=c=C(c,q(a)));"style"==d?U(a):"_"==d[0]||(0===d.lastIndexOf("on", | ||
0)?aa(a,d,c):null!=c&&ba(a,d,c,e))}}n(a.body)?da(a):null!=a.body&&""!==a.body&&(a.raw?a.el.innerHTML=a.body:a.el.textContent=a.body)}else 2==a.type?a.el=b||E.createTextNode(a.body):3==a.type&&(a.el=b||E.createComment(a.body));a.el._node=a;return a.el}function ea(a,b,c,d){c=c.previousSibling;d=d.nextSibling;a(c,d);return{lftSib:c?c.nextSibling:b.firstChild,rgtSib:d?d.previousSibling:b.lastChild}}function pa(a,b,c,d,e){var g=e.idx==c.idx+1,f=g?!1:b._node==e,h=g?!0:d._node==c;return f||h?ea(function(c, | ||
e){h&&m(a,d,b);f&&m(a,b,e)},a,b,d):null}function qa(a,b,c,d){return ea(function(c,g){for(var e=b;e!==g;e=e.nextSibling){b=c=e;for(var h=e.nextSibling;h!==g;h=h.nextSibling)0<d(c,h)&&(c=h);c!==e&&(m(a,c,b),e=c)}},a,b,c)}function ra(a,b){return a._node.idx-b._node.idx}function fa(a,b){var c=a.el,d=a.body,e=b.body;b=d[0];var g=d[d.length-1],f=(e[0]||u).el,e=(e[e.length-1]||u).el,h,k,l;a:for(;;){for(;;)if(f&&(k=f._node).parent!=a)h=f.nextSibling,null!=k.vm?k.vm.unmount(!0):A(c,f),f=h;else if(null==b)break a; | ||
else if(null==b.el)m(c,r(b),f),b=d[b.idx+1];else if(b.el===f)b=d[b.idx+1],f=f.nextSibling;else break;for(;;)if(e&&(l=e._node).parent!=a)h=e.previousSibling,null!=l.vm?l.vm.unmount(!0):A(c,e),e=h;else if(g==b)break a;else if(null==g.el)h=r(g),m(c,h,e?e.nextSibling:null),g=d[g.idx-1];else if(g.el===e)g=d[g.idx-1],e=e.previousSibling;else break;(h=pa(c,f,b,e,g))||(h=qa(c,f,e,ra));f=h.lftSib;e=h.rgtSib}}function sa(a,b,c,d){for(;c<b.length;c++){d=b[c];if(4==a.type&&null!=d.vm){var e=d.vm;if(e.view==a.view&& | ||
e.key==a.key)return d}if(d.el._node==d&&a.tag===d.tag&&a.type===d.type&&a.vm===d.vm&&(a.key===d.key||null==d.key))return d}return null}function ta(a,b){a:{a=a.key;var c=0,d=b.length-1,e;if(2147483647>=d)for(;c<=d;)if(e=c+d>>1,b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;else for(;c<=d;)if(e=Math.floor((c+d)/2),b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;a=-1}return-1<a?b[a]:null}function K(a,b,c){b.hooks&&l("willRecycle",b,a);c=a.el=b.el;var d=b.body,e=a.body;c._node=a;if(2==a.type&& | ||
e!==d)c.nodeValue=e;else{null==a.attrs&&null==b.attrs||ca(a,b);var g=n(d),f=n(e);if(g)if(f){a.flags&4?(c=b.body.slice(),c.sort(ua),d=ta):(c=b.body,d=sa);for(var h,e=0,g=a.body,f=0;f<g.length;f++){var k=g[f],m=k.type;3>=m?(h=d(k,c,e))&&K(k,h):4==m?(h=d(k,c,e))?h.vm._update(k.model,a,f):J(k.view,k.model,k.key,k.opts)._redraw(a,f,!1):5==m&&k.vm._update(k.model,a,f);a.list||null==h||h.idx!=e||e++}1!=a.type||a.flags&1||fa(a,b)}else{if(e!==d)if(null!=e)a.raw?c.innerHTML=e:c.textContent=e;else for(;c.firstChild;)A(c, | ||
c.firstChild)}else f?(c.firstChild&&c.removeChild(c.firstChild),da(a)):e!==d&&(a.raw?c.innerHTML=e:c.firstChild?c.firstChild.nodeValue=e:c.textContent=e);b.hooks&&l("didRecycle",b,a)}}function ua(a,b){return a.key>b.key?1:a.key<b.key?-1:0}function ga(a){var b=new v;b.type=2;b.body=a;return b}function w(a,b,c,d){if(5!=a.type&&4!=a.type){a.parent=b;a.idx=c;a.vm=d;if(null!=a.ref){c=q(a);b=["refs"].concat(a.ref.split("."));for(var e;e=b.shift();)c[e]=0==b.length?a:c=c[e]||{}}if(a.hooks&&a.hooks.willRemove|| | ||
d&&d.hooks&&d.hooks.willUnmount)for(d=a;d=d.parent;)d.flags|=2;if(n(a.body))for(d=a.body,b=0;b<d.length;b++)c=d[b],!1===c||null==c?d.splice(b--,1):n(c)?(e=b--,d.splice.apply(d,[e,1].concat(c))):(null==c.type&&(d[b]=c=ga(""+c)),2==c.type?null==c.body||""==c.body?d.splice(b--,1):0<b&&2==d[b-1].type?(d[b-1].body+=c.body,d.splice(b--,1)):w(c,a,b,null):w(c,a,b,null));else z(a.body)&&(a.body=C(a.body,q(a)))}}function D(a,b,c,d){var e=this;e.view=a;e.model=b;e.key=null==c?b:c;a.prototype._isClass?(a=e.diff, | ||
null!=a&&a!=t.diff&&(e.diff=t.diff.bind(e),e.diff(a))):(a=a.call(e,e,b,c,d),p(a)?e.render=a:(a.diff&&(e.diff(a.diff),delete a.diff),y(e,a)));d&&(e.opts=d,d.hooks&&e.hook(d.hooks),d.diff&&e.diff(d.diff));e._redrawAsync=O(function(a){return e._redraw()});e._updateAsync=O(function(a){return e._update(a)});(a=e.hooks)&&a.didInit&&a.didInit.call(e,e,b,c,d)}function F(a){if(H.length)for(a=a.node,a&&a.el&&a.el.offsetHeight;a=H.shift();)a[0](a[1],a[2])}function ha(a,b,c,d){var e,g;null==c?null!=b&&b.constructor== | ||
Object?e=b:g=b:(e=b,g=c);c=e;b=new v;b.type=1;null!=d&&(b.flags=d);null!=c&&(null!=c._key&&(b.key=c._key),null!=c._ref&&(b.ref=c._ref),null!=c._hooks&&(b.hooks=c._hooks),null!=c._raw&&(b.raw=c._raw),null!=c._data&&(b.data=c._data),null!=c._flags&&(b.flags=c._flags),null==b.key&&(null!=b.ref?b.key=b.ref:null!=c.id?b.key=c.id:null!=c.name&&(b.key=c.name)),b.attrs=c);d=ia[a];if(null==d){var f,h,k;for(ia[a]=d={tag:(f=a.match(/^[-\w]+/))?f[0]:"div",id:(h=a.match(/#([-\w]+)/))?h[1]:null,class:(k=a.match(/\.([-\w.]+)/))? | ||
k[1].replace(/\./g," "):null,attrs:null};f=va.exec(a);)null==d.attrs&&(d.attrs={}),d.attrs[f[1]]=f[2]||""}a=d;b.tag=a.tag;if(a.id||a.class||a.attrs){f=b.attrs||{};a.id&&null==f.id&&(f.id=a.id);a.class&&(b._class=a.class,f.class=a.class+(null!=f.class?" "+f.class:""));if(a.attrs)for(var l in a.attrs)null!=f[l]||(f[l]=a.attrs[l]);b.attrs=f}null!=g&&(b.body=g);return b}function L(a,b,c,d){this.view=a;this.model=b;this.key=null==c?b:c;this.opts=d}function M(a){this.vm=a}function ja(a,b){a=a.body;if(n(a))for(var c= | ||
0;c<a.length;c++){var d=a[c];null!=d.vm?b.push(d.vm):ja(d,b)}return b}var x="undefined"!=typeof window,P=(x?window:{}).requestAnimationFrame,u={},n=Array.isArray,na={animationIterationCount:!0,boxFlex:!0,boxFlexGroup:!0,columnCount:!0,counterIncrement:!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,tabSize:!0,transform:!0,transformOrigin:!0,widows:!0,zIndex:!0,zoom:!0},ia={},va=/\[(\w+)(?:=(\w+))?\]/g, | ||
z=function(){return!1},R=null,S=null,T=null,H=[],wa=v.prototype={constructor:v,type:null,vm:null,key:null,ref:null,data:null,hooks:null,raw:!1,ns:null,el:null,tag:null,attrs:null,body:null,flags:0,_class:null,idx:null,parent:null},E=x?document:null,Y={onevent:function(){}},t=D.prototype={constructor:D,_isClass:!1,view:null,key:null,model:null,opts:null,node:null,hooks:null,render:null,parent:function(){return q(this.node.parent)},root:function(){for(var a=this.node;a.parent;)a=a.parent;return a.vm}, | ||
api:null,refs:null,mount:function(a,b){if(b){for(;a.firstChild;)a.removeChild(a.firstChild);this._redraw(null,null,!1);a.nodeName.toLowerCase()!=this.node.tag?(r(this.node),m(a.parentNode,this.node.el,a),a.parentNode.removeChild(a)):m(a.parentNode,r(this.node,a),a)}else this._redraw(null,null),a&&m(a,this.node.el);a&&F(this);return this},unmount:function(a){var b=this.node;A(b.el.parentNode,b.el);a||F(this)},redraw:function(a){a?this._redraw():this._redrawAsync();return this},update:function(a,b){b? | ||
this._update(a):this._updateAsync(a);return this},_update:function(a,b,c,d){null!=a&&this.model!==a&&(this.hooks&&l("willUpdate",this,a),this.model=a);return this._redraw(b,c,d)},_redraw:function(a,b,c){var d=null==a,e=this.node&&this.node.el&&this.node.el.parentNode,g=this.node;if(e&&null!=this._diff&&this._diff())return g&&a&&(a.body[b]=g,g.idx=b,g.parent=a),this;e&&this.hooks&&l("willRedraw",this);this.refs=null;var f=this.render.call(this,this,this.model,this.key);!1!==this.key&&(f.key=this.key); | ||
this.node=f;a?(w(f,a,b,this),a.body[b]=f):g&&g.parent?(w(f,g.parent,g.idx,this),g.parent.body[g.idx]=f):w(f,null,null,this);!1!==c&&(g?g.tag!==f.tag?(g.vm=f.vm=null,a=g.el.parentNode,b=g.el.nextSibling,A(a,g.el),m(a,r(f),b),g.el=f.el,f.vm=this):K(f,g,d):r(f));e&&this.hooks&&l("didRedraw",this);d&&e&&F(this);return this},_redrawAsync:null,_updateAsync:null,hook:function(a){this.hooks=this.hooks||y({},this.hooks,a)}};L.prototype={constructor:L,type:4,view:null,model:null,key:null,opts:null};M.prototype= | ||
{constructor:M,type:5,vm:null};x={config:function(a){y(Y,a)},ViewModel:D,VNode:v,createView:J,defineElement:ha,defineSvgElement:function(a,b,c,d){a=ha(a,b,c,d);a.ns="http://www.w3.org/2000/svg";return a},defineText:ga,defineComment:function(a){var b=new v;b.type=3;b.body=a;return b},defineView:function(a,b,c,d){return new L(a,b,c,d)},injectView:function(a){return new M(a)},injectElement:function(a){var b=new v;b.type=1;b.el=b.key=a;return b},FIXED_BODY:1,DEEP_REMOVE:2,KEYED_LIST:4}; | ||
t._diff=null;t.diff=function(a){var b=this;if(p(a))var c=a;else var c=a.vals,d=a.then;var e=c.call(b,b,b.model,b.key,b.opts),g=n(e)?N:la;b._diff=function(){var a=c.call(b,b,b.model,b.key,b.opts),h=g(e,a);h||(null!=d&&!1===d.call(b,b,e,a)&&(h=!0),e=a);return h}};wa.patch=function(a){var b;a:{if(null!=a.type){if(null!=this.vm){b=void 0;break a}w(a,this.parent,this.idx,null);this.parent.body[this.idx]=a;K(a,this);F(q(a))}else{b=Object.create(this);b.attrs=y({},this.attrs);a=y(this.attrs,a);if(null!= | ||
this._class){var c=a.class;a.class=null!=c&&""!=c?this._class+" "+c:this._class}ca(this,b)}b=void 0}return b};t.events=null;t.emit=function(a){var b=arguments,c=this;do{var d=c.events;if(d=d?d[a]:null){d.apply(null,ka(b,1));break}}while(c=c.parent())};t.on=function(a,b){null==this.events&&(this.events={});if(B(a))this.events[a]=b;else for(a in b=a,b)this.on(a,b[a])};t.body=function(){return ja(this.node,[])};"undefined"!=typeof flyd&&Q({is:function(a){return flyd.isStream(a)},val:function(a){return a()}, | ||
sub:function(a,b){return flyd.on(b,a)},unsub:function(a){return a.end(!0)}});x.streamCfg=Q;x.prop=function(a,b,c,d){return function(e,g){"undefined"!=typeof e&&e!==a&&(a=e,!1!==g&&p(b)&&b.apply(c,d));return a}};return x}); |
@@ -7,3 +7,3 @@ /** | ||
* A thin, fast, dependency-free vdom view layer | ||
* @preserve https://github.com/leeoniya/domvm (v2.1.1, nano) | ||
* @preserve https://github.com/leeoniya/domvm (v2.1.3, nano) | ||
*/ | ||
@@ -44,2 +44,6 @@ | ||
function isSet(val) { | ||
return val != null; | ||
} | ||
function isPlainObj(val) { | ||
@@ -66,6 +70,4 @@ return val != null && val.constructor == Object; // && typeof val == "object" | ||
function isElem(val) { | ||
return ENV_DOM && val instanceof HTMLElement; | ||
} | ||
function assignObj(targ) { | ||
@@ -107,9 +109,4 @@ var args = arguments; | ||
function sliceArgs(args, offs) { | ||
var arr = []; | ||
for (var i = offs; i < args.length; i++) | ||
{ arr.push(args[i]); } | ||
return arr; | ||
} | ||
function cmpObj(a, b) { | ||
@@ -420,6 +417,2 @@ for (var i in a) | ||
function isSet(val) { | ||
return val != null; | ||
} | ||
// (de)optimization flags | ||
@@ -935,3 +928,3 @@ | ||
// from_right: | ||
while(1) { | ||
while (1) { | ||
// if (rgtSib == lftEnd) | ||
@@ -1213,4 +1206,2 @@ // break converge; | ||
vm.api = {}; | ||
vm.view = view; | ||
@@ -1221,3 +1212,3 @@ vm.model = model; | ||
if (!view.prototype._isClass) { | ||
var out = view.call(vm, vm, model, key); // , opts | ||
var out = view.call(vm, vm, model, key, opts); | ||
@@ -1244,2 +1235,3 @@ if (isFunc(out)) | ||
} | ||
// remove this? | ||
@@ -1259,2 +1251,7 @@ if (opts) { | ||
var hooks = vm.hooks; | ||
if (hooks && hooks.didInit) | ||
{ hooks.didInit.call(vm, vm, model, key, opts); } | ||
// this.update(model, parent, idx, parentVm, false); | ||
@@ -1418,2 +1415,5 @@ | ||
if (vm.key !== false) | ||
{ vnew.key = vm.key; } | ||
// console.log(vm.key); | ||
@@ -1677,42 +1677,4 @@ | ||
// does not handle defineComment, defineText, defineSVG (ambiguous); use plain text vals or explicit factories in templates. | ||
// does not handle defineElementSpread (not available in all builds); use exlicit factories in templates. | ||
function h(a) { | ||
return ( | ||
isVal(a) ? defineElement : | ||
isFunc(a) ? defineView : // todo: es6 class constructor | ||
isElem(a) ? injectElement : | ||
a instanceof ViewModel ? injectView : | ||
noop | ||
).apply(null, arguments); | ||
} | ||
function defineElementSpread(tag) { | ||
var args = arguments; | ||
var len = args.length; | ||
var body, attrs; | ||
if (len > 1) { | ||
var bodyIdx = 1; | ||
if (isPlainObj(args[1])) { | ||
attrs = args[1]; | ||
bodyIdx = 2; | ||
} | ||
if (len == bodyIdx + 1 && (isVal(args[bodyIdx]) || isArr(args[bodyIdx]))) | ||
{ body = args[bodyIdx]; } | ||
else | ||
{ body = sliceArgs(args, bodyIdx); } | ||
} | ||
return initElementNode(tag, attrs, body); | ||
} | ||
// #destub: cssTag,autoPx | ||
nano$1.h = h; | ||
nano$1.defineElementSpread = defineElementSpread; | ||
return nano$1; | ||
@@ -1719,0 +1681,0 @@ |
/* | ||
https://github.com/leeoniya/domvm (v2.1.1, nano) | ||
https://github.com/leeoniya/domvm (v2.1.3, nano) | ||
*/ | ||
'use strict';(function(z,q){"object"===typeof exports&&"undefined"!==typeof module?module.exports=q():"function"===typeof define&&define.amd?define(q):z.domvm=q()})(this,function(){function z(){}function q(a){a=typeof a;return"string"===a||"number"===a}function v(a){return"function"===typeof a}function w(a){for(var b=arguments,c=1;c<b.length;c++)for(var d in b[c])a[d]=b[c][d];return a}function ja(a,b){for(var c in a)if(a[c]!==b[c])return!1;return!0}function O(a,b){var c=a.length;if(b.length!=c)return!1; | ||
for(var d=0;d<c;d++)if(a[d]!==b[d])return!1;return!0}function P(a){function b(){c=0;a.apply(d,e)}if(!Q)return a;var c,d,e;return function(){d=this;e=arguments;c||(c=Q(b))}}function ka(a,b,c){return function(){return a.apply(c,b)}}function E(a,b){switch(b){case "value":case "checked":case "selected":case "selectedIndex":return!0}return!1}function A(a){for(a=a||r;null==a.vm&&a.parent;)a=a.parent;return a.vm}function R(a,b){var c=(a.attrs||r).style;b=b?(b.attrs||r).style:null;if(null==c||q(c))a.el.style.cssText= | ||
c;else{for(var d in c){var e=c[d];if(null==b||null!=e&&e!==b[d]){var f=a.el.style,g=d,h;h=d;h=isNaN(e)||la[h]?e:e+"px";f[g]=h}}if(b)for(var k in b)null==c[k]&&(a.el.style[k]="")}}function S(a,b,c,d,e){if(a)e?(a=c.parent,a&&a.el&&a.el.offsetHeight):F.push([b,c,d]);else return b(c,d)}function l(a,b,c,d){var e=b.hooks[a];if(e){var f=0===a.lastIndexOf("did",0);return n(e)?e.map(function(a){return S(f,a,b,c)}):S(f,e,b,c,d)}}function t(){}function T(a,b,c,d){var e=new t;e.type=1;null!=d&&(e.flags=d);null!= | ||
b&&(null!=b._key&&(e.key=b._key),null!=b._ref&&(e.ref=b._ref),null!=b._hooks&&(e.hooks=b._hooks),null!=b._raw&&(e.raw=b._raw),null!=b._data&&(e.data=b._data),null!=b._flags&&(e.flags=b._flags),null==e.key&&(null!=e.ref?e.key=e.ref:null!=b.id?e.key=b.id:null!=b.name&&(e.key=b.name)),e.attrs=b);b=U[a];if(null==b){var f,g,h;for(U[a]=b={tag:(f=a.match(/^[-\w]+/))?f[0]:"div",id:(g=a.match(/#([-\w]+)/))?g[1]:null,class:(h=a.match(/\.([-\w.]+)/))?h[1].replace(/\./g," "):null,attrs:null};f=ma.exec(a);)null== | ||
b.attrs&&(b.attrs={}),b.attrs[f[1]]=f[2]||""}a=b;e.tag=a.tag;if(a.id||a.class||a.attrs){f=e.attrs||{};a.id&&null==f.id&&(f.id=a.id);a.class&&(e._class=a.class,f.class=a.class+(null!=f.class?" "+f.class:""));if(a.attrs)for(var k in a.attrs)null==f[k]&&(f[k]=a.attrs[k]);e.attrs=f}null!=c&&(e.body=c);return e}function V(a){var b=a.hooks,c=a.vm;c&&c.hooks&&l("willUnmount",c);b=b&&l("willRemove",a);if(a.flags&2&&n(a.body))for(c=0;c<a.body.length;c++)V(a.body[c]);return b}function G(a,b,c){var d=b._node, | ||
e=d.hooks,f=d.vm;if(d.flags&2&&n(d.body))for(var g=0;g<d.body.length;g++)G(b,d.body[g].el);a.removeChild(b);e&&l("didRemove",d,null,c);f&&f.hooks&&l("didUnmount",f,null,c)}function x(a,b){var c=V(b._node);null!=c&&"object"===typeof c&&v(c.then)?c.then(ka(G,[a,b,!0])):G(a,b)}function m(a,b,c){var d=b._node,e=d.hooks,f=null!=b.parentNode,g=(b==c||!f)&&d.vm;g&&g.hooks&&l("willMount",g);e&&l(f?"willReinsert":"willInsert",d);a.insertBefore(b,c);e&&l(f?"didReinsert":"didInsert",d);g&&g.hooks&&l("didMount", | ||
g)}function W(a,b,c){var d;for(d=a.target;null==d._node;)d=d.parentNode;d=d._node;var e=A(d);b=b.apply(null,c.concat(a,d,e));X.onevent.apply(null,[a,d,e].concat(c));!1===b&&(a.preventDefault(),a.stopPropagation())}function Y(a,b){return function(c){W(c,a,b)}}function na(a){return function(b){for(var c in a)if(b.target.matches(c)){var d=a[c],e=n(d),f=e?d[0]:d,d=e?d.slice(1):[];W(b,f,d)}}}function Z(a,b,c,d){c!==d&&(a=a.el,n(c)?null!=d&&O(c,d)||(c=Y(c[0],c.slice(1)),a[b]=c):(c=v(c)&&c!=d?Y(c,[]):na(c), | ||
a[b]=c))}function aa(a,b,c,d){var e=a.el;null==c?a.el.removeAttribute(b):null!=a.ns?e.setAttribute(b,c):"class"==b?e.className=c:"id"==b||"boolean"==typeof c||d?e[b]=c:"."==b[0]?e[b.substr(1)]=c:e.setAttribute(b,c)}function ba(a,b){var c=a.attrs||r,d=b.attrs||r,e;for(e in c){var f=c[e],g=E(a.tag,e),h=g?a.el[e]:d[e];f!==h&&("style"==e?R(a,b):"_"==e[0]||(0===e.lastIndexOf("on",0)?Z(a,e,f,h):aa(a,e,f,g)))}for(e in d)e in c||"_"==e[0]||(b=a,d=e,E(a.tag,e)||0===e.lastIndexOf("on",0)?b.el[d]="":b.el.removeAttribute(d))} | ||
function H(a,b,c,d){if(4==a.type)b=a.model,c=a.key,d=a.opts,a=a.view;else if(a.prototype._isClass)return new a(b,c,d);return new y(a,b,c,d)}function ca(a){for(var b=0;b<a.body.length;b++){var c=a.body[b],d=c.type;3>=d?m(a.el,p(c)):4==d?(c=H(c.view,c.model,c.key,c.opts)._redraw(a,b,!1),m(a.el,p(c.node))):5==d&&(c=c.vm,c._redraw(a,b),m(a.el,c.node.el))}}function p(a,b){if(null==a.el)if(1==a.type){if(!b){b=a.tag;var c=a.ns;b=null!=c?B.createElementNS(c,b):B.createElement(b)}a.el=b;if(null!=a.attrs){b= | ||
a.attrs;for(var d in b){var c=b[d],e=E(a.tag,d);"style"==d?R(a):"_"==d[0]||(0===d.lastIndexOf("on",0)?Z(a,d,c):null!=c&&aa(a,d,c,e))}}n(a.body)?ca(a):null!=a.body&&""!==a.body&&(a.raw?a.el.innerHTML=a.body:a.el.textContent=a.body)}else 2==a.type?a.el=b||B.createTextNode(a.body):3==a.type&&(a.el=b||B.createComment(a.body));a.el._node=a;return a.el}function da(a,b,c,d){c=c.previousSibling;d=d.nextSibling;a(c,d);return{lftSib:c?c.nextSibling:b.firstChild,rgtSib:d?d.previousSibling:b.lastChild}}function oa(a, | ||
b,c,d,e){var f=e.idx==c.idx+1,g=f?!1:b._node==e,h=f?!0:d._node==c;return g||h?da(function(c,e){h&&m(a,d,b);g&&m(a,b,e)},a,b,d):null}function pa(a,b,c,d){return da(function(c,f){for(var e=b;e!==f;e=e.nextSibling){b=c=e;for(var h=e.nextSibling;h!==f;h=h.nextSibling)0<d(c,h)&&(c=h);c!==e&&(m(a,c,b),e=c)}},a,b,c)}function qa(a,b){return a._node.idx-b._node.idx}function ea(a,b){var c=a.el,d=a.body,e=b.body;b=d[0];var f=d[d.length-1],g=(e[0]||r).el,e=(e[e.length-1]||r).el,h,k,l;a:for(;;){for(;;)if(g&&(k= | ||
g._node).parent!=a)h=g.nextSibling,null!=k.vm?k.vm.unmount(!0):x(c,g),g=h;else if(null==b)break a;else if(null==b.el)m(c,p(b),g),b=d[b.idx+1];else if(b.el===g)b=d[b.idx+1],g=g.nextSibling;else break;for(;;)if(e&&(l=e._node).parent!=a)h=e.previousSibling,null!=l.vm?l.vm.unmount(!0):x(c,e),e=h;else if(f==b)break a;else if(null==f.el)h=p(f),m(c,h,e?e.nextSibling:null),f=d[f.idx-1];else if(f.el===e)f=d[f.idx-1],e=e.previousSibling;else break;(h=oa(c,g,b,e,f))||(h=pa(c,g,e,qa));g=h.lftSib;e=h.rgtSib}} | ||
function ra(a,b,c,d){for(;c<b.length;c++){d=b[c];if(4==a.type&&null!=d.vm){var e=d.vm;if(e.view==a.view&&e.key==a.key)return d}if(d.el._node==d&&a.tag===d.tag&&a.type===d.type&&a.vm===d.vm&&(a.key===d.key||null==d.key))return d}return null}function sa(a,b){a:{a=a.key;var c=0,d=b.length-1,e;if(2147483647>=d)for(;c<=d;)if(e=c+d>>1,b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;else for(;c<=d;)if(e=Math.floor((c+d)/2),b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;a=-1}return-1<a?b[a]: | ||
null}function I(a,b,c){b.hooks&&l("willRecycle",b,a);c=a.el=b.el;var d=b.body,e=a.body;c._node=a;if(2==a.type&&e!==d)c.nodeValue=e;else{null==a.attrs&&null==b.attrs||ba(a,b);var f=n(d),g=n(e);if(f)if(g){a.flags&4?(c=b.body.slice(),c.sort(ta),d=sa):(c=b.body,d=ra);for(var h,e=0,f=a.body,g=0;g<f.length;g++){var k=f[g],m=k.type;3>=m?(h=d(k,c,e))&&I(k,h):4==m?(h=d(k,c,e))?h.vm._update(k.model,a,g):H(k.view,k.model,k.key,k.opts)._redraw(a,g,!1):5==m&&k.vm._update(k.model,a,g);a.list||null==h||h.idx!=e|| | ||
e++}1!=a.type||a.flags&1||ea(a,b)}else{if(e!==d)if(null!=e)a.raw?c.innerHTML=e:c.textContent=e;else for(;c.firstChild;)x(c,c.firstChild)}else g?(c.firstChild&&c.removeChild(c.firstChild),ca(a)):e!==d&&(a.raw?c.innerHTML=e:c.firstChild?c.firstChild.nodeValue=e:c.textContent=e);b.hooks&&l("didRecycle",b,a)}}function ta(a,b){return a.key>b.key?1:a.key<b.key?-1:0}function fa(a){var b=new t;b.type=2;b.body=a;return b}function u(a,b,c,d){if(5!=a.type&&4!=a.type){a.parent=b;a.idx=c;a.vm=d;if(null!=a.ref){c= | ||
A(a);b=["refs"].concat(a.ref.split("."));for(var e;e=b.shift();)c[e]=0==b.length?a:c=c[e]||{}}if(a.hooks&&a.hooks.willRemove||d&&d.hooks&&d.hooks.willUnmount)for(d=a;d=d.parent;)d.flags|=2;if(n(a.body))for(d=a.body,b=0;b<d.length;b++)c=d[b],!1===c||null==c?d.splice(b--,1):n(c)?(e=b--,d.splice.apply(d,[e,1].concat(c))):(null==c.type&&(d[b]=c=fa(""+c)),2==c.type?null==c.body||""==c.body?d.splice(b--,1):0<b&&2==d[b-1].type?(d[b-1].body+=c.body,d.splice(b--,1)):u(c,a,b,null):u(c,a,b,null))}}function y(a, | ||
b,c,d){var e=this;e.api={};e.view=a;e.model=b;e.key=null==c?b:c;a.prototype._isClass?(a=e.diff,null!=a&&a!=C.diff&&(e.diff=C.diff.bind(e),e.diff(a))):(a=a.call(e,e,b,c),v(a)?e.render=a:(a.diff&&(e.diff(a.diff),delete a.diff),w(e,a)));d&&(e.opts=d,d.hooks&&e.hook(d.hooks),d.diff&&e.diff(d.diff));e._redrawAsync=P(function(a){return e._redraw()});e._updateAsync=P(function(a){return e._update(a)})}function D(a){if(F.length)for(a=a.node,a&&a.el&&a.el.offsetHeight;a=F.shift();)a[0](a[1],a[2])}function J(a, | ||
b,c,d){var e,f;null==c?null!=b&&b.constructor==Object?e=b:f=b:(e=b,f=c);return T(a,e,f,d)}function K(a,b,c,d){this.view=a;this.model=b;this.key=null==c?b:c;this.opts=d}function ga(a,b,c,d){return new K(a,b,c,d)}function L(a){this.vm=a}function ha(a){return new L(a)}function ia(a){var b=new t;b.type=1;b.el=b.key=a;return b}var M="undefined"!=typeof window,Q=(M?window:{}).requestAnimationFrame,r={},n=Array.isArray,la={animationIterationCount:!0,boxFlex:!0,boxFlexGroup:!0,columnCount:!0,counterIncrement:!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,tabSize:!0,transform:!0,transformOrigin:!0,widows:!0,zIndex:!0,zoom:!0},U={},ma=/\[(\w+)(?:=(\w+))?\]/g,F=[],ua=t.prototype={constructor:t,type:null,vm:null,key:null,ref:null,data:null,hooks:null,raw:!1,ns:null,el:null,tag:null,attrs:null,body:null,flags:0,_class:null,idx:null,parent:null},B=M?document:null,X={onevent:z},C=y.prototype={constructor:y, | ||
_isClass:!1,view:null,key:null,model:null,opts:null,node:null,hooks:null,render:null,parent:function(){return A(this.node.parent)},root:function(){for(var a=this.node;a.parent;)a=a.parent;return a.vm},api:null,refs:null,mount:function(a,b){if(b){for(;a.firstChild;)a.removeChild(a.firstChild);this._redraw(null,null,!1);a.nodeName.toLowerCase()!=this.node.tag?(p(this.node),m(a.parentNode,this.node.el,a),a.parentNode.removeChild(a)):m(a.parentNode,p(this.node,a),a)}else this._redraw(null,null),a&&m(a, | ||
this.node.el);a&&D(this);return this},unmount:function(a){var b=this.node;x(b.el.parentNode,b.el);a||D(this)},redraw:function(a){a?this._redraw():this._redrawAsync();return this},update:function(a,b){b?this._update(a):this._updateAsync(a);return this},_update:function(a,b,c,d){null!=a&&this.model!==a&&(this.hooks&&l("willUpdate",this,a),this.model=a);return this._redraw(b,c,d)},_redraw:function(a,b,c){var d=null==a,e=this.node&&this.node.el&&this.node.el.parentNode,f=this.node;if(e&&null!=this._diff&& | ||
this._diff())return f&&a&&(a.body[b]=f,f.idx=b,f.parent=a),this;e&&this.hooks&&l("willRedraw",this);this.refs=null;var g=this.render.call(this,this,this.model,this.key);this.node=g;a?(u(g,a,b,this),a.body[b]=g):f&&f.parent?(u(g,f.parent,f.idx,this),f.parent.body[f.idx]=g):u(g,null,null,this);!1!==c&&(f?f.tag!==g.tag?(f.vm=g.vm=null,a=f.el.parentNode,b=f.el.nextSibling,x(a,f.el),m(a,p(g),b),f.el=g.el,g.vm=this):I(g,f,d):p(g));e&&this.hooks&&l("didRedraw",this);d&&e&&D(this);return this},_redrawAsync:null, | ||
_updateAsync:null,hook:function(a){this.hooks=this.hooks||w({},this.hooks,a)}};K.prototype={constructor:K,type:4,view:null,model:null,key:null,opts:null};L.prototype={constructor:L,type:5,vm:null};var N={config:function(a){w(X,a)},ViewModel:y,VNode:t,createView:H,defineElement:J,defineSvgElement:function(a,b,c,d){a=J(a,b,c,d);a.ns="http://www.w3.org/2000/svg";return a},defineText:fa,defineComment:function(a){var b=new t;b.type=3;b.body=a;return b},defineView:ga,injectView:ha, | ||
injectElement:ia,FIXED_BODY:1,DEEP_REMOVE:2,KEYED_LIST:4};C._diff=null;C.diff=function(a){var b=this;if(v(a))var c=a;else var c=a.vals,d=a.then;var e=c.call(b,b,b.model,b.key,b.opts),f=n(e)?O:ja;b._diff=function(){var a=c.call(b,b,b.model,b.key,b.opts),h=f(e,a);h||(null!=d&&!1===d.call(b,b,e,a)&&(h=!0),e=a);return h}};ua.patch=function(a){var b;a:{if(null!=a.type){if(null!=this.vm){b=void 0;break a}u(a,this.parent,this.idx,null);this.parent.body[this.idx]=a;I(a,this);D(A(a))}else{b=Object.create(this); | ||
b.attrs=w({},this.attrs);a=w(this.attrs,a);if(null!=this._class){var c=a.class;a.class=null!=c&&""!=c?this._class+" "+c:this._class}ba(this,b)}b=void 0}return b};N.h=function(a){return(q(a)?J:v(a)?ga:M&&a instanceof HTMLElement?ia:a instanceof y?ha:z).apply(null,arguments)};N.defineElementSpread=function(a){var b=arguments,c=b.length,d,e;if(1<c){d=1;var f=b[1];null!=f&&f.constructor==Object&&(e=b[1],d=2);if(c==d+1&&(q(b[d])||n(b[d])))d=b[d];else{for(c=[];d<b.length;d++)c.push(b[d]);d=c}}return T(a, | ||
e,d)};return N}); | ||
'use strict';(function(u,p){"object"===typeof exports&&"undefined"!==typeof module?module.exports=p():"function"===typeof define&&define.amd?define(p):u.domvm=p()})(this,function(){function u(a){return"function"===typeof a}function p(a){for(var b=arguments,c=1;c<b.length;c++)for(var d in b[c])a[d]=b[c][d];return a}function ca(a,b){for(var c in a)if(a[c]!==b[c])return!1;return!0}function K(a,b){var c=a.length;if(b.length!=c)return!1;for(var d=0;d<c;d++)if(a[d]!==b[d])return!1;return!0}function L(a){function b(){c= | ||
0;a.apply(d,e)}if(!M)return a;var c,d,e;return function(){d=this;e=arguments;c||(c=M(b))}}function da(a,b,c){return function(){return a.apply(c,b)}}function D(a,b){switch(b){case "value":case "checked":case "selected":case "selectedIndex":return!0}return!1}function x(a){for(a=a||r;null==a.vm&&a.parent;)a=a.parent;return a.vm}function N(a,b){var c=(a.attrs||r).style;b=b?(b.attrs||r).style:null;var d;(d=null==c)||(d=typeof c,d="string"===d||"number"===d);if(d)a.el.style.cssText=c;else{for(var e in c){var g= | ||
c[e];if(null==b||null!=g&&g!==b[e]){d=a.el.style;var f=e,h;h=e;h=isNaN(g)||ea[h]?g:g+"px";d[f]=h}}if(b)for(var k in b)null==c[k]&&(a.el.style[k]="")}}function O(a,b,c,d,e){if(a)e?(a=c.parent,a&&a.el&&a.el.offsetHeight):E.push([b,c,d]);else return b(c,d)}function l(a,b,c,d){var e=b.hooks[a];if(e){var g=0===a.lastIndexOf("did",0);return n(e)?e.map(function(a){return O(g,a,b,c)}):O(g,e,b,c,d)}}function t(){}function P(a){var b=a.hooks,c=a.vm;c&&c.hooks&&l("willUnmount",c);b=b&&l("willRemove",a);if(a.flags& | ||
2&&n(a.body))for(c=0;c<a.body.length;c++)P(a.body[c]);return b}function F(a,b,c){var d=b._node,e=d.hooks,g=d.vm;if(d.flags&2&&n(d.body))for(var f=0;f<d.body.length;f++)F(b,d.body[f].el);a.removeChild(b);e&&l("didRemove",d,null,c);g&&g.hooks&&l("didUnmount",g,null,c)}function w(a,b){var c=P(b._node);null!=c&&"object"===typeof c&&u(c.then)?c.then(da(F,[a,b,!0])):F(a,b)}function m(a,b,c){var d=b._node,e=d.hooks,g=null!=b.parentNode,f=(b==c||!g)&&d.vm;f&&f.hooks&&l("willMount",f);e&&l(g?"willReinsert": | ||
"willInsert",d);a.insertBefore(b,c);e&&l(g?"didReinsert":"didInsert",d);f&&f.hooks&&l("didMount",f)}function Q(a,b,c){var d;for(d=a.target;null==d._node;)d=d.parentNode;d=d._node;var e=x(d);b=b.apply(null,c.concat(a,d,e));R.onevent.apply(null,[a,d,e].concat(c));!1===b&&(a.preventDefault(),a.stopPropagation())}function S(a,b){return function(c){Q(c,a,b)}}function fa(a){return function(b){for(var c in a)if(b.target.matches(c)){var d=a[c],e=n(d),g=e?d[0]:d,d=e?d.slice(1):[];Q(b,g,d)}}}function T(a,b, | ||
c,d){c!==d&&(a=a.el,n(c)?null!=d&&K(c,d)||(c=S(c[0],c.slice(1)),a[b]=c):(c=u(c)&&c!=d?S(c,[]):fa(c),a[b]=c))}function U(a,b,c,d){var e=a.el;null==c?a.el.removeAttribute(b):null!=a.ns?e.setAttribute(b,c):"class"==b?e.className=c:"id"==b||"boolean"==typeof c||d?e[b]=c:"."==b[0]?e[b.substr(1)]=c:e.setAttribute(b,c)}function V(a,b){var c=a.attrs||r,d=b.attrs||r,e;for(e in c){var g=c[e],f=D(a.tag,e),h=f?a.el[e]:d[e];g!==h&&("style"==e?N(a,b):"_"==e[0]||(0===e.lastIndexOf("on",0)?T(a,e,g,h):U(a,e,g,f)))}for(e in d)e in | ||
c||"_"==e[0]||(b=a,d=e,D(a.tag,e)||0===e.lastIndexOf("on",0)?b.el[d]="":b.el.removeAttribute(d))}function G(a,b,c,d){if(4==a.type)b=a.model,c=a.key,d=a.opts,a=a.view;else if(a.prototype._isClass)return new a(b,c,d);return new y(a,b,c,d)}function W(a){for(var b=0;b<a.body.length;b++){var c=a.body[b],d=c.type;3>=d?m(a.el,q(c)):4==d?(c=G(c.view,c.model,c.key,c.opts)._redraw(a,b,!1),m(a.el,q(c.node))):5==d&&(c=c.vm,c._redraw(a,b),m(a.el,c.node.el))}}function q(a,b){if(null==a.el)if(1==a.type){if(!b){b= | ||
a.tag;var c=a.ns;b=null!=c?z.createElementNS(c,b):z.createElement(b)}a.el=b;if(null!=a.attrs){b=a.attrs;for(var d in b){var c=b[d],e=D(a.tag,d);"style"==d?N(a):"_"==d[0]||(0===d.lastIndexOf("on",0)?T(a,d,c):null!=c&&U(a,d,c,e))}}n(a.body)?W(a):null!=a.body&&""!==a.body&&(a.raw?a.el.innerHTML=a.body:a.el.textContent=a.body)}else 2==a.type?a.el=b||z.createTextNode(a.body):3==a.type&&(a.el=b||z.createComment(a.body));a.el._node=a;return a.el}function X(a,b,c,d){c=c.previousSibling;d=d.nextSibling;a(c, | ||
d);return{lftSib:c?c.nextSibling:b.firstChild,rgtSib:d?d.previousSibling:b.lastChild}}function ga(a,b,c,d,e){var g=e.idx==c.idx+1,f=g?!1:b._node==e,h=g?!0:d._node==c;return f||h?X(function(c,e){h&&m(a,d,b);f&&m(a,b,e)},a,b,d):null}function ha(a,b,c,d){return X(function(c,g){for(var e=b;e!==g;e=e.nextSibling){b=c=e;for(var h=e.nextSibling;h!==g;h=h.nextSibling)0<d(c,h)&&(c=h);c!==e&&(m(a,c,b),e=c)}},a,b,c)}function ia(a,b){return a._node.idx-b._node.idx}function Y(a,b){var c=a.el,d=a.body,e=b.body; | ||
b=d[0];var g=d[d.length-1],f=(e[0]||r).el,e=(e[e.length-1]||r).el,h,k,l;a:for(;;){for(;;)if(f&&(k=f._node).parent!=a)h=f.nextSibling,null!=k.vm?k.vm.unmount(!0):w(c,f),f=h;else if(null==b)break a;else if(null==b.el)m(c,q(b),f),b=d[b.idx+1];else if(b.el===f)b=d[b.idx+1],f=f.nextSibling;else break;for(;;)if(e&&(l=e._node).parent!=a)h=e.previousSibling,null!=l.vm?l.vm.unmount(!0):w(c,e),e=h;else if(g==b)break a;else if(null==g.el)h=q(g),m(c,h,e?e.nextSibling:null),g=d[g.idx-1];else if(g.el===e)g=d[g.idx- | ||
1],e=e.previousSibling;else break;(h=ga(c,f,b,e,g))||(h=ha(c,f,e,ia));f=h.lftSib;e=h.rgtSib}}function ja(a,b,c,d){for(;c<b.length;c++){d=b[c];if(4==a.type&&null!=d.vm){var e=d.vm;if(e.view==a.view&&e.key==a.key)return d}if(d.el._node==d&&a.tag===d.tag&&a.type===d.type&&a.vm===d.vm&&(a.key===d.key||null==d.key))return d}return null}function ka(a,b){a:{a=a.key;var c=0,d=b.length-1,e;if(2147483647>=d)for(;c<=d;)if(e=c+d>>1,b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;else for(;c<=d;)if(e=Math.floor((c+ | ||
d)/2),b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;a=-1}return-1<a?b[a]:null}function H(a,b,c){b.hooks&&l("willRecycle",b,a);c=a.el=b.el;var d=b.body,e=a.body;c._node=a;if(2==a.type&&e!==d)c.nodeValue=e;else{null==a.attrs&&null==b.attrs||V(a,b);var g=n(d),f=n(e);if(g)if(f){a.flags&4?(c=b.body.slice(),c.sort(la),d=ka):(c=b.body,d=ja);for(var h,e=0,g=a.body,f=0;f<g.length;f++){var k=g[f],m=k.type;3>=m?(h=d(k,c,e))&&H(k,h):4==m?(h=d(k,c,e))?h.vm._update(k.model,a,f):G(k.view,k.model,k.key,k.opts)._redraw(a, | ||
f,!1):5==m&&k.vm._update(k.model,a,f);a.list||null==h||h.idx!=e||e++}1!=a.type||a.flags&1||Y(a,b)}else{if(e!==d)if(null!=e)a.raw?c.innerHTML=e:c.textContent=e;else for(;c.firstChild;)w(c,c.firstChild)}else f?(c.firstChild&&c.removeChild(c.firstChild),W(a)):e!==d&&(a.raw?c.innerHTML=e:c.firstChild?c.firstChild.nodeValue=e:c.textContent=e);b.hooks&&l("didRecycle",b,a)}}function la(a,b){return a.key>b.key?1:a.key<b.key?-1:0}function Z(a){var b=new t;b.type=2;b.body=a;return b}function v(a,b,c,d){if(5!= | ||
a.type&&4!=a.type){a.parent=b;a.idx=c;a.vm=d;if(null!=a.ref){c=x(a);b=["refs"].concat(a.ref.split("."));for(var e;e=b.shift();)c[e]=0==b.length?a:c=c[e]||{}}if(a.hooks&&a.hooks.willRemove||d&&d.hooks&&d.hooks.willUnmount)for(d=a;d=d.parent;)d.flags|=2;if(n(a.body))for(d=a.body,b=0;b<d.length;b++)c=d[b],!1===c||null==c?d.splice(b--,1):n(c)?(e=b--,d.splice.apply(d,[e,1].concat(c))):(null==c.type&&(d[b]=c=Z(""+c)),2==c.type?null==c.body||""==c.body?d.splice(b--,1):0<b&&2==d[b-1].type?(d[b-1].body+=c.body, | ||
d.splice(b--,1)):v(c,a,b,null):v(c,a,b,null))}}function y(a,b,c,d){var e=this;e.view=a;e.model=b;e.key=null==c?b:c;a.prototype._isClass?(a=e.diff,null!=a&&a!=A.diff&&(e.diff=A.diff.bind(e),e.diff(a))):(a=a.call(e,e,b,c,d),u(a)?e.render=a:(a.diff&&(e.diff(a.diff),delete a.diff),p(e,a)));d&&(e.opts=d,d.hooks&&e.hook(d.hooks),d.diff&&e.diff(d.diff));e._redrawAsync=L(function(a){return e._redraw()});e._updateAsync=L(function(a){return e._update(a)});(a=e.hooks)&&a.didInit&&a.didInit.call(e,e,b,c,d)}function B(a){if(E.length)for(a= | ||
a.node,a&&a.el&&a.el.offsetHeight;a=E.shift();)a[0](a[1],a[2])}function aa(a,b,c,d){var e,g;null==c?null!=b&&b.constructor==Object?e=b:g=b:(e=b,g=c);c=e;b=new t;b.type=1;null!=d&&(b.flags=d);null!=c&&(null!=c._key&&(b.key=c._key),null!=c._ref&&(b.ref=c._ref),null!=c._hooks&&(b.hooks=c._hooks),null!=c._raw&&(b.raw=c._raw),null!=c._data&&(b.data=c._data),null!=c._flags&&(b.flags=c._flags),null==b.key&&(null!=b.ref?b.key=b.ref:null!=c.id?b.key=c.id:null!=c.name&&(b.key=c.name)),b.attrs=c);d=ba[a];if(null== | ||
d){var f,h,k;for(ba[a]=d={tag:(f=a.match(/^[-\w]+/))?f[0]:"div",id:(h=a.match(/#([-\w]+)/))?h[1]:null,class:(k=a.match(/\.([-\w.]+)/))?k[1].replace(/\./g," "):null,attrs:null};f=ma.exec(a);)null==d.attrs&&(d.attrs={}),d.attrs[f[1]]=f[2]||""}a=d;b.tag=a.tag;if(a.id||a.class||a.attrs){f=b.attrs||{};a.id&&null==f.id&&(f.id=a.id);a.class&&(b._class=a.class,f.class=a.class+(null!=f.class?" "+f.class:""));if(a.attrs)for(var l in a.attrs)null!=f[l]||(f[l]=a.attrs[l]);b.attrs=f}null!=g&&(b.body=g);return b} | ||
function I(a,b,c,d){this.view=a;this.model=b;this.key=null==c?b:c;this.opts=d}function J(a){this.vm=a}var C="undefined"!=typeof window,M=(C?window:{}).requestAnimationFrame,r={},n=Array.isArray,ea={animationIterationCount:!0,boxFlex:!0,boxFlexGroup:!0,columnCount:!0,counterIncrement:!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,tabSize:!0,transform:!0,transformOrigin:!0,widows:!0,zIndex:!0, | ||
zoom:!0},ba={},ma=/\[(\w+)(?:=(\w+))?\]/g,E=[],na=t.prototype={constructor:t,type:null,vm:null,key:null,ref:null,data:null,hooks:null,raw:!1,ns:null,el:null,tag:null,attrs:null,body:null,flags:0,_class:null,idx:null,parent:null},z=C?document:null,R={onevent:function(){}},A=y.prototype={constructor:y,_isClass:!1,view:null,key:null,model:null,opts:null,node:null,hooks:null,render:null,parent:function(){return x(this.node.parent)},root:function(){for(var a=this.node;a.parent;)a=a.parent;return a.vm}, | ||
api:null,refs:null,mount:function(a,b){if(b){for(;a.firstChild;)a.removeChild(a.firstChild);this._redraw(null,null,!1);a.nodeName.toLowerCase()!=this.node.tag?(q(this.node),m(a.parentNode,this.node.el,a),a.parentNode.removeChild(a)):m(a.parentNode,q(this.node,a),a)}else this._redraw(null,null),a&&m(a,this.node.el);a&&B(this);return this},unmount:function(a){var b=this.node;w(b.el.parentNode,b.el);a||B(this)},redraw:function(a){a?this._redraw():this._redrawAsync();return this},update:function(a,b){b? | ||
this._update(a):this._updateAsync(a);return this},_update:function(a,b,c,d){null!=a&&this.model!==a&&(this.hooks&&l("willUpdate",this,a),this.model=a);return this._redraw(b,c,d)},_redraw:function(a,b,c){var d=null==a,e=this.node&&this.node.el&&this.node.el.parentNode,g=this.node;if(e&&null!=this._diff&&this._diff())return g&&a&&(a.body[b]=g,g.idx=b,g.parent=a),this;e&&this.hooks&&l("willRedraw",this);this.refs=null;var f=this.render.call(this,this,this.model,this.key);!1!==this.key&&(f.key=this.key); | ||
this.node=f;a?(v(f,a,b,this),a.body[b]=f):g&&g.parent?(v(f,g.parent,g.idx,this),g.parent.body[g.idx]=f):v(f,null,null,this);!1!==c&&(g?g.tag!==f.tag?(g.vm=f.vm=null,a=g.el.parentNode,b=g.el.nextSibling,w(a,g.el),m(a,q(f),b),g.el=f.el,f.vm=this):H(f,g,d):q(f));e&&this.hooks&&l("didRedraw",this);d&&e&&B(this);return this},_redrawAsync:null,_updateAsync:null,hook:function(a){this.hooks=this.hooks||p({},this.hooks,a)}};I.prototype={constructor:I,type:4,view:null,model:null,key:null,opts:null};J.prototype= | ||
{constructor:J,type:5,vm:null};C={config:function(a){p(R,a)},ViewModel:y,VNode:t,createView:G,defineElement:aa,defineSvgElement:function(a,b,c,d){a=aa(a,b,c,d);a.ns="http://www.w3.org/2000/svg";return a},defineText:Z,defineComment:function(a){var b=new t;b.type=3;b.body=a;return b},defineView:function(a,b,c,d){return new I(a,b,c,d)},injectView:function(a){return new J(a)},injectElement:function(a){var b=new t;b.type=1;b.el=b.key=a;return b},FIXED_BODY:1,DEEP_REMOVE:2,KEYED_LIST:4}; | ||
A._diff=null;A.diff=function(a){var b=this;if(u(a))var c=a;else var c=a.vals,d=a.then;var e=c.call(b,b,b.model,b.key,b.opts),g=n(e)?K:ca;b._diff=function(){var a=c.call(b,b,b.model,b.key,b.opts),h=g(e,a);h||(null!=d&&!1===d.call(b,b,e,a)&&(h=!0),e=a);return h}};na.patch=function(a){var b;a:{if(null!=a.type){if(null!=this.vm){b=void 0;break a}v(a,this.parent,this.idx,null);this.parent.body[this.idx]=a;H(a,this);B(x(a))}else{b=Object.create(this);b.attrs=p({},this.attrs);a=p(this.attrs,a);if(null!= | ||
this._class){var c=a.class;a.class=null!=c&&""!=c?this._class+" "+c:this._class}V(this,b)}b=void 0}return b};return C}); |
@@ -7,3 +7,3 @@ /** | ||
* A thin, fast, dependency-free vdom view layer | ||
* @preserve https://github.com/leeoniya/domvm (v2.1.1, pico) | ||
* @preserve https://github.com/leeoniya/domvm (v2.1.3, pico) | ||
*/ | ||
@@ -44,2 +44,6 @@ | ||
function isSet(val) { | ||
return val != null; | ||
} | ||
function isPlainObj(val) { | ||
@@ -345,6 +349,2 @@ return val != null && val.constructor == Object; // && typeof val == "object" | ||
function isSet(val) { | ||
return val != null; | ||
} | ||
// (de)optimization flags | ||
@@ -860,3 +860,3 @@ | ||
// from_right: | ||
while(1) { | ||
while (1) { | ||
// if (rgtSib == lftEnd) | ||
@@ -1138,4 +1138,2 @@ // break converge; | ||
vm.api = {}; | ||
vm.view = view; | ||
@@ -1146,3 +1144,3 @@ vm.model = model; | ||
if (!view.prototype._isClass) { | ||
var out = view.call(vm, vm, model, key); // , opts | ||
var out = view.call(vm, vm, model, key, opts); | ||
@@ -1169,2 +1167,3 @@ if (isFunc(out)) | ||
} | ||
// remove this? | ||
@@ -1184,2 +1183,7 @@ if (opts) { | ||
var hooks = vm.hooks; | ||
if (hooks && hooks.didInit) | ||
{ hooks.didInit.call(vm, vm, model, key, opts); } | ||
// this.update(model, parent, idx, parentVm, false); | ||
@@ -1343,2 +1347,5 @@ | ||
if (vm.key !== false) | ||
{ vnew.key = vm.key; } | ||
// console.log(vm.key); | ||
@@ -1345,0 +1352,0 @@ |
/* | ||
https://github.com/leeoniya/domvm (v2.1.1, pico) | ||
https://github.com/leeoniya/domvm (v2.1.3, pico) | ||
*/ | ||
@@ -17,10 +17,10 @@ 'use strict';(function(u,m){"object"===typeof exports&&"undefined"!==typeof module?module.exports=m():"function"===typeof define&&define.amd?define(m):u.domvm=m()})(this,function(){function u(a){return"function"===typeof a}function m(a){for(var b=arguments,c=1;c<b.length;c++)for(var d in b[c])a[d]=b[c][d];return a}function H(a){function b(){c=0;a.apply(d,e)}if(!I)return a;var c,d,e;return function(){d=this;e=arguments;c||(c=I(b))}}function aa(a,b,c){return function(){return a.apply(c,b)}}function z(a, | ||
e)a.raw?c.innerHTML=e:c.textContent=e;else for(;c.firstChild;)v(c,c.firstChild)}else f?(c.firstChild&&c.removeChild(c.firstChild),R(a)):e!==d&&(a.raw?c.innerHTML=e:c.firstChild?c.firstChild.nodeValue=e:c.textContent=e);b.hooks&&k("didRecycle",b,a)}}function ha(a,b){return a.key>b.key?1:a.key<b.key?-1:0}function V(a){var b=new t;b.type=2;b.body=a;return b}function w(a,b,c,d){if(5!=a.type&&4!=a.type){a.parent=b;a.idx=c;a.vm=d;if(null!=a.ref){c=A(a);b=["refs"].concat(a.ref.split("."));for(var e;e=b.shift();)c[e]= | ||
0==b.length?a:c=c[e]||{}}if(a.hooks&&a.hooks.willRemove||d&&d.hooks&&d.hooks.willUnmount)for(d=a;d=d.parent;)d.flags|=2;if(q(a.body))for(d=a.body,b=0;b<d.length;b++)c=d[b],!1===c||null==c?d.splice(b--,1):q(c)?(e=b--,d.splice.apply(d,[e,1].concat(c))):(null==c.type&&(d[b]=c=V(""+c)),2==c.type?null==c.body||""==c.body?d.splice(b--,1):0<b&&2==d[b-1].type?(d[b-1].body+=c.body,d.splice(b--,1)):w(c,a,b,null):w(c,a,b,null))}}function x(a,b,c,d){var e=this;e.api={};e.view=a;e.model=b;e.key=null==c?b:c;a.prototype._isClass? | ||
(a=e.diff,null!=a&&a!=W.diff&&(e.diff=W.diff.bind(e),e.diff(a))):(a=a.call(e,e,b,c),u(a)?e.render=a:(a.diff&&(e.diff(a.diff),delete a.diff),m(e,a)));d&&(e.opts=d,d.hooks&&e.hook(d.hooks),d.diff&&e.diff(d.diff));e._redrawAsync=H(function(a){return e._redraw()});e._updateAsync=H(function(a){return e._update(a)})}function E(a){if(B.length)for(a=a.node,a&&a.el&&a.el.offsetHeight;a=B.shift();)a[0](a[1],a[2])}function X(a,b,c,d){var e,f;null==c?null!=b&&b.constructor==Object?e=b:f=b:(e=b,f=c);c=e;b=new t; | ||
b.type=1;null!=d&&(b.flags=d);null!=c&&(null!=c._key&&(b.key=c._key),null!=c._ref&&(b.ref=c._ref),null!=c._hooks&&(b.hooks=c._hooks),null!=c._raw&&(b.raw=c._raw),null!=c._data&&(b.data=c._data),null!=c._flags&&(b.flags=c._flags),null==b.key&&(null!=b.ref?b.key=b.ref:null!=c.id?b.key=c.id:null!=c.name&&(b.key=c.name)),b.attrs=c);Y.tag=a;a=Y;b.tag=a.tag;if(a.id||a.class||a.attrs){d=b.attrs||{};a.id&&null==d.id&&(d.id=a.id);a.class&&(b._class=a.class,d.class=a.class+(null!=d.class?" "+d.class:""));if(a.attrs)for(var g in a.attrs)null!= | ||
d[g]||(d[g]=a.attrs[g]);b.attrs=d}null!=f&&(b.body=f);return b}function F(a,b,c,d){this.view=a;this.model=b;this.key=null==c?b:c;this.opts=d}function G(a){this.vm=a}var Z="undefined"!=typeof window,I=(Z?window:{}).requestAnimationFrame,r={},q=Array.isArray,Y={},B=[];t.prototype={constructor:t,type:null,vm:null,key:null,ref:null,data:null,hooks:null,raw:!1,ns:null,el:null,tag:null,attrs:null,body:null,flags:0,_class:null,idx:null,parent:null};var y=Z?document:null,N={onevent:function(){}},W=x.prototype= | ||
{constructor:x,_isClass:!1,view:null,key:null,model:null,opts:null,node:null,hooks:null,render:null,parent:function(){return A(this.node.parent)},root:function(){for(var a=this.node;a.parent;)a=a.parent;return a.vm},api:null,refs:null,mount:function(a,b){if(b){for(;a.firstChild;)a.removeChild(a.firstChild);this._redraw(null,null,!1);a.nodeName.toLowerCase()!=this.node.tag?(p(this.node),l(a.parentNode,this.node.el,a),a.parentNode.removeChild(a)):l(a.parentNode,p(this.node,a),a)}else this._redraw(null, | ||
null),a&&l(a,this.node.el);a&&E(this);return this},unmount:function(a){var b=this.node;v(b.el.parentNode,b.el);a||E(this)},redraw:function(a){a?this._redraw():this._redrawAsync();return this},update:function(a,b){b?this._update(a):this._updateAsync(a);return this},_update:function(a,b,c,d){null!=a&&this.model!==a&&(this.hooks&&k("willUpdate",this,a),this.model=a);return this._redraw(b,c,d)},_redraw:function(a,b,c){var d=null==a,e=this.node&&this.node.el&&this.node.el.parentNode,f=this.node;if(e&& | ||
null!=this._diff&&this._diff())return f&&a&&(a.body[b]=f,f.idx=b,f.parent=a),this;e&&this.hooks&&k("willRedraw",this);this.refs=null;var g=this.render.call(this,this,this.model,this.key);this.node=g;a?(w(g,a,b,this),a.body[b]=g):f&&f.parent?(w(g,f.parent,f.idx,this),f.parent.body[f.idx]=g):w(g,null,null,this);!1!==c&&(f?f.tag!==g.tag?(f.vm=g.vm=null,a=f.el.parentNode,b=f.el.nextSibling,v(a,f.el),l(a,p(g),b),f.el=g.el,g.vm=this):U(g,f,d):p(g));e&&this.hooks&&k("didRedraw",this);d&&e&&E(this);return this}, | ||
_redrawAsync:null,_updateAsync:null,hook:function(a){this.hooks=this.hooks||m({},this.hooks,a)}};F.prototype={constructor:F,type:4,view:null,model:null,key:null,opts:null};G.prototype={constructor:G,type:5,vm:null};return{config:function(a){m(N,a)},ViewModel:x,VNode:t,createView:D,defineElement:X,defineSvgElement:function(a,b,c,d){a=X(a,b,c,d);a.ns="http://www.w3.org/2000/svg";return a},defineText:V,defineComment:function(a){var b=new t;b.type=3;b.body=a;return b},defineView:function(a, | ||
b,c,d){return new F(a,b,c,d)},injectView:function(a){return new G(a)},injectElement:function(a){var b=new t;b.type=1;b.el=b.key=a;return b},FIXED_BODY:1,DEEP_REMOVE:2,KEYED_LIST:4}}); | ||
0==b.length?a:c=c[e]||{}}if(a.hooks&&a.hooks.willRemove||d&&d.hooks&&d.hooks.willUnmount)for(d=a;d=d.parent;)d.flags|=2;if(q(a.body))for(d=a.body,b=0;b<d.length;b++)c=d[b],!1===c||null==c?d.splice(b--,1):q(c)?(e=b--,d.splice.apply(d,[e,1].concat(c))):(null==c.type&&(d[b]=c=V(""+c)),2==c.type?null==c.body||""==c.body?d.splice(b--,1):0<b&&2==d[b-1].type?(d[b-1].body+=c.body,d.splice(b--,1)):w(c,a,b,null):w(c,a,b,null))}}function x(a,b,c,d){var e=this;e.view=a;e.model=b;e.key=null==c?b:c;a.prototype._isClass? | ||
(a=e.diff,null!=a&&a!=W.diff&&(e.diff=W.diff.bind(e),e.diff(a))):(a=a.call(e,e,b,c,d),u(a)?e.render=a:(a.diff&&(e.diff(a.diff),delete a.diff),m(e,a)));d&&(e.opts=d,d.hooks&&e.hook(d.hooks),d.diff&&e.diff(d.diff));e._redrawAsync=H(function(a){return e._redraw()});e._updateAsync=H(function(a){return e._update(a)});(a=e.hooks)&&a.didInit&&a.didInit.call(e,e,b,c,d)}function E(a){if(B.length)for(a=a.node,a&&a.el&&a.el.offsetHeight;a=B.shift();)a[0](a[1],a[2])}function X(a,b,c,d){var e,f;null==c?null!= | ||
b&&b.constructor==Object?e=b:f=b:(e=b,f=c);c=e;b=new t;b.type=1;null!=d&&(b.flags=d);null!=c&&(null!=c._key&&(b.key=c._key),null!=c._ref&&(b.ref=c._ref),null!=c._hooks&&(b.hooks=c._hooks),null!=c._raw&&(b.raw=c._raw),null!=c._data&&(b.data=c._data),null!=c._flags&&(b.flags=c._flags),null==b.key&&(null!=b.ref?b.key=b.ref:null!=c.id?b.key=c.id:null!=c.name&&(b.key=c.name)),b.attrs=c);Y.tag=a;a=Y;b.tag=a.tag;if(a.id||a.class||a.attrs){d=b.attrs||{};a.id&&null==d.id&&(d.id=a.id);a.class&&(b._class=a.class, | ||
d.class=a.class+(null!=d.class?" "+d.class:""));if(a.attrs)for(var g in a.attrs)null!=d[g]||(d[g]=a.attrs[g]);b.attrs=d}null!=f&&(b.body=f);return b}function F(a,b,c,d){this.view=a;this.model=b;this.key=null==c?b:c;this.opts=d}function G(a){this.vm=a}var Z="undefined"!=typeof window,I=(Z?window:{}).requestAnimationFrame,r={},q=Array.isArray,Y={},B=[];t.prototype={constructor:t,type:null,vm:null,key:null,ref:null,data:null,hooks:null,raw:!1,ns:null,el:null,tag:null,attrs:null,body:null,flags:0,_class:null, | ||
idx:null,parent:null};var y=Z?document:null,N={onevent:function(){}},W=x.prototype={constructor:x,_isClass:!1,view:null,key:null,model:null,opts:null,node:null,hooks:null,render:null,parent:function(){return A(this.node.parent)},root:function(){for(var a=this.node;a.parent;)a=a.parent;return a.vm},api:null,refs:null,mount:function(a,b){if(b){for(;a.firstChild;)a.removeChild(a.firstChild);this._redraw(null,null,!1);a.nodeName.toLowerCase()!=this.node.tag?(p(this.node),l(a.parentNode,this.node.el,a), | ||
a.parentNode.removeChild(a)):l(a.parentNode,p(this.node,a),a)}else this._redraw(null,null),a&&l(a,this.node.el);a&&E(this);return this},unmount:function(a){var b=this.node;v(b.el.parentNode,b.el);a||E(this)},redraw:function(a){a?this._redraw():this._redrawAsync();return this},update:function(a,b){b?this._update(a):this._updateAsync(a);return this},_update:function(a,b,c,d){null!=a&&this.model!==a&&(this.hooks&&k("willUpdate",this,a),this.model=a);return this._redraw(b,c,d)},_redraw:function(a,b,c){var d= | ||
null==a,e=this.node&&this.node.el&&this.node.el.parentNode,f=this.node;if(e&&null!=this._diff&&this._diff())return f&&a&&(a.body[b]=f,f.idx=b,f.parent=a),this;e&&this.hooks&&k("willRedraw",this);this.refs=null;var g=this.render.call(this,this,this.model,this.key);!1!==this.key&&(g.key=this.key);this.node=g;a?(w(g,a,b,this),a.body[b]=g):f&&f.parent?(w(g,f.parent,f.idx,this),f.parent.body[f.idx]=g):w(g,null,null,this);!1!==c&&(f?f.tag!==g.tag?(f.vm=g.vm=null,a=f.el.parentNode,b=f.el.nextSibling,v(a, | ||
f.el),l(a,p(g),b),f.el=g.el,g.vm=this):U(g,f,d):p(g));e&&this.hooks&&k("didRedraw",this);d&&e&&E(this);return this},_redrawAsync:null,_updateAsync:null,hook:function(a){this.hooks=this.hooks||m({},this.hooks,a)}};F.prototype={constructor:F,type:4,view:null,model:null,key:null,opts:null};G.prototype={constructor:G,type:5,vm:null};return{config:function(a){m(N,a)},ViewModel:x,VNode:t,createView:D,defineElement:X,defineSvgElement:function(a,b,c,d){a=X(a,b,c,d);a.ns="http://www.w3.org/2000/svg"; | ||
return a},defineText:V,defineComment:function(a){var b=new t;b.type=3;b.body=a;return b},defineView:function(a,b,c,d){return new F(a,b,c,d)},injectView:function(a){return new G(a)},injectElement:function(a){var b=new t;b.type=1;b.el=b.key=a;return b},FIXED_BODY:1,DEEP_REMOVE:2,KEYED_LIST:4}}); |
| build | min / gz | contents | descr | | ||
| ----------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| [pico][1] | 10.7k / 4.3k | dom recycling<br>lifecycle hooks<br>event delegation<br>parameterized handlers<br>sub-views<br>element injection<br>raw html<br>vnode refs<br>css objects<br>svg<br>global onevent | view core<br><br>**This build is unstable by design; features that get decoupled<br>can move to nano+ builds at any commit!** | | ||
| [nano][2] | 12.4k / 5.0k | + `h`<br>+ `selectorTag`<br>+ `autoPx`<br>+ `defineElementSpread`<br>+ `diff`<br>+ `patch`<br> | tpl conveniences:<br>`"input[type=checkbox].some-class"`<br>`{style: {width: 20}}`<br>`el("div", el("span", "foo")...)`<br><br>optims:<br>`vnode.patch({class: ..., style...})`<br>`vm.diff({vals:...then:...})` | | ||
| [micro][3] | 12.9k / 5.2k | + `emit`<br> + `body`<br> | subview-to-parent events:<br>`vm.emit('myNotif', arg1, arg2...)`<br><br>get child views:<br>`vm.body()` | | ||
| [mini][4] | 13.5k / 5.4k | + `streamCfg`<br> + `streamFlyd`<br> + `prop`<br> | view reactivity (reduce need for explicit `redraw()`) | | ||
| [client][5] | 13.9k / 5.5k | `mini`<br> + `attach`<br> | SSR hydration | | ||
| [server][6] | 14.9k / 6.0k | `mini`<br> + `html`<br> | SSR rendering | | ||
| [full][7] | 15.3k / 6.1k | `mini`<br> + `attach`<br> + `html`<br> | everything (for tests/debug) | | ||
| [pico][1] | 10.8k / 4.3k | dom recycling<br>lifecycle hooks<br>event delegation<br>parameterized handlers<br>sub-views<br>element injection<br>raw html<br>vnode refs<br>css objects<br>svg<br>global onevent | view core<br><br>**This build is unstable by design; features that get decoupled<br>can move to nano+ builds at any commit!** | | ||
| [nano][2] | 12.1k / 4.9k | + `selectorTag`<br> + `autoPx`<br> + `diff`<br> + `patch`<br> | tpl conveniences:<br>`"input[type=checkbox].some-class"`<br>`{style: {width: 20}}`<br>`el("div", el("span", "foo")...)`<br><br>optims:<br>`vnode.patch({class: ..., style...})`<br>`vm.diff({vals:...then:...})` | | ||
| [micro][3] | 12.6k / 5.0k | + `emit`<br> + `body`<br> | subview-to-parent events:<br>`vm.emit('myNotif', arg1, arg2...)`<br><br>get child views:<br>`vm.body()` | | ||
| [mini][4] | 13.2k / 5.3k | + `streamCfg`<br> + `streamFlyd`<br> + `prop`<br> | view reactivity (reduce need for explicit `redraw()`) | | ||
| [client][5] | 13.6k / 5.4k | `mini`<br> + `attach`<br> | SSR hydration | | ||
| [server][6] | 14.6k / 5.8k | `mini`<br> + `html`<br> | SSR rendering | | ||
| [full][7] | 15.1k / 6.0k | `mini`<br> + `attach`<br> + `html`<br> | everything (for tests/debug) | | ||
@@ -11,0 +11,0 @@ [1]: https://github.com/leeoniya/domvm/blob/2.x-stable/dist/pico/domvm.pico.min.js |
@@ -7,3 +7,3 @@ /** | ||
* A thin, fast, dependency-free vdom view layer | ||
* @preserve https://github.com/leeoniya/domvm (v2.1.1, server) | ||
* @preserve https://github.com/leeoniya/domvm (v2.1.3, server) | ||
*/ | ||
@@ -44,2 +44,6 @@ | ||
function isSet(val) { | ||
return val != null; | ||
} | ||
function isPlainObj(val) { | ||
@@ -66,6 +70,4 @@ return val != null && val.constructor == Object; // && typeof val == "object" | ||
function isElem(val) { | ||
return ENV_DOM && val instanceof HTMLElement; | ||
} | ||
function assignObj(targ) { | ||
@@ -447,6 +449,2 @@ var args = arguments; | ||
function isSet(val) { | ||
return val != null; | ||
} | ||
// (de)optimization flags | ||
@@ -962,3 +960,3 @@ | ||
// from_right: | ||
while(1) { | ||
while (1) { | ||
// if (rgtSib == lftEnd) | ||
@@ -1240,4 +1238,2 @@ // break converge; | ||
vm.api = {}; | ||
vm.view = view; | ||
@@ -1248,3 +1244,3 @@ vm.model = model; | ||
if (!view.prototype._isClass) { | ||
var out = view.call(vm, vm, model, key); // , opts | ||
var out = view.call(vm, vm, model, key, opts); | ||
@@ -1271,2 +1267,3 @@ if (isFunc(out)) | ||
} | ||
// remove this? | ||
@@ -1286,2 +1283,7 @@ if (opts) { | ||
var hooks = vm.hooks; | ||
if (hooks && hooks.didInit) | ||
{ hooks.didInit.call(vm, vm, model, key, opts); } | ||
// this.update(model, parent, idx, parentVm, false); | ||
@@ -1445,2 +1447,5 @@ | ||
if (vm.key !== false) | ||
{ vnew.key = vm.key; } | ||
// console.log(vm.key); | ||
@@ -1704,42 +1709,4 @@ | ||
// does not handle defineComment, defineText, defineSVG (ambiguous); use plain text vals or explicit factories in templates. | ||
// does not handle defineElementSpread (not available in all builds); use exlicit factories in templates. | ||
function h(a) { | ||
return ( | ||
isVal(a) ? defineElement : | ||
isFunc(a) ? defineView : // todo: es6 class constructor | ||
isElem(a) ? injectElement : | ||
a instanceof ViewModel ? injectView : | ||
noop | ||
).apply(null, arguments); | ||
} | ||
function defineElementSpread(tag) { | ||
var args = arguments; | ||
var len = args.length; | ||
var body, attrs; | ||
if (len > 1) { | ||
var bodyIdx = 1; | ||
if (isPlainObj(args[1])) { | ||
attrs = args[1]; | ||
bodyIdx = 2; | ||
} | ||
if (len == bodyIdx + 1 && (isVal(args[bodyIdx]) || isArr(args[bodyIdx]))) | ||
{ body = args[bodyIdx]; } | ||
else | ||
{ body = sliceArgs(args, bodyIdx); } | ||
} | ||
return initElementNode(tag, attrs, body); | ||
} | ||
// #destub: cssTag,autoPx | ||
nano.h = h; | ||
nano.defineElementSpread = defineElementSpread; | ||
ViewModelProto.events = null; | ||
@@ -1746,0 +1713,0 @@ ViewModelProto.emit = emit; |
/* | ||
https://github.com/leeoniya/domvm (v2.1.1, server) | ||
https://github.com/leeoniya/domvm (v2.1.3, server) | ||
*/ | ||
'use strict';(function(E,q){"object"===typeof exports&&"undefined"!==typeof module?module.exports=q():"function"===typeof define&&define.amd?define(q):E.domvm=q()})(this,function(){function E(){}function q(a){a=typeof a;return"string"===a||"number"===a}function w(a){return"function"===typeof a}function y(a){for(var b=arguments,c=1;c<b.length;c++)for(var d in b[c])a[d]=b[c][d];return a}function S(a,b){for(var c=[];b<a.length;b++)c.push(a[b]);return c}function wa(a,b){for(var c in a)if(a[c]!==b[c])return!1; | ||
return!0}function T(a,b){var c=a.length;if(b.length!=c)return!1;for(var d=0;d<c;d++)if(a[d]!==b[d])return!1;return!0}function U(a){function b(){c=0;a.apply(d,e)}if(!V)return a;var c,d,e;return function(){d=this;e=arguments;c||(c=V(b))}}function xa(a,b,c){return function(){return a.apply(c,b)}}function F(a,b){switch(b){case "value":case "checked":case "selected":case "selectedIndex":return!0}return!1}function r(a){for(a=a||u;null==a.vm&&a.parent;)a=a.parent;return a.vm}function W(a,b){return isNaN(b)|| | ||
ya[a]?b:b+"px"}function X(a){z=a.is;Y=a.val;Z=a.sub;aa=a.unsub}function G(a,b){var c=Z(a,function(a){c&&(null!=b.node&&b.redraw(),aa(c))});return Y(a)}function ba(a,b){var c=(a.attrs||u).style;b=b?(b.attrs||u).style:null;if(null==c||q(c))a.el.style.cssText=c;else{for(var d in c){var e=c[d];z(e)&&(e=G(e,r(a)));if(null==b||null!=e&&e!==b[d])a.el.style[d]=W(d,e)}if(b)for(var f in b)null==c[f]&&(a.el.style[f]="")}}function ca(a,b,c,d,e){if(a)e?(a=c.parent,a&&a.el&&a.el.offsetHeight):K.push([b,c,d]);else return b(c, | ||
d)}function n(a,b,c,d){var e=b.hooks[a];if(e){var f=0===a.lastIndexOf("did",0);return l(e)?e.map(function(a){return ca(f,a,b,c)}):ca(f,e,b,c,d)}}function v(){}function da(a,b,c,d){var e=new v;e.type=1;null!=d&&(e.flags=d);null!=b&&(null!=b._key&&(e.key=b._key),null!=b._ref&&(e.ref=b._ref),null!=b._hooks&&(e.hooks=b._hooks),null!=b._raw&&(e.raw=b._raw),null!=b._data&&(e.data=b._data),null!=b._flags&&(e.flags=b._flags),null==e.key&&(null!=e.ref?e.key=e.ref:null!=b.id?e.key=b.id:null!=b.name&&(e.key= | ||
b.name)),e.attrs=b);b=ea[a];if(null==b){var f,g,h;for(ea[a]=b={tag:(f=a.match(/^[-\w]+/))?f[0]:"div",id:(g=a.match(/#([-\w]+)/))?g[1]:null,class:(h=a.match(/\.([-\w.]+)/))?h[1].replace(/\./g," "):null,attrs:null};f=za.exec(a);)null==b.attrs&&(b.attrs={}),b.attrs[f[1]]=f[2]||""}a=b;e.tag=a.tag;if(a.id||a.class||a.attrs){f=e.attrs||{};a.id&&null==f.id&&(f.id=a.id);a.class&&(e._class=a.class,f.class=a.class+(null!=f.class?" "+f.class:""));if(a.attrs)for(var k in a.attrs)null==f[k]&&(f[k]=a.attrs[k]); | ||
e.attrs=f}null!=c&&(e.body=c);return e}function fa(a){var b=a.hooks,c=a.vm;c&&c.hooks&&n("willUnmount",c);b=b&&n("willRemove",a);if(a.flags&2&&l(a.body))for(c=0;c<a.body.length;c++)fa(a.body[c]);return b}function L(a,b,c){var d=b._node,e=d.hooks,f=d.vm;if(d.flags&2&&l(d.body))for(var g=0;g<d.body.length;g++)L(b,d.body[g].el);a.removeChild(b);e&&n("didRemove",d,null,c);f&&f.hooks&&n("didUnmount",f,null,c)}function A(a,b){var c=fa(b._node);null!=c&&"object"===typeof c&&w(c.then)?c.then(xa(L,[a,b,!0])): | ||
L(a,b)}function m(a,b,c){var d=b._node,e=d.hooks,f=null!=b.parentNode,g=(b==c||!f)&&d.vm;g&&g.hooks&&n("willMount",g);e&&n(f?"willReinsert":"willInsert",d);a.insertBefore(b,c);e&&n(f?"didReinsert":"didInsert",d);g&&g.hooks&&n("didMount",g)}function ga(a,b,c){var d;for(d=a.target;null==d._node;)d=d.parentNode;d=d._node;var e=r(d);b=b.apply(null,c.concat(a,d,e));ha.onevent.apply(null,[a,d,e].concat(c));!1===b&&(a.preventDefault(),a.stopPropagation())}function ia(a,b){return function(c){ga(c,a,b)}}function Aa(a){return function(b){for(var c in a)if(b.target.matches(c)){var d= | ||
a[c],e=l(d),f=e?d[0]:d,d=e?d.slice(1):[];ga(b,f,d)}}}function ja(a,b,c,d){c!==d&&(a=a.el,l(c)?null!=d&&T(c,d)||(c=ia(c[0],c.slice(1)),a[b]=c):(c=w(c)&&c!=d?ia(c,[]):Aa(c),a[b]=c))}function ka(a,b,c,d){var e=a.el;null==c?a.el.removeAttribute(b):null!=a.ns?e.setAttribute(b,c):"class"==b?e.className=c:"id"==b||"boolean"==typeof c||d?e[b]=c:"."==b[0]?e[b.substr(1)]=c:e.setAttribute(b,c)}function la(a,b){var c=a.attrs||u,d=b.attrs||u,e;for(e in c){var f=c[e],g=F(a.tag,e),h=g?a.el[e]:d[e];z(f)&&(c[e]=f= | ||
G(f,r(a)));f!==h&&("style"==e?ba(a,b):"_"==e[0]||(0===e.lastIndexOf("on",0)?ja(a,e,f,h):ka(a,e,f,g)))}for(e in d)e in c||"_"==e[0]||(b=a,d=e,F(a.tag,e)||0===e.lastIndexOf("on",0)?b.el[d]="":b.el.removeAttribute(d))}function H(a,b,c,d){if(4==a.type)b=a.model,c=a.key,d=a.opts,a=a.view;else if(a.prototype._isClass)return new a(b,c,d);return new B(a,b,c,d)}function ma(a){for(var b=0;b<a.body.length;b++){var c=a.body[b],d=c.type;3>=d?m(a.el,t(c)):4==d?(c=H(c.view,c.model,c.key,c.opts)._redraw(a,b,!1), | ||
m(a.el,t(c.node))):5==d&&(c=c.vm,c._redraw(a,b),m(a.el,c.node.el))}}function t(a,b){if(null==a.el)if(1==a.type){if(!b){b=a.tag;var c=a.ns;b=null!=c?I.createElementNS(c,b):I.createElement(b)}a.el=b;if(null!=a.attrs){b=a.attrs;for(var d in b){var c=b[d],e=F(a.tag,d);z(c)&&(b[d]=c=G(c,r(a)));"style"==d?ba(a):"_"==d[0]||(0===d.lastIndexOf("on",0)?ja(a,d,c):null!=c&&ka(a,d,c,e))}}l(a.body)?ma(a):null!=a.body&&""!==a.body&&(a.raw?a.el.innerHTML=a.body:a.el.textContent=a.body)}else 2==a.type?a.el=b||I.createTextNode(a.body): | ||
3==a.type&&(a.el=b||I.createComment(a.body));a.el._node=a;return a.el}function na(a,b,c,d){c=c.previousSibling;d=d.nextSibling;a(c,d);return{lftSib:c?c.nextSibling:b.firstChild,rgtSib:d?d.previousSibling:b.lastChild}}function Ba(a,b,c,d,e){var f=e.idx==c.idx+1,g=f?!1:b._node==e,h=f?!0:d._node==c;return g||h?na(function(c,e){h&&m(a,d,b);g&&m(a,b,e)},a,b,d):null}function Ca(a,b,c,d){return na(function(c,f){for(var e=b;e!==f;e=e.nextSibling){b=c=e;for(var h=e.nextSibling;h!==f;h=h.nextSibling)0<d(c, | ||
h)&&(c=h);c!==e&&(m(a,c,b),e=c)}},a,b,c)}function Da(a,b){return a._node.idx-b._node.idx}function oa(a,b){var c=a.el,d=a.body,e=b.body;b=d[0];var f=d[d.length-1],g=(e[0]||u).el,e=(e[e.length-1]||u).el,h,k,l;a:for(;;){for(;;)if(g&&(k=g._node).parent!=a)h=g.nextSibling,null!=k.vm?k.vm.unmount(!0):A(c,g),g=h;else if(null==b)break a;else if(null==b.el)m(c,t(b),g),b=d[b.idx+1];else if(b.el===g)b=d[b.idx+1],g=g.nextSibling;else break;for(;;)if(e&&(l=e._node).parent!=a)h=e.previousSibling,null!=l.vm?l.vm.unmount(!0): | ||
A(c,e),e=h;else if(f==b)break a;else if(null==f.el)h=t(f),m(c,h,e?e.nextSibling:null),f=d[f.idx-1];else if(f.el===e)f=d[f.idx-1],e=e.previousSibling;else break;(h=Ba(c,g,b,e,f))||(h=Ca(c,g,e,Da));g=h.lftSib;e=h.rgtSib}}function Ea(a,b,c,d){for(;c<b.length;c++){d=b[c];if(4==a.type&&null!=d.vm){var e=d.vm;if(e.view==a.view&&e.key==a.key)return d}if(d.el._node==d&&a.tag===d.tag&&a.type===d.type&&a.vm===d.vm&&(a.key===d.key||null==d.key))return d}return null}function Fa(a,b){a:{a=a.key;var c=0,d=b.length- | ||
1,e;if(2147483647>=d)for(;c<=d;)if(e=c+d>>1,b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;else for(;c<=d;)if(e=Math.floor((c+d)/2),b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;a=-1}return-1<a?b[a]:null}function M(a,b,c){b.hooks&&n("willRecycle",b,a);c=a.el=b.el;var d=b.body,e=a.body;c._node=a;if(2==a.type&&e!==d)c.nodeValue=e;else{null==a.attrs&&null==b.attrs||la(a,b);var f=l(d),g=l(e);if(f)if(g){a.flags&4?(c=b.body.slice(),c.sort(Ga),d=Fa):(c=b.body,d=Ea);for(var h,e=0,f=a.body, | ||
g=0;g<f.length;g++){var k=f[g],m=k.type;3>=m?(h=d(k,c,e))&&M(k,h):4==m?(h=d(k,c,e))?h.vm._update(k.model,a,g):H(k.view,k.model,k.key,k.opts)._redraw(a,g,!1):5==m&&k.vm._update(k.model,a,g);a.list||null==h||h.idx!=e||e++}1!=a.type||a.flags&1||oa(a,b)}else{if(e!==d)if(null!=e)a.raw?c.innerHTML=e:c.textContent=e;else for(;c.firstChild;)A(c,c.firstChild)}else g?(c.firstChild&&c.removeChild(c.firstChild),ma(a)):e!==d&&(a.raw?c.innerHTML=e:c.firstChild?c.firstChild.nodeValue=e:c.textContent=e);b.hooks&& | ||
n("didRecycle",b,a)}}function Ga(a,b){return a.key>b.key?1:a.key<b.key?-1:0}function pa(a){var b=new v;b.type=2;b.body=a;return b}function x(a,b,c,d){if(5!=a.type&&4!=a.type){a.parent=b;a.idx=c;a.vm=d;if(null!=a.ref){c=r(a);b=["refs"].concat(a.ref.split("."));for(var e;e=b.shift();)c[e]=0==b.length?a:c=c[e]||{}}if(a.hooks&&a.hooks.willRemove||d&&d.hooks&&d.hooks.willUnmount)for(d=a;d=d.parent;)d.flags|=2;if(l(a.body))for(d=a.body,b=0;b<d.length;b++)c=d[b],!1===c||null==c?d.splice(b--,1):l(c)?(e=b--, | ||
d.splice.apply(d,[e,1].concat(c))):(null==c.type&&(d[b]=c=pa(""+c)),2==c.type?null==c.body||""==c.body?d.splice(b--,1):0<b&&2==d[b-1].type?(d[b-1].body+=c.body,d.splice(b--,1)):x(c,a,b,null):x(c,a,b,null));else z(a.body)&&(a.body=G(a.body,r(a)))}}function B(a,b,c,d){var e=this;e.api={};e.view=a;e.model=b;e.key=null==c?b:c;a.prototype._isClass?(a=e.diff,null!=a&&a!=p.diff&&(e.diff=p.diff.bind(e),e.diff(a))):(a=a.call(e,e,b,c),w(a)?e.render=a:(a.diff&&(e.diff(a.diff),delete a.diff),y(e,a)));d&&(e.opts= | ||
d,d.hooks&&e.hook(d.hooks),d.diff&&e.diff(d.diff));e._redrawAsync=U(function(a){return e._redraw()});e._updateAsync=U(function(a){return e._update(a)})}function J(a){if(K.length)for(a=a.node,a&&a.el&&a.el.offsetHeight;a=K.shift();)a[0](a[1],a[2])}function N(a,b,c,d){var e,f;null==c?null!=b&&b.constructor==Object?e=b:f=b:(e=b,f=c);return da(a,e,f,d)}function O(a,b,c,d){this.view=a;this.model=b;this.key=null==c?b:c;this.opts=d}function qa(a,b,c,d){return new O(a,b,c,d)}function P(a){this.vm=a}function ra(a){return new P(a)} | ||
function sa(a){var b=new v;b.type=1;b.el=b.key=a;return b}function ta(a,b){a=a.body;if(l(a))for(var c=0;c<a.length;c++){var d=a[c];null!=d.vm?b.push(d.vm):ta(d,b)}return b}function C(a){a=null==a?"":""+a;for(var b=0,c="";b<a.length;b++)switch(a[b]){case "&":c+="&";break;case "<":c+="<";break;case ">":c+=">";break;default:c+=a[b]}return c}function ua(a){a=null==a?"":""+a;for(var b=0,c="";b<a.length;b++)c+='"'==a[b]?""":a[b];return c}function Q(a,b){var c,d;switch(a.type){case 4:c=H(a.view, | ||
a.model,a.key,a.opts).html(b);break;case 5:c=a.vm.html();break;case 1:if(null!=a.el&&null==a.tag){c=a.el.outerHTML;break}c="<"+a.tag;if(null!=a.attrs){for(var e in a.attrs)if(!(0===e.lastIndexOf("on",0)||"."==e[0]||"_"==e[0]||!1===b&&F(a.tag,e))){var f=a.attrs[e];if("style"==e&&null!=f)if("object"==typeof f){d=void 0;var g="";for(d in f)null!==f[d]&&(g+=d.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()+": "+W(d,f[d])+"; ");d=g}else d=f;else!0===f?c+=" "+C(e)+'=""':!1!==f&&null!=f&&(c+=" "+C(e)+'="'+ | ||
ua(f)+'"')}null!=d&&(c+=' style="'+ua(d.trim())+'"')}if(null==a.body&&null!=a.ns&&"svg"!==a.tag)return c+"/>";c+=">";if(!Ha[a.tag]){if(l(a.body)){e=c;c=a.body;d="";for(f=0;f<c.length;f++)d+=Q(c[f],b);c=e+d}else c+=a.raw?a.body:C(a.body);c+="</"+a.tag+">"}break;case 2:c=C(a.body);break;case 3:c="\x3c!--"+C(a.body)+"--\x3e"}return c}var R="undefined"!=typeof window,V=(R?window:{}).requestAnimationFrame,u={},l=Array.isArray,ya={animationIterationCount:!0,boxFlex:!0,boxFlexGroup:!0,columnCount:!0,counterIncrement:!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,tabSize:!0,transform:!0,transformOrigin:!0,widows:!0,zIndex:!0,zoom:!0},ea={},za=/\[(\w+)(?:=(\w+))?\]/g,z=function(){return!1},Y=null,Z=null,aa=null,K=[],va=v.prototype={constructor:v,type:null,vm:null,key:null,ref:null,data:null,hooks:null,raw:!1,ns:null,el:null,tag:null,attrs:null,body:null,flags:0,_class:null,idx:null,parent:null},I=R?document: | ||
null,ha={onevent:E},p=B.prototype={constructor:B,_isClass:!1,view:null,key:null,model:null,opts:null,node:null,hooks:null,render:null,parent:function(){return r(this.node.parent)},root:function(){for(var a=this.node;a.parent;)a=a.parent;return a.vm},api:null,refs:null,mount:function(a,b){if(b){for(;a.firstChild;)a.removeChild(a.firstChild);this._redraw(null,null,!1);a.nodeName.toLowerCase()!=this.node.tag?(t(this.node),m(a.parentNode,this.node.el,a),a.parentNode.removeChild(a)):m(a.parentNode,t(this.node, | ||
a),a)}else this._redraw(null,null),a&&m(a,this.node.el);a&&J(this);return this},unmount:function(a){var b=this.node;A(b.el.parentNode,b.el);a||J(this)},redraw:function(a){a?this._redraw():this._redrawAsync();return this},update:function(a,b){b?this._update(a):this._updateAsync(a);return this},_update:function(a,b,c,d){null!=a&&this.model!==a&&(this.hooks&&n("willUpdate",this,a),this.model=a);return this._redraw(b,c,d)},_redraw:function(a,b,c){var d=null==a,e=this.node&&this.node.el&&this.node.el.parentNode, | ||
f=this.node;if(e&&null!=this._diff&&this._diff())return f&&a&&(a.body[b]=f,f.idx=b,f.parent=a),this;e&&this.hooks&&n("willRedraw",this);this.refs=null;var g=this.render.call(this,this,this.model,this.key);this.node=g;a?(x(g,a,b,this),a.body[b]=g):f&&f.parent?(x(g,f.parent,f.idx,this),f.parent.body[f.idx]=g):x(g,null,null,this);!1!==c&&(f?f.tag!==g.tag?(f.vm=g.vm=null,a=f.el.parentNode,b=f.el.nextSibling,A(a,f.el),m(a,t(g),b),f.el=g.el,g.vm=this):M(g,f,d):t(g));e&&this.hooks&&n("didRedraw",this);d&& | ||
e&&J(this);return this},_redrawAsync:null,_updateAsync:null,hook:function(a){this.hooks=this.hooks||y({},this.hooks,a)}};O.prototype={constructor:O,type:4,view:null,model:null,key:null,opts:null};P.prototype={constructor:P,type:5,vm:null};var D={config:function(a){y(ha,a)},ViewModel:B,VNode:v,createView:H,defineElement:N,defineSvgElement:function(a,b,c,d){a=N(a,b,c,d);a.ns="http://www.w3.org/2000/svg";return a},defineText:pa,defineComment:function(a){var b=new v;b.type=3;b.body= | ||
a;return b},defineView:qa,injectView:ra,injectElement:sa,FIXED_BODY:1,DEEP_REMOVE:2,KEYED_LIST:4};p._diff=null;p.diff=function(a){var b=this;if(w(a))var c=a;else var c=a.vals,d=a.then;var e=c.call(b,b,b.model,b.key,b.opts),f=l(e)?T:wa;b._diff=function(){var a=c.call(b,b,b.model,b.key,b.opts),h=f(e,a);h||(null!=d&&!1===d.call(b,b,e,a)&&(h=!0),e=a);return h}};va.patch=function(a){var b;a:{if(null!=a.type){if(null!=this.vm){b=void 0;break a}x(a,this.parent,this.idx,null);this.parent.body[this.idx]=a; | ||
M(a,this);J(r(a))}else{b=Object.create(this);b.attrs=y({},this.attrs);a=y(this.attrs,a);if(null!=this._class){var c=a.class;a.class=null!=c&&""!=c?this._class+" "+c:this._class}la(this,b)}b=void 0}return b};D.h=function(a){return(q(a)?N:w(a)?qa:R&&a instanceof HTMLElement?sa:a instanceof B?ra:E).apply(null,arguments)};D.defineElementSpread=function(a){var b=arguments,c=b.length,d,e;if(1<c){d=1;var f=b[1];null!=f&&f.constructor==Object&&(e=b[1],d=2);d=c==d+1&&(q(b[d])||l(b[d]))?b[d]:S(b,d)}return da(a, | ||
e,d)};p.events=null;p.emit=function(a){var b=arguments,c=this;do{var d=c.events;if(d=d?d[a]:null){d.apply(null,S(b,1));break}}while(c=c.parent())};p.on=function(a,b){null==this.events&&(this.events={});if(q(a))this.events[a]=b;else for(a in b=a,b)this.on(a,b[a])};p.body=function(){return ta(this.node,[])};"undefined"!=typeof flyd&&X({is:function(a){return flyd.isStream(a)},val:function(a){return a()},sub:function(a,b){return flyd.on(b,a)},unsub:function(a){return a.end(!0)}});D.streamCfg=X;D.prop= | ||
function(a,b,c,d){return function(e,f){"undefined"!=typeof e&&e!==a&&(a=e,!1!==f&&w(b)&&b.apply(c,d));return a}};p.html=function(a){null==this.node&&this._redraw(null,null,!1);return Q(this.node,a)};va.html=function(a){return Q(this,a)};var Ha={area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0};return D}); | ||
'use strict';(function(C,p){"object"===typeof exports&&"undefined"!==typeof module?module.exports=p():"function"===typeof define&&define.amd?define(p):C.domvm=p()})(this,function(){function C(a){a=typeof a;return"string"===a||"number"===a}function p(a){return"function"===typeof a}function y(a){for(var b=arguments,c=1;c<b.length;c++)for(var d in b[c])a[d]=b[c][d];return a}function pa(a,b){for(var c=[];b<a.length;b++)c.push(a[b]);return c}function qa(a,b){for(var c in a)if(a[c]!==b[c])return!1;return!0} | ||
function P(a,b){var c=a.length;if(b.length!=c)return!1;for(var d=0;d<c;d++)if(a[d]!==b[d])return!1;return!0}function Q(a){function b(){c=0;a.apply(d,e)}if(!R)return a;var c,d,e;return function(){d=this;e=arguments;c||(c=R(b))}}function ra(a,b,c){return function(){return a.apply(c,b)}}function D(a,b){switch(b){case "value":case "checked":case "selected":case "selectedIndex":return!0}return!1}function r(a){for(a=a||u;null==a.vm&&a.parent;)a=a.parent;return a.vm}function S(a,b){return isNaN(b)||sa[a]? | ||
b:b+"px"}function T(a){z=a.is;U=a.val;V=a.sub;W=a.unsub}function E(a,b){var c=V(a,function(a){c&&(null!=b.node&&b.redraw(),W(c))});return U(a)}function X(a,b){var c=(a.attrs||u).style;b=b?(b.attrs||u).style:null;if(null==c||C(c))a.el.style.cssText=c;else{for(var d in c){var e=c[d];z(e)&&(e=E(e,r(a)));if(null==b||null!=e&&e!==b[d])a.el.style[d]=S(d,e)}if(b)for(var f in b)null==c[f]&&(a.el.style[f]="")}}function Y(a,b,c,d,e){if(a)e?(a=c.parent,a&&a.el&&a.el.offsetHeight):J.push([b,c,d]);else return b(c, | ||
d)}function k(a,b,c,d){var e=b.hooks[a];if(e){var f=0===a.lastIndexOf("did",0);return n(e)?e.map(function(a){return Y(f,a,b,c)}):Y(f,e,b,c,d)}}function v(){}function Z(a){var b=a.hooks,c=a.vm;c&&c.hooks&&k("willUnmount",c);b=b&&k("willRemove",a);if(a.flags&2&&n(a.body))for(c=0;c<a.body.length;c++)Z(a.body[c]);return b}function K(a,b,c){var d=b._node,e=d.hooks,f=d.vm;if(d.flags&2&&n(d.body))for(var g=0;g<d.body.length;g++)K(b,d.body[g].el);a.removeChild(b);e&&k("didRemove",d,null,c);f&&f.hooks&&k("didUnmount", | ||
f,null,c)}function A(a,b){var c=Z(b._node);null!=c&&"object"===typeof c&&p(c.then)?c.then(ra(K,[a,b,!0])):K(a,b)}function m(a,b,c){var d=b._node,e=d.hooks,f=null!=b.parentNode,g=(b==c||!f)&&d.vm;g&&g.hooks&&k("willMount",g);e&&k(f?"willReinsert":"willInsert",d);a.insertBefore(b,c);e&&k(f?"didReinsert":"didInsert",d);g&&g.hooks&&k("didMount",g)}function aa(a,b,c){var d;for(d=a.target;null==d._node;)d=d.parentNode;d=d._node;var e=r(d);b=b.apply(null,c.concat(a,d,e));ba.onevent.apply(null,[a,d,e].concat(c)); | ||
!1===b&&(a.preventDefault(),a.stopPropagation())}function ca(a,b){return function(c){aa(c,a,b)}}function ta(a){return function(b){for(var c in a)if(b.target.matches(c)){var d=a[c],e=n(d),f=e?d[0]:d,d=e?d.slice(1):[];aa(b,f,d)}}}function da(a,b,c,d){c!==d&&(a=a.el,n(c)?null!=d&&P(c,d)||(c=ca(c[0],c.slice(1)),a[b]=c):(c=p(c)&&c!=d?ca(c,[]):ta(c),a[b]=c))}function ea(a,b,c,d){var e=a.el;null==c?a.el.removeAttribute(b):null!=a.ns?e.setAttribute(b,c):"class"==b?e.className=c:"id"==b||"boolean"==typeof c|| | ||
d?e[b]=c:"."==b[0]?e[b.substr(1)]=c:e.setAttribute(b,c)}function fa(a,b){var c=a.attrs||u,d=b.attrs||u,e;for(e in c){var f=c[e],g=D(a.tag,e),h=g?a.el[e]:d[e];z(f)&&(c[e]=f=E(f,r(a)));f!==h&&("style"==e?X(a,b):"_"==e[0]||(0===e.lastIndexOf("on",0)?da(a,e,f,h):ea(a,e,f,g)))}for(e in d)e in c||"_"==e[0]||(b=a,d=e,D(a.tag,e)||0===e.lastIndexOf("on",0)?b.el[d]="":b.el.removeAttribute(d))}function F(a,b,c,d){if(4==a.type)b=a.model,c=a.key,d=a.opts,a=a.view;else if(a.prototype._isClass)return new a(b,c, | ||
d);return new G(a,b,c,d)}function ga(a){for(var b=0;b<a.body.length;b++){var c=a.body[b],d=c.type;3>=d?m(a.el,t(c)):4==d?(c=F(c.view,c.model,c.key,c.opts)._redraw(a,b,!1),m(a.el,t(c.node))):5==d&&(c=c.vm,c._redraw(a,b),m(a.el,c.node.el))}}function t(a,b){if(null==a.el)if(1==a.type){if(!b){b=a.tag;var c=a.ns;b=null!=c?H.createElementNS(c,b):H.createElement(b)}a.el=b;if(null!=a.attrs){b=a.attrs;for(var d in b){var c=b[d],e=D(a.tag,d);z(c)&&(b[d]=c=E(c,r(a)));"style"==d?X(a):"_"==d[0]||(0===d.lastIndexOf("on", | ||
0)?da(a,d,c):null!=c&&ea(a,d,c,e))}}n(a.body)?ga(a):null!=a.body&&""!==a.body&&(a.raw?a.el.innerHTML=a.body:a.el.textContent=a.body)}else 2==a.type?a.el=b||H.createTextNode(a.body):3==a.type&&(a.el=b||H.createComment(a.body));a.el._node=a;return a.el}function ha(a,b,c,d){c=c.previousSibling;d=d.nextSibling;a(c,d);return{lftSib:c?c.nextSibling:b.firstChild,rgtSib:d?d.previousSibling:b.lastChild}}function ua(a,b,c,d,e){var f=e.idx==c.idx+1,g=f?!1:b._node==e,h=f?!0:d._node==c;return g||h?ha(function(c, | ||
e){h&&m(a,d,b);g&&m(a,b,e)},a,b,d):null}function va(a,b,c,d){return ha(function(c,f){for(var e=b;e!==f;e=e.nextSibling){b=c=e;for(var h=e.nextSibling;h!==f;h=h.nextSibling)0<d(c,h)&&(c=h);c!==e&&(m(a,c,b),e=c)}},a,b,c)}function wa(a,b){return a._node.idx-b._node.idx}function ia(a,b){var c=a.el,d=a.body,e=b.body;b=d[0];var f=d[d.length-1],g=(e[0]||u).el,e=(e[e.length-1]||u).el,h,l,k;a:for(;;){for(;;)if(g&&(l=g._node).parent!=a)h=g.nextSibling,null!=l.vm?l.vm.unmount(!0):A(c,g),g=h;else if(null==b)break a; | ||
else if(null==b.el)m(c,t(b),g),b=d[b.idx+1];else if(b.el===g)b=d[b.idx+1],g=g.nextSibling;else break;for(;;)if(e&&(k=e._node).parent!=a)h=e.previousSibling,null!=k.vm?k.vm.unmount(!0):A(c,e),e=h;else if(f==b)break a;else if(null==f.el)h=t(f),m(c,h,e?e.nextSibling:null),f=d[f.idx-1];else if(f.el===e)f=d[f.idx-1],e=e.previousSibling;else break;(h=ua(c,g,b,e,f))||(h=va(c,g,e,wa));g=h.lftSib;e=h.rgtSib}}function xa(a,b,c,d){for(;c<b.length;c++){d=b[c];if(4==a.type&&null!=d.vm){var e=d.vm;if(e.view==a.view&& | ||
e.key==a.key)return d}if(d.el._node==d&&a.tag===d.tag&&a.type===d.type&&a.vm===d.vm&&(a.key===d.key||null==d.key))return d}return null}function ya(a,b){a:{a=a.key;var c=0,d=b.length-1,e;if(2147483647>=d)for(;c<=d;)if(e=c+d>>1,b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;else for(;c<=d;)if(e=Math.floor((c+d)/2),b[e].key===a){a=e;break a}else b[e].key<a?c=e+1:d=e-1;a=-1}return-1<a?b[a]:null}function L(a,b,c){b.hooks&&k("willRecycle",b,a);c=a.el=b.el;var d=b.body,e=a.body;c._node=a;if(2==a.type&& | ||
e!==d)c.nodeValue=e;else{null==a.attrs&&null==b.attrs||fa(a,b);var f=n(d),g=n(e);if(f)if(g){a.flags&4?(c=b.body.slice(),c.sort(za),d=ya):(c=b.body,d=xa);for(var h,e=0,f=a.body,g=0;g<f.length;g++){var l=f[g],m=l.type;3>=m?(h=d(l,c,e))&&L(l,h):4==m?(h=d(l,c,e))?h.vm._update(l.model,a,g):F(l.view,l.model,l.key,l.opts)._redraw(a,g,!1):5==m&&l.vm._update(l.model,a,g);a.list||null==h||h.idx!=e||e++}1!=a.type||a.flags&1||ia(a,b)}else{if(e!==d)if(null!=e)a.raw?c.innerHTML=e:c.textContent=e;else for(;c.firstChild;)A(c, | ||
c.firstChild)}else g?(c.firstChild&&c.removeChild(c.firstChild),ga(a)):e!==d&&(a.raw?c.innerHTML=e:c.firstChild?c.firstChild.nodeValue=e:c.textContent=e);b.hooks&&k("didRecycle",b,a)}}function za(a,b){return a.key>b.key?1:a.key<b.key?-1:0}function ja(a){var b=new v;b.type=2;b.body=a;return b}function w(a,b,c,d){if(5!=a.type&&4!=a.type){a.parent=b;a.idx=c;a.vm=d;if(null!=a.ref){c=r(a);b=["refs"].concat(a.ref.split("."));for(var e;e=b.shift();)c[e]=0==b.length?a:c=c[e]||{}}if(a.hooks&&a.hooks.willRemove|| | ||
d&&d.hooks&&d.hooks.willUnmount)for(d=a;d=d.parent;)d.flags|=2;if(n(a.body))for(d=a.body,b=0;b<d.length;b++)c=d[b],!1===c||null==c?d.splice(b--,1):n(c)?(e=b--,d.splice.apply(d,[e,1].concat(c))):(null==c.type&&(d[b]=c=ja(""+c)),2==c.type?null==c.body||""==c.body?d.splice(b--,1):0<b&&2==d[b-1].type?(d[b-1].body+=c.body,d.splice(b--,1)):w(c,a,b,null):w(c,a,b,null));else z(a.body)&&(a.body=E(a.body,r(a)))}}function G(a,b,c,d){var e=this;e.view=a;e.model=b;e.key=null==c?b:c;a.prototype._isClass?(a=e.diff, | ||
null!=a&&a!=q.diff&&(e.diff=q.diff.bind(e),e.diff(a))):(a=a.call(e,e,b,c,d),p(a)?e.render=a:(a.diff&&(e.diff(a.diff),delete a.diff),y(e,a)));d&&(e.opts=d,d.hooks&&e.hook(d.hooks),d.diff&&e.diff(d.diff));e._redrawAsync=Q(function(a){return e._redraw()});e._updateAsync=Q(function(a){return e._update(a)});(a=e.hooks)&&a.didInit&&a.didInit.call(e,e,b,c,d)}function I(a){if(J.length)for(a=a.node,a&&a.el&&a.el.offsetHeight;a=J.shift();)a[0](a[1],a[2])}function ka(a,b,c,d){var e,f;null==c?null!=b&&b.constructor== | ||
Object?e=b:f=b:(e=b,f=c);c=e;b=new v;b.type=1;null!=d&&(b.flags=d);null!=c&&(null!=c._key&&(b.key=c._key),null!=c._ref&&(b.ref=c._ref),null!=c._hooks&&(b.hooks=c._hooks),null!=c._raw&&(b.raw=c._raw),null!=c._data&&(b.data=c._data),null!=c._flags&&(b.flags=c._flags),null==b.key&&(null!=b.ref?b.key=b.ref:null!=c.id?b.key=c.id:null!=c.name&&(b.key=c.name)),b.attrs=c);d=la[a];if(null==d){var g,h,l;for(la[a]=d={tag:(g=a.match(/^[-\w]+/))?g[0]:"div",id:(h=a.match(/#([-\w]+)/))?h[1]:null,class:(l=a.match(/\.([-\w.]+)/))? | ||
l[1].replace(/\./g," "):null,attrs:null};g=Aa.exec(a);)null==d.attrs&&(d.attrs={}),d.attrs[g[1]]=g[2]||""}a=d;b.tag=a.tag;if(a.id||a.class||a.attrs){g=b.attrs||{};a.id&&null==g.id&&(g.id=a.id);a.class&&(b._class=a.class,g.class=a.class+(null!=g.class?" "+g.class:""));if(a.attrs)for(var k in a.attrs)null!=g[k]||(g[k]=a.attrs[k]);b.attrs=g}null!=f&&(b.body=f);return b}function M(a,b,c,d){this.view=a;this.model=b;this.key=null==c?b:c;this.opts=d}function N(a){this.vm=a}function ma(a,b){a=a.body;if(n(a))for(var c= | ||
0;c<a.length;c++){var d=a[c];null!=d.vm?b.push(d.vm):ma(d,b)}return b}function B(a){a=null==a?"":""+a;for(var b=0,c="";b<a.length;b++)switch(a[b]){case "&":c+="&";break;case "<":c+="<";break;case ">":c+=">";break;default:c+=a[b]}return c}function na(a){a=null==a?"":""+a;for(var b=0,c="";b<a.length;b++)c+='"'==a[b]?""":a[b];return c}function O(a,b){var c,d;switch(a.type){case 4:c=F(a.view,a.model,a.key,a.opts).html(b);break;case 5:c=a.vm.html();break;case 1:if(null!=a.el&&null==a.tag){c= | ||
a.el.outerHTML;break}c="<"+a.tag;if(null!=a.attrs){for(var e in a.attrs)if(!(0===e.lastIndexOf("on",0)||"."==e[0]||"_"==e[0]||!1===b&&D(a.tag,e))){var f=a.attrs[e];if("style"==e&&null!=f)if("object"==typeof f){d=void 0;var g="";for(d in f)null!==f[d]&&(g+=d.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()+": "+S(d,f[d])+"; ");d=g}else d=f;else!0===f?c+=" "+B(e)+'=""':!1!==f&&null!=f&&(c+=" "+B(e)+'="'+na(f)+'"')}null!=d&&(c+=' style="'+na(d.trim())+'"')}if(null==a.body&&null!=a.ns&&"svg"!==a.tag)return c+ | ||
"/>";c+=">";if(!Ba[a.tag]){if(n(a.body)){e=c;c=a.body;d="";for(f=0;f<c.length;f++)d+=O(c[f],b);c=e+d}else c+=a.raw?a.body:B(a.body);c+="</"+a.tag+">"}break;case 2:c=B(a.body);break;case 3:c="\x3c!--"+B(a.body)+"--\x3e"}return c}var x="undefined"!=typeof window,R=(x?window:{}).requestAnimationFrame,u={},n=Array.isArray,sa={animationIterationCount:!0,boxFlex:!0,boxFlexGroup:!0,columnCount:!0,counterIncrement:!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,tabSize:!0,transform:!0,transformOrigin:!0,widows:!0,zIndex:!0,zoom:!0},la={},Aa=/\[(\w+)(?:=(\w+))?\]/g,z=function(){return!1},U=null,V=null,W=null,J=[],oa=v.prototype={constructor:v,type:null,vm:null,key:null,ref:null,data:null,hooks:null,raw:!1,ns:null,el:null,tag:null,attrs:null,body:null,flags:0,_class:null,idx:null,parent:null},H=x?document:null,ba={onevent:function(){}},q=G.prototype={constructor:G,_isClass:!1,view:null,key:null,model:null, | ||
opts:null,node:null,hooks:null,render:null,parent:function(){return r(this.node.parent)},root:function(){for(var a=this.node;a.parent;)a=a.parent;return a.vm},api:null,refs:null,mount:function(a,b){if(b){for(;a.firstChild;)a.removeChild(a.firstChild);this._redraw(null,null,!1);a.nodeName.toLowerCase()!=this.node.tag?(t(this.node),m(a.parentNode,this.node.el,a),a.parentNode.removeChild(a)):m(a.parentNode,t(this.node,a),a)}else this._redraw(null,null),a&&m(a,this.node.el);a&&I(this);return this},unmount:function(a){var b= | ||
this.node;A(b.el.parentNode,b.el);a||I(this)},redraw:function(a){a?this._redraw():this._redrawAsync();return this},update:function(a,b){b?this._update(a):this._updateAsync(a);return this},_update:function(a,b,c,d){null!=a&&this.model!==a&&(this.hooks&&k("willUpdate",this,a),this.model=a);return this._redraw(b,c,d)},_redraw:function(a,b,c){var d=null==a,e=this.node&&this.node.el&&this.node.el.parentNode,f=this.node;if(e&&null!=this._diff&&this._diff())return f&&a&&(a.body[b]=f,f.idx=b,f.parent=a), | ||
this;e&&this.hooks&&k("willRedraw",this);this.refs=null;var g=this.render.call(this,this,this.model,this.key);!1!==this.key&&(g.key=this.key);this.node=g;a?(w(g,a,b,this),a.body[b]=g):f&&f.parent?(w(g,f.parent,f.idx,this),f.parent.body[f.idx]=g):w(g,null,null,this);!1!==c&&(f?f.tag!==g.tag?(f.vm=g.vm=null,a=f.el.parentNode,b=f.el.nextSibling,A(a,f.el),m(a,t(g),b),f.el=g.el,g.vm=this):L(g,f,d):t(g));e&&this.hooks&&k("didRedraw",this);d&&e&&I(this);return this},_redrawAsync:null,_updateAsync:null,hook:function(a){this.hooks= | ||
this.hooks||y({},this.hooks,a)}};M.prototype={constructor:M,type:4,view:null,model:null,key:null,opts:null};N.prototype={constructor:N,type:5,vm:null};x={config:function(a){y(ba,a)},ViewModel:G,VNode:v,createView:F,defineElement:ka,defineSvgElement:function(a,b,c,d){a=ka(a,b,c,d);a.ns="http://www.w3.org/2000/svg";return a},defineText:ja,defineComment:function(a){var b=new v;b.type=3;b.body=a;return b},defineView:function(a,b,c,d){return new M(a,b,c,d)},injectView:function(a){return new N(a)}, | ||
injectElement:function(a){var b=new v;b.type=1;b.el=b.key=a;return b},FIXED_BODY:1,DEEP_REMOVE:2,KEYED_LIST:4};q._diff=null;q.diff=function(a){var b=this;if(p(a))var c=a;else var c=a.vals,d=a.then;var e=c.call(b,b,b.model,b.key,b.opts),f=n(e)?P:qa;b._diff=function(){var a=c.call(b,b,b.model,b.key,b.opts),h=f(e,a);h||(null!=d&&!1===d.call(b,b,e,a)&&(h=!0),e=a);return h}};oa.patch=function(a){var b;a:{if(null!=a.type){if(null!=this.vm){b=void 0;break a}w(a,this.parent,this.idx,null);this.parent.body[this.idx]= | ||
a;L(a,this);I(r(a))}else{b=Object.create(this);b.attrs=y({},this.attrs);a=y(this.attrs,a);if(null!=this._class){var c=a.class;a.class=null!=c&&""!=c?this._class+" "+c:this._class}fa(this,b)}b=void 0}return b};q.events=null;q.emit=function(a){var b=arguments,c=this;do{var d=c.events;if(d=d?d[a]:null){d.apply(null,pa(b,1));break}}while(c=c.parent())};q.on=function(a,b){null==this.events&&(this.events={});if(C(a))this.events[a]=b;else for(a in b=a,b)this.on(a,b[a])};q.body=function(){return ma(this.node, | ||
[])};"undefined"!=typeof flyd&&T({is:function(a){return flyd.isStream(a)},val:function(a){return a()},sub:function(a,b){return flyd.on(b,a)},unsub:function(a){return a.end(!0)}});x.streamCfg=T;x.prop=function(a,b,c,d){return function(e,f){"undefined"!=typeof e&&e!==a&&(a=e,!1!==f&&p(b)&&b.apply(c,d));return a}};q.html=function(a){null==this.node&&this._redraw(null,null,!1);return O(this.node,a)};oa.html=function(a){return O(this,a)};var Ba={area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,hr:!0,img:!0, | ||
input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0};return x}); |
@@ -8,3 +8,3 @@ { | ||
"author": "Leon Sorokin <leeoniya@gmail.com>", | ||
"version": "2.1.1", | ||
"version": "2.1.3", | ||
"main": "./dist/full/domvm.full.min.js", | ||
@@ -11,0 +11,0 @@ "scripts": { |
@@ -116,9 +116,8 @@ <img src="domvm.png" alt="domvm logo" style="max-width:100%;" align="right" height="60"> | ||
domvm.defineElementSpread | ||
domvm.defineFragment | ||
Additionally, there's a convenience factory `domvm.h` that can discern `defineElement`, `defineView`, `injectView` and `injectElement` based on the provided arguments. | ||
--> | ||
Using `defineText` isn't strictly necessary since all encountered numbers and strings will be automatically converted into `defineText` vnodes for you. | ||
Additionally, there's a convenience factory `domvm.h` that can discern `defineElement`, `defineView`, `injectView` and `injectElement` based on the provided arguments. | ||
Below is a dense reference of most template semantics. Pay attention, there's a lot of neat stuff in here that won't be covered later! | ||
Below is a dense reference of most template semantics. **Pay attention!**, there's a lot of neat stuff in here that won't be covered later! | ||
@@ -303,3 +302,3 @@ ```js | ||
iv(model.viewC), // injected explicit view | ||
]), | ||
]); | ||
}; | ||
@@ -452,6 +451,8 @@ } | ||
- didInit (after view's closure/constructor) | ||
- willUpdate (before views's model is replaced) | ||
- will/didRedraw | ||
- will/didMount | ||
- will/didUnmount | ||
- will/didMount (dom insertion) | ||
- will/didUnmount (dom removal) | ||
View-level `will*` hooks are not yet promise handling, so cannot be used for delay, but you can just rely on the view's root node's hooks to accomplish similar goals. |
@@ -8,2 +8,3 @@ // #destub: cssTag,autoPx | ||
/* | ||
import { h } from "../view/addons/h"; | ||
@@ -16,3 +17,4 @@ | ||
nano.defineElementSpread = defineElementSpread; | ||
*/ | ||
export default nano; |
@@ -16,2 +16,6 @@ export const ENV_DOM = typeof window != "undefined"; | ||
export function isSet(val) { | ||
return val != null; | ||
} | ||
export function isPlainObj(val) { | ||
@@ -18,0 +22,0 @@ return val != null && val.constructor == Object; // && typeof val == "object" |
@@ -8,3 +8,3 @@ import { isVal, isElem, isFunc, noop } from '../../utils'; | ||
// does not handle defineComment, defineText, defineSVG (ambiguous); use plain text vals or explicit factories in templates. | ||
// does not handle defineComment, defineText, defineSvgElement (ambiguous); use plain text vals or explicit factories in templates. | ||
// does not handle defineElementSpread (not available in all builds); use exlicit factories in templates. | ||
@@ -14,3 +14,3 @@ export function h(a) { | ||
isVal(a) ? defineElement : | ||
isFunc(a) ? defineView : // todo: es6 class constructor | ||
isFunc(a) ? defineView : | ||
isElem(a) ? injectElement : | ||
@@ -17,0 +17,0 @@ a instanceof ViewModel ? injectView : |
import { ELEMENT } from './VTYPES'; | ||
import { VNode } from './VNode'; | ||
import { cssTag } from './addons/stubs'; | ||
import { isPlainObj } from '../utils'; | ||
import { isSet, isPlainObj } from '../utils'; | ||
function isSet(val) { | ||
return val != null; | ||
} | ||
// (de)optimization flags | ||
@@ -11,0 +7,0 @@ |
@@ -127,3 +127,3 @@ import { emptyObj } from '../utils'; | ||
// from_right: | ||
while(1) { | ||
while (1) { | ||
// if (rgtSib == lftEnd) | ||
@@ -130,0 +130,0 @@ // break converge; |
@@ -12,4 +12,2 @@ import { patch } from "./patch"; | ||
vm.api = {}; | ||
vm.view = view; | ||
@@ -20,3 +18,3 @@ vm.model = model; | ||
if (!view.prototype._isClass) { | ||
var out = view.call(vm, vm, model, key); // , opts | ||
var out = view.call(vm, vm, model, key, opts); | ||
@@ -43,2 +41,3 @@ if (isFunc(out)) | ||
} | ||
// remove this? | ||
@@ -58,2 +57,7 @@ if (opts) { | ||
var hooks = vm.hooks; | ||
if (hooks && hooks.didInit) | ||
hooks.didInit.call(vm, vm, model, key, opts); | ||
// this.update(model, parent, idx, parentVm, false); | ||
@@ -217,2 +221,5 @@ | ||
if (vm.key !== false) | ||
vnew.key = vm.key; | ||
// console.log(vm.key); | ||
@@ -219,0 +226,0 @@ |
@@ -33,3 +33,3 @@ QUnit.module("Hyperscript"); | ||
QUnit.test('Factory disambig', function(assert) { | ||
QUnit.skip('Factory disambig', function(assert) { | ||
instr.start(); | ||
@@ -36,0 +36,0 @@ var vm = domvm.createView(ViewA).mount(testyDiv); |
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 not supported yet
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 not supported yet
Sorry, the diff of this file is not supported yet
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
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
455
1478301
20679