diff --git a/dist/mvvm.js b/dist/mvvm.js index fbf7caea..99410a46 100644 --- a/dist/mvvm.js +++ b/dist/mvvm.js @@ -1,7 +1,7 @@ /*! - * mvvm.js v1.4.0 (c) 2017 TANG + * mvvm.js v1.4.1 (c) 2017 TANG * Released under the MIT license - * Sat Oct 14 2017 08:39:43 GMT+0800 (CST) + * Sat Nov 04 2017 11:30:28 GMT+0800 (CST) */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : @@ -1258,6 +1258,20 @@ var regQuotes = /(^'*)|('*$)|(^"*)|("*$)/g var regJsonFormat = /[^,]+:[^:]+((?=,[^:]+:)|$)/g + /** + * 生成匿名事件函数 + * @param {String} expression + * @return {Function} + */ + function createAnonymous (expression) { + try { + return new Function('scope', addScope(expression)) + } catch (e) { + error('Invalid generated expression: [' + expression + ']') + return noop + } + } + /** * 分解字符串函数参数 * @param {String} funcString @@ -1326,6 +1340,11 @@ var info = stringToParams(expression) var func = info.func, args = info.args + // 尝试匿名函数表达式 + if (!isNormal(func)) { + func = createAnonymous(expression) + } + return { type: type, dress: dress, func: func, args: args } } @@ -1340,7 +1359,7 @@ var expression = desc.expression if (args) { - binds.push(formatEvent(args, expression)) + binds = [formatEvent(args, expression)] } else { var json = convertJson(expression) each(json, function (value, key) { @@ -1432,6 +1451,10 @@ var dress = bind.dress var capture = dress.indexOf('capture') > -1 + if (isFunc(func)) { + return this.bindAnonymousEvent(type, dress, func) + } + if (func === '$remove') { return this.bindRemoveEvent(type, dress) } @@ -1459,7 +1482,18 @@ } /** - * 隐性绑定删除($remove) vfor 选项事件 + * 绑定匿名事件 + * @param {String} type [事件类型] + * @param {String} dress [事件修饰符] + * @param {Function} func [匿名事件函数] + */ + von.bindAnonymousEvent = function (type, dress, func) { + var scope = this.scope || this.vm.$data + this.bindEvent(type, dress, func.bind(scope, scope)) + } + + /** + * 匿名绑定删除($remove) vfor 选项事件 * @param {String} type [事件类型] * @param {String} dress [事件修饰符] */ diff --git a/dist/mvvm.min.js b/dist/mvvm.min.js index 3b999d6f..a5691f02 100644 --- a/dist/mvvm.min.js +++ b/dist/mvvm.min.js @@ -1,6 +1,6 @@ /*! - * mvvm.js v1.4.0 (c) 2017 TANG + * mvvm.js v1.4.1 (c) 2017 TANG * Released under the MIT license - * Sat Oct 14 2017 08:39:46 GMT+0800 (CST) + * Sat Nov 04 2017 11:30:31 GMT+0800 (CST) */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.MVVM=e()}(this,function(){"use strict";function t(t,e){return typeof t===e}function e(t){return"[object Object]"===Yt.toString.call(t)}function n(t){return Array.isArray(t)}function i(e){return t(e,"function")}function s(e){return t(e,"string")}function r(e){return t(e,"boolean")}function o(e){return t(e,"number")&&!isNaN(e)}function h(t){return!(!t||!e(t)||t.nodeType||t===t.window)&&!(t.constructor&&!te.call(t.constructor.prototype,"isPrototypeOf"))}function u(t){return 0===Object.keys(t).length}function a(t){return null==t?"":t.toString()}function c(t){if(s(t)){var e=Number(t);return o(e)?e:t}return t}function f(){}function l(){ee&&ee.warn.apply(ee,arguments)}function d(){ee&&ee.error.apply(ee,arguments)}function p(t,e){return t&&te.call(t,e)}function v(t,e,n,i){return Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!!i,configurable:!0})}function _(t,i,s){var r,o;if(s||(s=this),n(t))for(r=0;r1&&p(t,i[0]);)t=t[i.shift()];return e=i[0],"undefined"!=typeof n?void(t[e]=n):t[e]}function k(t){this.path=t,this.watchers=[],this.guid=ie++}function O(t){return t}function C(t){return""}function A(t){var e=t.charCodeAt(0);if(e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57)return oe;switch(e){case 91:case 93:case 46:case 34:case 39:return he;default:return ue}}function N(t){var e=[],n=t.split(""),i=n.length-1,s=A(n[0]);return ce.init(s),_(n,function(t,n){var s=A(t),r=ce.set(s,t);r&&e.push(r),n===i&&ce.saves&&(e.push(ce.saves),ce.reset())}),e}function D(t,e){for(;e.length;)t=t[e.shift()];return t}function E(t){return N(w(t))}function I(t,n,i){var s=g(i),r=s.pop(),o=D(t,s);e(o)&&(o[r]=n)}function T(t){var e=ye.length;return ye[e]=t,'"'+e+'"'}function j(t,e){return ye[e]}function L(t){var e=t.charAt(0),n=t.slice(1);return me.test(n)?t:(n=n.indexOf('"')>-1?n.replace(fe,j):n,e+"scope."+n)}function S(t){return ve.test(t)&&!le.test(t)&&0!==t.indexOf("Math.")}function P(t){return S(t)?"scope."+t:(t=(" "+t).replace(de,T),t=t.replace(pe,L),t=t.replace(fe,j))}function U(t){if(ge.test(t))return l("Avoid using unallow keyword in expression ["+t+"]"),f;try{return new Function("scope","return "+P(t)+";")}catch(e){return d("Invalid generated expression: ["+t+"]"),f}}function W(t){var e=E(t);return e.length?function(t,n){I(t,n,e)}:(d("Invalid setter expression ["+t+"]"),f)}function M(t,e){var n=t&&t.__ob__,i=n&&n.dep.guid;if(i){if($e.indexOf(i)>-1)return;$e.push(i)}_(t,function(t){M(t,!1)}),e&&($e.length=0)}function V(t,e,n,s){this.vm=t,b(this,e),this.callback=n,this.context=s||this,this.depIds=[],this.newDepIds=[],this.shallowIds=[],this.depends=[],this.newDepends=[];var r=e.once,o=e.expression,h=i(o);this.getter=h?o:U(o),this.setter=!r&&e.duplex?W(o):null,this.oldVal=null,this.value=r?this.getValue():this.get()}function z(t){this.parser=t,this.scope=t.scope}function F(t,e,n,i){this.vm=t,this.el=e,this.desc=n,this.scope=i,this.parse()}function R(t){return t.prototype=Object.create(F.prototype)}function H(t){return 1===t.nodeType}function q(t){return 3===t.nodeType}function B(t){for(;t.firstChild;)t.removeChild(t.firstChild);return t}function Z(t,e){return t.getAttribute(e)||""}function G(t,e){t.removeAttribute(e)}function Q(t,e,n){return null==n||n===!1?G(t,e):void(n===!0?(t[e]=n,J(t,e)||t.setAttribute(e,"")):n!==Z(t,e)&&t.setAttribute(e,n))}function J(t,e){return t.hasAttribute(e)}function K(t,e){var n,i=t.classList;return i?i.contains(e):(n=" "+Z(t,"class")+" ",n.indexOf(" "+e+" ")>-1)}function X(t,e){var n,i=t.classList;e&&!K(t,e)&&(i?i.add(e):(n=" "+Z(t,"class")+" ",n.indexOf(" "+e+" ")===-1&&Q(t,"class",(n+e).trim())))}function Y(t,e){var n,i,s=t.classList;if(e&&K(t,e)){if(s)s.remove(e);else{for(i=" "+e+" ",n=" "+Z(t,"class")+" ";n.indexOf(i)>-1;)n=n.replace(i," ");Q(t,"class",n.trim())}t.className||G(t,"class")}}function tt(t,e,n,i){t.addEventListener(e,n,i)}function et(t,e,n,i){t.removeEventListener(e,n,i)}function nt(t){var e,n,i=w(t),s=i.match(Ae),r=s&&s[0];return r?(n=i.substr(0,i.indexOf(r)),e="["+r.substr(1,r.length-2)+"]"):n=i,{func:n,args:e}}function it(t){var e={},n=t.trim();if(Ce.test(n)){var i=n.length;n=n.substr(1,i-2).replace(/\s/g,"");var s=n.match(De);_(s,function(t){var n=t.split(":"),i=n[0],s=n[1];i&&s&&(i=i.replace(Ne,""),e[i]=s)})}return e}function st(t,e){var n,i=t.indexOf("."),s="";i>-1?(n=t.substr(0,i),s=t.substr(i+1,t.length)):n=t;var r=nt(e),o=r.func,h=r.args;return{type:n,dress:s,func:o,args:h}}function rt(t){var e=[],n=t.args,i=t.expression;if(n)e.push(st(n,i));else{var s=it(i);_(s,function(t,n){e.push(st(n,t))})}return e}function ot(t,e){var n,i=e.split("."),s=i.indexOf("self")>-1,r=i.indexOf("stop")>-1,o=i.indexOf("one")>-1,h=i.indexOf("prevent")>-1,u=i.indexOf("capture")>-1;return 0===t.indexOf("key")&&_(i,function(t){if(Oe.test(t))return n=+t,!1}),{self:s,stop:r,prevent:h,capture:u,keyCode:n,one:o}}function ht(){this.cache={},this.funcWatchers=[],this.argsWatchers=[],F.apply(this,arguments)}function ut(){F.apply(this,arguments)}function at(t){for(var e=0;e=e&&t.call(t)},e)}function Mt(t,e){for(var n=[],i=t.options,s=0;s-1?(n=i.substr(r+1),e=i.substr(0,r)):e=i,{args:n,attr:i,directive:e,expression:s}}function Qt(t){t.__afterHook__||v(t,"__afterHook__",Z(t,"v-hook:after")),t.__beforeHook__||v(t,"__beforeHook__",Z(t,"v-hook:before"))}function Jt(t,e){var n,i,s;return function(r,o,h){var u=r.path;u===n&&o===i&&h===s||(t.apply(e,arguments),n=u,i=o,s=h)}}function Kt(t){var n=t.model,s=t.view,r=t.computed,o=t.watchAll;return H(s)?e(n)?(this.$queue=[],this.$data=n,this.$element=s,this.$regEles={},this.$directives=[],this.$context=t.context||this,this.$ob=vt(this.$data),r&&bt(this.$data,r),this.$afters=[],this.$hooks=t.hooks||{},this.$customs=t.customs||{},this.$unifyCb=i(o)?Jt(o,this.$context):null,void(t.lazy||this.mount())):l("model must be a type of Object: ",n):l("view must be a type of DOMElement: ",s)}function Xt(t){var n=t.context||t.model;_(t.model,function(e,s){i(e)&&(t.model[s]=e.bind(n))}),_(t.methods,function(e,i){t.model[i]=e.bind(n)}),this.__ct__=n,this.__bk__=g(t.model),this.__vm__=new Kt(t),this.$data=this.__vm__.$data,this.$els=this.__vm__.$regEles,_(t.watches,function(t,n){i(t)?this.watch(n,t,!1):e(t)&&this.watch(n,t.handler,t.deep)},this)}var Yt=Object.prototype,te=Yt.hasOwnProperty,ee=window.console,ne=/\s/g,ie=0;k.watcher=null;var se=k.prototype;se.addWatcher=function(t){this.watchers.push(t)},se.removeWatcher=function(t){this.watchers.$remove(t)},se.depend=function(){k.watcher&&k.watcher.addDepend(this)},se.beforeNotify=function(){_(this.watchers,function(t){t.beforeUpdate()})},se.notify=function(t){_(this.watchers,function(e){e.update(t,this)},this)};var re=0,oe=1,he=2,ue=1,ae=[0,O,C,O],ce={init:function(t){this.saves="",this.state=t},set:function(t,e){var n=this.get(t),i=n.keepIdent,s=n.tobeQuote,r=n.tobeIdent;if(i)this.save(t,e);else{if(s){var o=this.saves;return this.saves="",this.change(t),o}r&&(this.save(t,e),this.change(t))}},get:function(t){var e=this.state,n=e===oe&&t===oe,i=(e===oe||e===re)&&t===he,s=e===he&&t===he,r=(e===he||e===re)&&t===oe;return{keepIdent:n,tobeQuote:i,keepQuote:s,tobeIdent:r}},change:function(t){this.state=t},save:function(t,e){this.saves+=ae[t](e)},reset:function(){this.saves="",this.state=re}},fe=/"(\d+)"/g,le=/^(true|false)$/,de=/[\{,]\s*[\w\$_]+\s*:|('[^']*'|"[^"]*")|typeof /g,pe=/[^\w$\.]([A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*|\['.*?'\]|\[".*?"\])*)/g,ve=/^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*|\['.*?'\]|\[".*?"\]|\[\d+\]|\[[A-Za-z_$][\w$]*\])*$/,_e="JSON.Math.parseInt.parseFloat.Date.this.true.false.null.undefined.Infinity.NaN.isNaN.isFinite.decodeURI.decodeURIComponent.encodeURI.encodeURIComponent",me=new RegExp("^("+_e.replace(/\./g,"\\b|")+"\\b)"),be="var.const.let.if.else.for.in.continue.switch.case.break.default.function.return.do.while.delete.try.catch.throw.finally.with.import.export.instanceof.yield.await",ge=new RegExp("^("+be.replace(/\./g,"\\b|")+"\\b)"),ye=[],$e=[],we=V.prototype;we.getScope=function(){return this.context.scope||this.vm.$data},we.getValue=function(){var t=this.getScope();return this.getter.call(t,t)},we.setValue=function(t){var e=this.getScope();this.setter&&this.setter.call(e,e,t)},we.get=function(){this.beforeGet();var t=this.getValue();return this.deep&&(this.shallowIds=g(this.newDepIds),M(t,!0)),this.afterGet(),t},we.beforeGet=function(){k.watcher=this},we.addDepend=function(t){var e=t.guid,n=this.newDepIds;n.indexOf(e)<0&&(n.push(e),this.newDepends.push(t),this.depIds.indexOf(e)<0&&t.addWatcher(this))},we.removeDepends=function(t){_(this.depends,function(e){t?t.call(this,e)&&e.removeWatcher(this):e.removeWatcher(this)},this)},we.afterGet=function(){k.watcher=null,this.removeDepends(function(t){return this.newDepIds.indexOf(t.guid)<0}),this.depIds=g(this.newDepIds),this.newDepIds.length=0,this.depends=g(this.newDepends),this.newDepends.length=0},we.beforeUpdate=function(){this.oldVal=g(this.value)},we.update=function(t,e){var n=this.oldVal,i=this.vm.$unifyCb,s=this.value=this.get(),r=t&&t.source;if(!r||r===s||"v-for"!==this.directive){var o=this.callback;o&&n!==s&&(o.call(this.context,s,n,this.deep&&this.shallowIds.indexOf(e.guid)<0,t),r&&(t.source=null)),i&&i({action:t,path:e.path},s,n)}},we.destroy=function(){this.value=null,this.removeDepends(),this.getter=this.setter=null,this.vm=this.callback=this.context=null};var xe=z.prototype;xe.mount=function(){var t=this.parser,e=this.watcher=new V(t.vm,t.desc,this.update,this);this.update(e.value)},xe.destroy=function(){this.watcher.destroy(),this.parser=this.scope=null},xe.update=function(){var t=this.parser;t.update.apply(t,arguments)},xe.get=function(){return this.watcher.value},xe.set=function(t){this.watcher.setValue(t)};var ke=F.prototype;ke.bind=function(){this.directive=new z(this),this.directive.mount()},ke.destroy=function(){var t=this.directive;t?t.destroy():i(this._destroy)&&this._destroy(),this.vm=this.el=this.desc=this.scope=null};var Oe=/^(\d)*$/,Ce=/^\{.*\}$/,Ae=/(\(.*\))/,Ne=/(^'*)|('*$)|(^"*)|("*$)/g,De=/[^,]+:[^:]+((?=,[^:]+:)|$)/g,Ee=2e3,Ie="__vonid__",Te=R(ht);Te.parse=function(){_(rt(this.desc),function(t){this.parseEvent(t)},this)},Te.getExpDesc=function(t){return b({},this.desc,{expression:t})},Te.parseEvent=function(t){var e=t.func,n=t.args,s=t.type,r=t.dress,o=r.indexOf("capture")>-1;if("$remove"===e)return this.bindRemoveEvent(s,r);var h=this.getExpDesc(e),u=new V(this.vm,h,function(t,e){this.off(s,e,o),this.bindEvent(s,r,t,n)},this),a=u.value;return i(a)?(this.bindEvent(s,r,a,n),void(h.once?u.destroy():this.funcWatchers.push(u))):(u.destroy(),l("Directive ["+this.desc.attr+"] must be a type of Function"))},Te.bindRemoveEvent=function(t,e){var n=this.scope;if(!n)return l("The specify event $remove must be used in v-for scope");var i=n.__alias__;this.bindEvent(t,e,function(){n.__viterator__.$remove(n[i])},"["+i+"]")},Te.bindEvent=function(t,e,n,i){var s=ot(t,e),r=s.self,o=s.stop,h=s.prevent,u=s.capture,a=s.keyCode,c=s.one;v(this.scope||this.vm.$data,"$event","__e__");var f=[];if(i){var l=this.getExpDesc(i),d=new V(this.vm,l,function(t){f=t},this);f=d.value,l.once?d.destroy():this.argsWatchers.push(d)}var p,m=this.el,b=function(t){r&&t.target!==m||a&&a!==t.keyCode||(f.length?_(f,function(e,n){("__e__"===e||e instanceof Event)&&(f[n]=t)}):f.push(t),h&&t.preventDefault(),o&&t.stopPropagation(),n.apply(this,f))},g=Ee++,y=this;c?(p=function(e){b(e),y.off(t,p,u)},p[Ie]=g):(n[Ie]=g,p=b),this.cache[g]=p,this.on(t,p,u)},Te.on=function(t,e,n){tt(this.el,t,e,n)},Te.off=function(t,e,n){var i=this.cache,s=e[Ie],r=i[s];r&&(et(this.el,t,r,n),delete i[s])},Te._destroy=function(){m(this.cache),_(this.funcWatchers,function(t){t.destroy()}),_(this.argsWatchers,function(t){t.destroy()})};var je=R(ut);je.parse=function(){this.scope?l("v-el can not be used inside v-for! Consider use v-custom to handle v-for element."):this.vm.$regEles[this.desc.expression]=this.el};var Le="__proto__"in{},Se=Array.prototype,Pe=Object.create(Se);_(["pop","push","sort","shift","splice","unshift","reverse"],function(t){var e=Se[t];v(Pe,t,function(){for(var n=arguments,i=[],s=this.__ob__,r=0;r=this.length&&(t=this.length),this.splice(t,1,e)[0]}),v(Se,"$remove",function(t){var e=this.indexOf(t);if(e>-1)return this.splice(e,1)});var Ue=Object.getOwnPropertyNames(Pe),We="__vfor__",Me="__vforid__",Ve=/(.*) (?:in|of) (.*)/,ze="push|pop|shift|unshift|splice".split("|"),Fe=R($t);Fe.parse=function(){var t=this.el,e=this.desc,n=t.parentNode,i=e.expression,s=i.match(Ve);if(!s)return l('The format of v-for must be like "item in/of items"!');if(1!==n.nodeType)return l("v-for cannot use in the root element!");if(J(t,"v-if"))return l("Do not use v-if and v-for on the same element! Consider filtering the source Array instead.");var r=s[1],o=s[2];this.length=0,this.scopes=[],this.init=!0,this.alias=r,this.partly=!1,this.partlyArgs=[],this.$parent=n,this.end=t.nextSibling,this.start=t.previousSibling,this.bodyDirs=t.__dirs__,this.tpl=t.cloneNode(!0),this.hooks=gt(this.vm,t),this.isOption="OPTION"===t.tagName&&"SELECT"===n.tagName,e.expression=o,this.bind(),this.updateModel()},Fe.updateModel=function(){if(this.isOption){var t=this.$parent.__vmodel__;t&&t.forceUpdate()}},Fe.hook=function(t,e,n){var s=this.hooks[t];i(s)&&(s.call(this.vm.$context,e,n,e[Me]),e=null)},Fe.update=function(t,e,n,i){this.length=t&&t.length,this.init?(this.$parent.replaceChild(this.buildList(t),this.el),this.el=null,this.init=!1):i&&ze.indexOf(i.method)>-1?(this.partly=!0,this.updatePartly(t,i),this.partly=!1):(this.recompileList(t),this.updateModel())},Fe.updatePartly=function(t,e){var n=[],i=e.args,s=e.method,r=this.scopes;switch(this[s].call(this,t,i),s){case"pop":case"shift":break;case"push":case"unshift":n=this.partlyArgs;break;case"splice":n=i.slice(0,2),Array.prototype.push.apply(n,this.partlyArgs)}r[s].apply(r,n),this.partlyArgs.length=0,_(r,function(t,e){t.$index=e})},Fe.recompileList=function(t){for(var e=this,n=0,i=this.$parent,s=i.childNodes,r=0;r1&&n.block(this.el),v(a,We,u),v(a,Me,yt()),n.compile(a,!0,f,this.desc.once),r.appendChild(a),this.hook("after",a,h)},this),r},Fe.getChilds=function(){for(var t=this,e=[],n=this.$parent.childNodes,i=0;i=n&&e0,Xe={bind:function(){function t(t){i&&(t=t.trim());var e=Vt(t,r);o?Wt(function(){n.onDebounce=!0,h.set(e)},c(o)):h.set(e)}var e,n=this,i=this.trim,s=this.lazy,r=this.number,o=this.debounce,h=this.directive;this.on("compositionstart",function(){e=!0}),this.on("compositionend",function(){e=!1,s||t(this.value)}),this.on("input",function(){e||s||t(this.value)}),this.on("blur",function(){t(this.value)}),this.on("change",function(){t(this.value)}),Ke&&(this.on("cut",function(){t(this.value)}),this.on("keyup",function(e){var n=e.keyCode;8!==n&&46!==n||t(this.value)}))},update:function(t){var e=this.el,n=a(t);e.value===n||this.onDebounce||(e.value=n)}},Ye={bind:function(){var t=this.number,e=this.directive;this.on("change",function(){e.set(Vt(this.value,t))})},update:function(t){var e=this.el;e.checked=e.value===a(t)}},tn={bind:function(){var t=this.multi,e=this.number,n=this.directive;this.on("change",function(){var i=t?Mt(this,e):Vt(this.value,e);n.set(i)}),this.vm.after(this.forceUpdate,this)},update:function(t){var e=this.el,i=this.multi,s=this.desc.expression;if(e.selectedIndex=-1,i&&!n(t))return l(" has no multiple propperty");for(var r=e.options,o=0;o-1:u===a(t)}},forceUpdate:function(){this.update(this.directive.get())}},en={bind:function(){var t=this.number,e=this.directive;this.on("change",function(){var i=e.get(),s=this.checked;if(r(i))e.set(s);else if(n(i)){var o=Vt(this.value,t),h=zt(o,i);s&&h===-1?i.push(o):h>-1&&i.splice(h,1)}})},update:function(t){var e=this.el,i=Vt(e.value,this.number);return n(t)||r(t)?void(e.checked=r(t)?t:zt(i,t)>-1):l("Checkbox v-model value must be a type of Boolean or Array")}},nn=["input","select","textarea"],sn=R(Ft);sn.parse=function(){var t=this.el,e=this.desc,n=t.tagName.toLowerCase(),i="input"===n?Z(t,"type"):n;return nn.indexOf(n)<0?l("v-model only for using in "+nn.join(", ")):S(e.expression)?(e.duplex=!0,void this.bindDuplex(i)):l("v-model directive value can be use by static expression")},sn.bindDuplex=function(t){var e,n=this.el;switch(t){case"text":case"password":case"textarea":e=Xe,this.trim=J(n,"trim"),this.lazy=J(n,"lazy"),this.debounce=Z(n,"debounce");break;case"radio":e=Ye;break;case"checkbox":e=en;break;case"select":e=tn,v(n,"__vmodel__",this),this.multi=J(n,"multiple"),this.forceUpdate=tn.forceUpdate.bind(this)}return e?(this.number=J(n,"number"),this.update=e.update.bind(this),this.bind(),void(this.desc.once||e.bind.call(this))):l("Do not use incorrect form-type with v-model: ",n)},sn.on=function(t,e){tt(this.el,t,e,!1)};var rn=R(Rt);rn.parse=function(){var t=this.desc,e=this.vm.$customs[t.args];return i(e)?(this.update=e,void this.bind()):l("Custom directive ["+t.attr+"] must define with a refresh function!")};var on={von:ht,vel:ut,vif:Ot,vfor:$t,vtext:Ct,vhtml:At,vshow:Et,vbind:Ut,vmodel:Ft,vcustom:Rt},hn=/\n/g,un=/\{\{(.+?)\}\}/g,an=/(\{\{.*\}\})/,cn=["velse","vpre","vcloak","vonce","vhook"],fn=Kt.prototype;fn.mount=function(){this.$done=!1,this.$fragment=$(this.$element),this.compile(this.$fragment,!0)},fn.compile=function(t,e,n,i){var s=this,r=t.childNodes,o=!!i||qt(t);e&&Zt(t)&&this.$queue.push([t,n]),v(t,"__vonce__",o);for(var h=0;h1&&o!==h.length-1){var l=h.splice(o,1)[0];h.push(l),l=null}i&&(v(e,"__dirs__",h.length),h=[i],i=null),_(h,function(t){this.parse(e,t,n)},this)}else q(e)&&this.parseText(e,n)},fn.parse=function(t,e,n){var i=t.__vonce__,s=Gt(e),r=s.directive,o="v"+r.substr(2),h=on[o];if(G(t,s.attr),!(cn.indexOf(o)>-1))if(h){s.once=i;var u=new h(this,t,s,n);i?u.destroy():n||this.$directives.push(u)}else l("["+r+"] is an unknown directive!")},fn.parseText=function(t,e){var n=[],i={},s=t.parentNode&&t.parentNode.__vonce__,r=t.textContent.trim().replace(hn,""),o=r.split(un),h=r.match(un);_(o,function(t){h.indexOf("{{"+t+"}}")>-1?n.push("("+t+")"):t&&n.push('"'+t+'"')}),i.once=s,i.expression=n.join("+");var u=new on.vtext(this,t,i,e);s?u.destroy():e||this.$directives.push(u)},fn.block=function(t){_(this.$queue,function(e){if(t===e[0])return null})},fn.after=function(t,e){this.$afters.push([t,e])},fn.completed=function(){0!==this.$queue.length||this.$done||(this.$done=!0,this.$element.appendChild(this.$fragment),_(this.$afters,function(t){return t[0].call(t[1]),null}))},fn.destroy=function(){this.$data=null,B(this.$element),_(this.$directives,function(t){return t.destroy(),null})};var ln=Xt.prototype;return ln.mount=function(){this.__vm__.mount()},ln.get=function(t){var e=this.$data;return s(t)?x(e,t):e},ln.getCopy=function(t){return g(this.get(t))},ln.set=function(t,n){var i=this.$data;s(t)?x(i,t,n):e(t)&&_(t,function(t,e){x(i,e,t)})},ln.reset=function(t){var e=this.$data,i=g(this.__bk__);s(t)?e[t]=i[t]:n(t)?_(t,function(t){e[t]=i[t]}):_(e,function(t,n){e[n]=i[n]})},ln.watch=function(t,e,n){return new V(this,{deep:n,expression:t},e.bind(this.__ct__))},ln.destroy=function(){this.__vm__.destroy(),this.__vm__=this.__ct__=this.__bk__=this.$data=this.$els=null},Xt}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.MVVM=e()}(this,function(){"use strict";function t(t,e){return typeof t===e}function e(t){return"[object Object]"===te.toString.call(t)}function n(t){return Array.isArray(t)}function i(e){return t(e,"function")}function s(e){return t(e,"string")}function r(e){return t(e,"boolean")}function o(e){return t(e,"number")&&!isNaN(e)}function h(t){return!(!t||!e(t)||t.nodeType||t===t.window)&&!(t.constructor&&!ee.call(t.constructor.prototype,"isPrototypeOf"))}function u(t){return 0===Object.keys(t).length}function a(t){return null==t?"":t.toString()}function c(t){if(s(t)){var e=Number(t);return o(e)?e:t}return t}function f(){}function l(){ne&&ne.warn.apply(ne,arguments)}function d(){ne&&ne.error.apply(ne,arguments)}function p(t,e){return t&&ee.call(t,e)}function v(t,e,n,i){return Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!!i,configurable:!0})}function _(t,i,s){var r,o;if(s||(s=this),n(t))for(r=0;r1&&p(t,i[0]);)t=t[i.shift()];return e=i[0],"undefined"!=typeof n?void(t[e]=n):t[e]}function k(t){this.path=t,this.watchers=[],this.guid=se++}function O(t){return t}function C(t){return""}function A(t){var e=t.charCodeAt(0);if(e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57)return he;switch(e){case 91:case 93:case 46:case 34:case 39:return ue;default:return ae}}function N(t){var e=[],n=t.split(""),i=n.length-1,s=A(n[0]);return fe.init(s),_(n,function(t,n){var s=A(t),r=fe.set(s,t);r&&e.push(r),n===i&&fe.saves&&(e.push(fe.saves),fe.reset())}),e}function D(t,e){for(;e.length;)t=t[e.shift()];return t}function E(t){return N(w(t))}function I(t,n,i){var s=g(i),r=s.pop(),o=D(t,s);e(o)&&(o[r]=n)}function T(t){var e=$e.length;return $e[e]=t,'"'+e+'"'}function j(t,e){return $e[e]}function L(t){var e=t.charAt(0),n=t.slice(1);return be.test(n)?t:(n=n.indexOf('"')>-1?n.replace(le,j):n,e+"scope."+n)}function S(t){return _e.test(t)&&!de.test(t)&&0!==t.indexOf("Math.")}function P(t){return S(t)?"scope."+t:(t=(" "+t).replace(pe,T),t=t.replace(ve,L),t=t.replace(le,j))}function U(t){if(ye.test(t))return l("Avoid using unallow keyword in expression ["+t+"]"),f;try{return new Function("scope","return "+P(t)+";")}catch(e){return d("Invalid generated expression: ["+t+"]"),f}}function W(t){var e=E(t);return e.length?function(t,n){I(t,n,e)}:(d("Invalid setter expression ["+t+"]"),f)}function M(t,e){var n=t&&t.__ob__,i=n&&n.dep.guid;if(i){if(we.indexOf(i)>-1)return;we.push(i)}_(t,function(t){M(t,!1)}),e&&(we.length=0)}function V(t,e,n,s){this.vm=t,b(this,e),this.callback=n,this.context=s||this,this.depIds=[],this.newDepIds=[],this.shallowIds=[],this.depends=[],this.newDepends=[];var r=e.once,o=e.expression,h=i(o);this.getter=h?o:U(o),this.setter=!r&&e.duplex?W(o):null,this.oldVal=null,this.value=r?this.getValue():this.get()}function z(t){this.parser=t,this.scope=t.scope}function F(t,e,n,i){this.vm=t,this.el=e,this.desc=n,this.scope=i,this.parse()}function R(t){return t.prototype=Object.create(F.prototype)}function H(t){return 1===t.nodeType}function q(t){return 3===t.nodeType}function B(t){for(;t.firstChild;)t.removeChild(t.firstChild);return t}function Z(t,e){return t.getAttribute(e)||""}function G(t,e){t.removeAttribute(e)}function Q(t,e,n){return null==n||n===!1?G(t,e):void(n===!0?(t[e]=n,J(t,e)||t.setAttribute(e,"")):n!==Z(t,e)&&t.setAttribute(e,n))}function J(t,e){return t.hasAttribute(e)}function K(t,e){var n,i=t.classList;return i?i.contains(e):(n=" "+Z(t,"class")+" ",n.indexOf(" "+e+" ")>-1)}function X(t,e){var n,i=t.classList;e&&!K(t,e)&&(i?i.add(e):(n=" "+Z(t,"class")+" ",n.indexOf(" "+e+" ")===-1&&Q(t,"class",(n+e).trim())))}function Y(t,e){var n,i,s=t.classList;if(e&&K(t,e)){if(s)s.remove(e);else{for(i=" "+e+" ",n=" "+Z(t,"class")+" ";n.indexOf(i)>-1;)n=n.replace(i," ");Q(t,"class",n.trim())}t.className||G(t,"class")}}function tt(t,e,n,i){t.addEventListener(e,n,i)}function et(t,e,n,i){t.removeEventListener(e,n,i)}function nt(t){try{return new Function("scope",P(t))}catch(e){return d("Invalid generated expression: ["+t+"]"),f}}function it(t){var e,n,i=w(t),s=i.match(Ne),r=s&&s[0];return r?(n=i.substr(0,i.indexOf(r)),e="["+r.substr(1,r.length-2)+"]"):n=i,{func:n,args:e}}function st(t){var e={},n=t.trim();if(Ae.test(n)){var i=n.length;n=n.substr(1,i-2).replace(/\s/g,"");var s=n.match(Ee);_(s,function(t){var n=t.split(":"),i=n[0],s=n[1];i&&s&&(i=i.replace(De,""),e[i]=s)})}return e}function rt(t,e){var n,i=t.indexOf("."),s="";i>-1?(n=t.substr(0,i),s=t.substr(i+1,t.length)):n=t;var r=it(e),o=r.func,h=r.args;return S(o)||(o=nt(e)),{type:n,dress:s,func:o,args:h}}function ot(t){var e=[],n=t.args,i=t.expression;if(n)e=[rt(n,i)];else{var s=st(i);_(s,function(t,n){e.push(rt(n,t))})}return e}function ht(t,e){var n,i=e.split("."),s=i.indexOf("self")>-1,r=i.indexOf("stop")>-1,o=i.indexOf("one")>-1,h=i.indexOf("prevent")>-1,u=i.indexOf("capture")>-1;return 0===t.indexOf("key")&&_(i,function(t){if(Ce.test(t))return n=+t,!1}),{self:s,stop:r,prevent:h,capture:u,keyCode:n,one:o}}function ut(){this.cache={},this.funcWatchers=[],this.argsWatchers=[],F.apply(this,arguments)}function at(){F.apply(this,arguments)}function ct(t){for(var e=0;e=e&&t.call(t)},e)}function Vt(t,e){for(var n=[],i=t.options,s=0;s-1?(n=i.substr(r+1),e=i.substr(0,r)):e=i,{args:n,attr:i,directive:e,expression:s}}function Jt(t){t.__afterHook__||v(t,"__afterHook__",Z(t,"v-hook:after")),t.__beforeHook__||v(t,"__beforeHook__",Z(t,"v-hook:before"))}function Kt(t,e){var n,i,s;return function(r,o,h){var u=r.path;u===n&&o===i&&h===s||(t.apply(e,arguments),n=u,i=o,s=h)}}function Xt(t){var n=t.model,s=t.view,r=t.computed,o=t.watchAll;return H(s)?e(n)?(this.$queue=[],this.$data=n,this.$element=s,this.$regEles={},this.$directives=[],this.$context=t.context||this,this.$ob=_t(this.$data),r&>(this.$data,r),this.$afters=[],this.$hooks=t.hooks||{},this.$customs=t.customs||{},this.$unifyCb=i(o)?Kt(o,this.$context):null,void(t.lazy||this.mount())):l("model must be a type of Object: ",n):l("view must be a type of DOMElement: ",s)}function Yt(t){var n=t.context||t.model;_(t.model,function(e,s){i(e)&&(t.model[s]=e.bind(n))}),_(t.methods,function(e,i){t.model[i]=e.bind(n)}),this.__ct__=n,this.__bk__=g(t.model),this.__vm__=new Xt(t),this.$data=this.__vm__.$data,this.$els=this.__vm__.$regEles,_(t.watches,function(t,n){i(t)?this.watch(n,t,!1):e(t)&&this.watch(n,t.handler,t.deep)},this)}var te=Object.prototype,ee=te.hasOwnProperty,ne=window.console,ie=/\s/g,se=0;k.watcher=null;var re=k.prototype;re.addWatcher=function(t){this.watchers.push(t)},re.removeWatcher=function(t){this.watchers.$remove(t)},re.depend=function(){k.watcher&&k.watcher.addDepend(this)},re.beforeNotify=function(){_(this.watchers,function(t){t.beforeUpdate()})},re.notify=function(t){_(this.watchers,function(e){e.update(t,this)},this)};var oe=0,he=1,ue=2,ae=1,ce=[0,O,C,O],fe={init:function(t){this.saves="",this.state=t},set:function(t,e){var n=this.get(t),i=n.keepIdent,s=n.tobeQuote,r=n.tobeIdent;if(i)this.save(t,e);else{if(s){var o=this.saves;return this.saves="",this.change(t),o}r&&(this.save(t,e),this.change(t))}},get:function(t){var e=this.state,n=e===he&&t===he,i=(e===he||e===oe)&&t===ue,s=e===ue&&t===ue,r=(e===ue||e===oe)&&t===he;return{keepIdent:n,tobeQuote:i,keepQuote:s,tobeIdent:r}},change:function(t){this.state=t},save:function(t,e){this.saves+=ce[t](e)},reset:function(){this.saves="",this.state=oe}},le=/"(\d+)"/g,de=/^(true|false)$/,pe=/[\{,]\s*[\w\$_]+\s*:|('[^']*'|"[^"]*")|typeof /g,ve=/[^\w$\.]([A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*|\['.*?'\]|\[".*?"\])*)/g,_e=/^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*|\['.*?'\]|\[".*?"\]|\[\d+\]|\[[A-Za-z_$][\w$]*\])*$/,me="JSON.Math.parseInt.parseFloat.Date.this.true.false.null.undefined.Infinity.NaN.isNaN.isFinite.decodeURI.decodeURIComponent.encodeURI.encodeURIComponent",be=new RegExp("^("+me.replace(/\./g,"\\b|")+"\\b)"),ge="var.const.let.if.else.for.in.continue.switch.case.break.default.function.return.do.while.delete.try.catch.throw.finally.with.import.export.instanceof.yield.await",ye=new RegExp("^("+ge.replace(/\./g,"\\b|")+"\\b)"),$e=[],we=[],xe=V.prototype;xe.getScope=function(){return this.context.scope||this.vm.$data},xe.getValue=function(){var t=this.getScope();return this.getter.call(t,t)},xe.setValue=function(t){var e=this.getScope();this.setter&&this.setter.call(e,e,t)},xe.get=function(){this.beforeGet();var t=this.getValue();return this.deep&&(this.shallowIds=g(this.newDepIds),M(t,!0)),this.afterGet(),t},xe.beforeGet=function(){k.watcher=this},xe.addDepend=function(t){var e=t.guid,n=this.newDepIds;n.indexOf(e)<0&&(n.push(e),this.newDepends.push(t),this.depIds.indexOf(e)<0&&t.addWatcher(this))},xe.removeDepends=function(t){_(this.depends,function(e){t?t.call(this,e)&&e.removeWatcher(this):e.removeWatcher(this)},this)},xe.afterGet=function(){k.watcher=null,this.removeDepends(function(t){return this.newDepIds.indexOf(t.guid)<0}),this.depIds=g(this.newDepIds),this.newDepIds.length=0,this.depends=g(this.newDepends),this.newDepends.length=0},xe.beforeUpdate=function(){this.oldVal=g(this.value)},xe.update=function(t,e){var n=this.oldVal,i=this.vm.$unifyCb,s=this.value=this.get(),r=t&&t.source;if(!r||r===s||"v-for"!==this.directive){var o=this.callback;o&&n!==s&&(o.call(this.context,s,n,this.deep&&this.shallowIds.indexOf(e.guid)<0,t),r&&(t.source=null)),i&&i({action:t,path:e.path},s,n)}},xe.destroy=function(){this.value=null,this.removeDepends(),this.getter=this.setter=null,this.vm=this.callback=this.context=null};var ke=z.prototype;ke.mount=function(){var t=this.parser,e=this.watcher=new V(t.vm,t.desc,this.update,this);this.update(e.value)},ke.destroy=function(){this.watcher.destroy(),this.parser=this.scope=null},ke.update=function(){var t=this.parser;t.update.apply(t,arguments)},ke.get=function(){return this.watcher.value},ke.set=function(t){this.watcher.setValue(t)};var Oe=F.prototype;Oe.bind=function(){this.directive=new z(this),this.directive.mount()},Oe.destroy=function(){var t=this.directive;t?t.destroy():i(this._destroy)&&this._destroy(),this.vm=this.el=this.desc=this.scope=null};var Ce=/^(\d)*$/,Ae=/^\{.*\}$/,Ne=/(\(.*\))/,De=/(^'*)|('*$)|(^"*)|("*$)/g,Ee=/[^,]+:[^:]+((?=,[^:]+:)|$)/g,Ie=2e3,Te="__vonid__",je=R(ut);je.parse=function(){_(ot(this.desc),function(t){this.parseEvent(t)},this)},je.getExpDesc=function(t){return b({},this.desc,{expression:t})},je.parseEvent=function(t){var e=t.func,n=t.args,s=t.type,r=t.dress,o=r.indexOf("capture")>-1;if(i(e))return this.bindAnonymousEvent(s,r,e);if("$remove"===e)return this.bindRemoveEvent(s,r);var h=this.getExpDesc(e),u=new V(this.vm,h,function(t,e){this.off(s,e,o),this.bindEvent(s,r,t,n)},this),a=u.value;return i(a)?(this.bindEvent(s,r,a,n),void(h.once?u.destroy():this.funcWatchers.push(u))):(u.destroy(),l("Directive ["+this.desc.attr+"] must be a type of Function"))},je.bindAnonymousEvent=function(t,e,n){var i=this.scope||this.vm.$data;this.bindEvent(t,e,n.bind(i,i))},je.bindRemoveEvent=function(t,e){var n=this.scope;if(!n)return l("The specify event $remove must be used in v-for scope");var i=n.__alias__;this.bindEvent(t,e,function(){n.__viterator__.$remove(n[i])},"["+i+"]")},je.bindEvent=function(t,e,n,i){var s=ht(t,e),r=s.self,o=s.stop,h=s.prevent,u=s.capture,a=s.keyCode,c=s.one;v(this.scope||this.vm.$data,"$event","__e__");var f=[];if(i){var l=this.getExpDesc(i),d=new V(this.vm,l,function(t){f=t},this);f=d.value,l.once?d.destroy():this.argsWatchers.push(d)}var p,m=this.el,b=function(t){r&&t.target!==m||a&&a!==t.keyCode||(f.length?_(f,function(e,n){("__e__"===e||e instanceof Event)&&(f[n]=t)}):f.push(t),h&&t.preventDefault(),o&&t.stopPropagation(),n.apply(this,f))},g=Ie++,y=this;c?(p=function(e){b(e),y.off(t,p,u)},p[Te]=g):(n[Te]=g,p=b),this.cache[g]=p,this.on(t,p,u)},je.on=function(t,e,n){tt(this.el,t,e,n)},je.off=function(t,e,n){var i=this.cache,s=e[Te],r=i[s];r&&(et(this.el,t,r,n),delete i[s])},je._destroy=function(){m(this.cache),_(this.funcWatchers,function(t){t.destroy()}),_(this.argsWatchers,function(t){t.destroy()})};var Le=R(at);Le.parse=function(){this.scope?l("v-el can not be used inside v-for! Consider use v-custom to handle v-for element."):this.vm.$regEles[this.desc.expression]=this.el};var Se="__proto__"in{},Pe=Array.prototype,Ue=Object.create(Pe);_(["pop","push","sort","shift","splice","unshift","reverse"],function(t){var e=Pe[t];v(Ue,t,function(){for(var n=arguments,i=[],s=this.__ob__,r=0;r=this.length&&(t=this.length),this.splice(t,1,e)[0]}),v(Pe,"$remove",function(t){var e=this.indexOf(t);if(e>-1)return this.splice(e,1)});var We=Object.getOwnPropertyNames(Ue),Me="__vfor__",Ve="__vforid__",ze=/(.*) (?:in|of) (.*)/,Fe="push|pop|shift|unshift|splice".split("|"),Re=R(wt);Re.parse=function(){var t=this.el,e=this.desc,n=t.parentNode,i=e.expression,s=i.match(ze);if(!s)return l('The format of v-for must be like "item in/of items"!');if(1!==n.nodeType)return l("v-for cannot use in the root element!");if(J(t,"v-if"))return l("Do not use v-if and v-for on the same element! Consider filtering the source Array instead.");var r=s[1],o=s[2];this.length=0,this.scopes=[],this.init=!0,this.alias=r,this.partly=!1,this.partlyArgs=[],this.$parent=n,this.end=t.nextSibling,this.start=t.previousSibling,this.bodyDirs=t.__dirs__,this.tpl=t.cloneNode(!0),this.hooks=yt(this.vm,t),this.isOption="OPTION"===t.tagName&&"SELECT"===n.tagName,e.expression=o,this.bind(),this.updateModel()},Re.updateModel=function(){if(this.isOption){var t=this.$parent.__vmodel__;t&&t.forceUpdate()}},Re.hook=function(t,e,n){var s=this.hooks[t];i(s)&&(s.call(this.vm.$context,e,n,e[Ve]),e=null)},Re.update=function(t,e,n,i){this.length=t&&t.length,this.init?(this.$parent.replaceChild(this.buildList(t),this.el),this.el=null,this.init=!1):i&&Fe.indexOf(i.method)>-1?(this.partly=!0,this.updatePartly(t,i),this.partly=!1):(this.recompileList(t),this.updateModel())},Re.updatePartly=function(t,e){var n=[],i=e.args,s=e.method,r=this.scopes;switch(this[s].call(this,t,i),s){case"pop":case"shift":break;case"push":case"unshift":n=this.partlyArgs;break;case"splice":n=i.slice(0,2),Array.prototype.push.apply(n,this.partlyArgs)}r[s].apply(r,n),this.partlyArgs.length=0,_(r,function(t,e){t.$index=e})},Re.recompileList=function(t){for(var e=this,n=0,i=this.$parent,s=i.childNodes,r=0;r1&&n.block(this.el),v(a,Me,u),v(a,Ve,$t()),n.compile(a,!0,f,this.desc.once),r.appendChild(a),this.hook("after",a,h)},this),r},Re.getChilds=function(){for(var t=this,e=[],n=this.$parent.childNodes,i=0;i=n&&e0,Ye={bind:function(){function t(t){i&&(t=t.trim());var e=zt(t,r);o?Mt(function(){n.onDebounce=!0,h.set(e)},c(o)):h.set(e)}var e,n=this,i=this.trim,s=this.lazy,r=this.number,o=this.debounce,h=this.directive;this.on("compositionstart",function(){e=!0}),this.on("compositionend",function(){e=!1,s||t(this.value)}),this.on("input",function(){e||s||t(this.value)}),this.on("blur",function(){t(this.value)}),this.on("change",function(){t(this.value)}),Xe&&(this.on("cut",function(){t(this.value)}),this.on("keyup",function(e){var n=e.keyCode;8!==n&&46!==n||t(this.value)}))},update:function(t){var e=this.el,n=a(t);e.value===n||this.onDebounce||(e.value=n)}},tn={bind:function(){var t=this.number,e=this.directive;this.on("change",function(){e.set(zt(this.value,t))})},update:function(t){var e=this.el;e.checked=e.value===a(t)}},en={bind:function(){var t=this.multi,e=this.number,n=this.directive;this.on("change",function(){var i=t?Vt(this,e):zt(this.value,e);n.set(i)}),this.vm.after(this.forceUpdate,this)},update:function(t){var e=this.el,i=this.multi,s=this.desc.expression;if(e.selectedIndex=-1,i&&!n(t))return l(" has no multiple propperty");for(var r=e.options,o=0;o-1:u===a(t)}},forceUpdate:function(){this.update(this.directive.get())}},nn={bind:function(){var t=this.number,e=this.directive;this.on("change",function(){var i=e.get(),s=this.checked;if(r(i))e.set(s);else if(n(i)){var o=zt(this.value,t),h=Ft(o,i);s&&h===-1?i.push(o):h>-1&&i.splice(h,1)}})},update:function(t){var e=this.el,i=zt(e.value,this.number);return n(t)||r(t)?void(e.checked=r(t)?t:Ft(i,t)>-1):l("Checkbox v-model value must be a type of Boolean or Array")}},sn=["input","select","textarea"],rn=R(Rt);rn.parse=function(){var t=this.el,e=this.desc,n=t.tagName.toLowerCase(),i="input"===n?Z(t,"type"):n;return sn.indexOf(n)<0?l("v-model only for using in "+sn.join(", ")):S(e.expression)?(e.duplex=!0,void this.bindDuplex(i)):l("v-model directive value can be use by static expression")},rn.bindDuplex=function(t){var e,n=this.el;switch(t){case"text":case"password":case"textarea":e=Ye,this.trim=J(n,"trim"),this.lazy=J(n,"lazy"),this.debounce=Z(n,"debounce");break;case"radio":e=tn;break;case"checkbox":e=nn;break;case"select":e=en,v(n,"__vmodel__",this),this.multi=J(n,"multiple"),this.forceUpdate=en.forceUpdate.bind(this)}return e?(this.number=J(n,"number"),this.update=e.update.bind(this),this.bind(),void(this.desc.once||e.bind.call(this))):l("Do not use incorrect form-type with v-model: ",n)},rn.on=function(t,e){tt(this.el,t,e,!1)};var on=R(Ht);on.parse=function(){var t=this.desc,e=this.vm.$customs[t.args];return i(e)?(this.update=e,void this.bind()):l("Custom directive ["+t.attr+"] must define with a refresh function!")};var hn={von:ut,vel:at,vif:Ct,vfor:wt,vtext:At,vhtml:Nt,vshow:It,vbind:Wt,vmodel:Rt,vcustom:Ht},un=/\n/g,an=/\{\{(.+?)\}\}/g,cn=/(\{\{.*\}\})/,fn=["velse","vpre","vcloak","vonce","vhook"],ln=Xt.prototype;ln.mount=function(){this.$done=!1,this.$fragment=$(this.$element),this.compile(this.$fragment,!0)},ln.compile=function(t,e,n,i){var s=this,r=t.childNodes,o=!!i||Bt(t);e&&Gt(t)&&this.$queue.push([t,n]),v(t,"__vonce__",o);for(var h=0;h1&&o!==h.length-1){var l=h.splice(o,1)[0];h.push(l),l=null}i&&(v(e,"__dirs__",h.length),h=[i],i=null),_(h,function(t){this.parse(e,t,n)},this)}else q(e)&&this.parseText(e,n)},ln.parse=function(t,e,n){var i=t.__vonce__,s=Qt(e),r=s.directive,o="v"+r.substr(2),h=hn[o];if(G(t,s.attr),!(fn.indexOf(o)>-1))if(h){s.once=i;var u=new h(this,t,s,n);i?u.destroy():n||this.$directives.push(u)}else l("["+r+"] is an unknown directive!")},ln.parseText=function(t,e){var n=[],i={},s=t.parentNode&&t.parentNode.__vonce__,r=t.textContent.trim().replace(un,""),o=r.split(an),h=r.match(an);_(o,function(t){h.indexOf("{{"+t+"}}")>-1?n.push("("+t+")"):t&&n.push('"'+t+'"')}),i.once=s,i.expression=n.join("+");var u=new hn.vtext(this,t,i,e);s?u.destroy():e||this.$directives.push(u)},ln.block=function(t){_(this.$queue,function(e){if(t===e[0])return null})},ln.after=function(t,e){this.$afters.push([t,e])},ln.completed=function(){0!==this.$queue.length||this.$done||(this.$done=!0,this.$element.appendChild(this.$fragment),_(this.$afters,function(t){return t[0].call(t[1]),null}))},ln.destroy=function(){this.$data=null,B(this.$element),_(this.$directives,function(t){return t.destroy(),null})};var dn=Yt.prototype;return dn.mount=function(){this.__vm__.mount()},dn.get=function(t){var e=this.$data;return s(t)?x(e,t):e},dn.getCopy=function(t){return g(this.get(t))},dn.set=function(t,n){var i=this.$data;s(t)?x(i,t,n):e(t)&&_(t,function(t,e){x(i,e,t)})},dn.reset=function(t){var e=this.$data,i=g(this.__bk__);s(t)?e[t]=i[t]:n(t)?_(t,function(t){e[t]=i[t]}):_(e,function(t,n){e[n]=i[n]})},dn.watch=function(t,e,n){return new V(this,{deep:n,expression:t},e.bind(this.__ct__))},dn.destroy=function(){this.__vm__.destroy(),this.__vm__=this.__ct__=this.__bk__=this.$data=this.$els=null},Yt}); \ No newline at end of file diff --git a/dist/sugar.js b/dist/sugar.js index 8e466a98..91fa3a4c 100644 --- a/dist/sugar.js +++ b/dist/sugar.js @@ -1,7 +1,7 @@ /*! - * sugar.js v1.4.0 (c) 2017 TANG + * sugar.js v1.4.1 (c) 2017 TANG * Released under the MIT license - * Sat Oct 14 2017 08:39:42 GMT+0800 (CST) + * Sat Nov 04 2017 11:30:27 GMT+0800 (CST) */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : @@ -1967,6 +1967,20 @@ var regQuotes = /(^'*)|('*$)|(^"*)|("*$)/g var regJsonFormat = /[^,]+:[^:]+((?=,[^:]+:)|$)/g + /** + * 生成匿名事件函数 + * @param {String} expression + * @return {Function} + */ + function createAnonymous (expression) { + try { + return new Function('scope', addScope(expression)) + } catch (e) { + error('Invalid generated expression: [' + expression + ']') + return noop + } + } + /** * 分解字符串函数参数 * @param {String} funcString @@ -2035,6 +2049,11 @@ var info = stringToParams(expression) var func = info.func, args = info.args + // 尝试匿名函数表达式 + if (!isNormal(func)) { + func = createAnonymous(expression) + } + return { type: type, dress: dress, func: func, args: args } } @@ -2049,7 +2068,7 @@ var expression = desc.expression if (args) { - binds.push(formatEvent(args, expression)) + binds = [formatEvent(args, expression)] } else { var json = convertJson(expression) each(json, function (value, key) { @@ -2141,6 +2160,10 @@ var dress = bind.dress var capture = dress.indexOf('capture') > -1 + if (isFunc(func)) { + return this.bindAnonymousEvent(type, dress, func) + } + if (func === '$remove') { return this.bindRemoveEvent(type, dress) } @@ -2168,7 +2191,18 @@ } /** - * 隐性绑定删除($remove) vfor 选项事件 + * 绑定匿名事件 + * @param {String} type [事件类型] + * @param {String} dress [事件修饰符] + * @param {Function} func [匿名事件函数] + */ + von.bindAnonymousEvent = function (type, dress, func) { + var scope = this.scope || this.vm.$data + this.bindEvent(type, dress, func.bind(scope, scope)) + } + + /** + * 匿名绑定删除($remove) vfor 选项事件 * @param {String} type [事件类型] * @param {String} dress [事件修饰符] */ diff --git a/dist/sugar.min.js b/dist/sugar.min.js index ab5edf5a..e414e1af 100644 --- a/dist/sugar.min.js +++ b/dist/sugar.min.js @@ -1,7 +1,7 @@ /*! - * sugar.js v1.4.0 (c) 2017 TANG + * sugar.js v1.4.1 (c) 2017 TANG * Released under the MIT license - * Sat Oct 14 2017 08:39:44 GMT+0800 (CST) + * Sat Nov 04 2017 11:30:29 GMT+0800 (CST) */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Sugar=e()}(this,function(){"use strict";function t(t,e){return typeof t===e}function e(t){return"[object Object]"===_e.toString.call(t)}function n(t){return Array.isArray(t)}function i(e){return t(e,"function")}function s(e){return t(e,"string")}function r(e){return t(e,"boolean")}function o(e){return t(e,"number")&&!isNaN(e)}function a(t){return!(!t||!e(t)||t.nodeType||t===t.window)&&!(t.constructor&&!me.call(t.constructor.prototype,"isPrototypeOf"))}function h(t){return 0===Object.keys(t).length}function u(t){return null==t?"":t.toString()}function c(t){if(s(t)){var e=Number(t);return o(e)?e:t}return t}function l(){}function f(){ge&&ge.warn.apply(ge,arguments)}function d(){ge&&ge.error.apply(ge,arguments)}function p(t,e){return t&&me.call(t,e)}function v(t,e,n,i){return Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!!i,configurable:!0})}function _(t,i,s){var r,o;if(s||(s=this),n(t))for(r=0;r1&&p(t,i[0]);)t=t[i.shift()];return e=i[0],"undefined"!=typeof n?void(t[e]=n):t[e]}function k(t,e,n,i,s,r){var o=r||this,a=new XMLHttpRequest;return a.open(n,e,!0),a.onreadystatechange=function(){var e=a.status,n=null,i=null;if(4===a.readyState){var r=a.responseText;if("text"!==t)try{r=JSON.parse(r)}catch(t){}200===e?n={success:!0,result:r}:i={result:null,success:!1,status:e},s.call(o,i,n)}},i&&a.setRequestHeader("Content-type","application/x-www-form-urlencoded"),a.send(i),a}function O(t,e,n,s,r){var o=[];return i(e)&&(r=s,s=n,n=e,e=null),_(e,function(t,e){o.push(e+"="+encodeURIComponent(t))}),o.length&&(t=t+"?"+o.join("&")),k(r||"json",t,"GET",null,n,s)}function A(t,e,n,i){return k("json",t,"POST",e?JSON.stringify(e):null,n,i)}function N(t,e,n,i){return O(t,e,n,i,"text")}function D(t,e){return i(e)&&$e.test(Ce.call(e))?function(){this.Super=t,e.apply(this,arguments)}:e}function E(){}function S(t){return t.charAt(0).toUpperCase()+t.substr(1)}function j(t){var e=null;return _(xe,function(n){if((n.__rd__&&n.__rd__.name)===t)return e=n,!1}),e}function I(t,e,n,i){return{type:t,from:e,to:null,count:0,name:n,param:i,method:"on"+S(n),returns:null}}function T(t,e){var n=t[e.method];if(i(n))return e.to=t,++e.count,n.call(t,e)}function L(t,e,n){i(e)&&e.call(n,t)}function P(t,e,n,i,s){for(var r=I("fire",t,e,n),o=t.getParent();o;){var a=T(o,r);if(a===!1)return void L(r,i,s);r.from=o,o=o.getParent()}L(r,i,s)}function R(t,e,n,i,s){for(var r=I("broadcast",t,e,n),o=t.getChilds(!0).slice(0);o.length;){var a=o.shift(),h=T(a,r);h!==!1&&(r.from=a,Array.prototype.push.apply(o,a.getChilds(!0)))}L(r,i,s)}function q(t,n,i,r,o,a){if(s(n)){var h,u=n.split("."),c=j(u.shift());u.length?_(u,function(t){return h=c.getChild(t),c=h,null}):h=c,c=null,e(h)&&(n=h)}var l=I("notify",t,i,r);return e(n)?(T(n,l),void L(l,o,a)):(L(l,o,a),f("Component: ["+n+"] is not exist!"))}function M(t,n,i,s){var r=I("globalCast","__core__",t,n);_(xe,function(t,n){e(t)&&"0"!==n&&T(t,r)}),L(r,i,s)}function U(t){this.path=t,this.watchers=[],this.guid=Se++}function z(t){return t}function H(t){return""}function W(t){var e=t.charCodeAt(0);if(e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57)return Te;switch(e){case 91:case 93:case 46:case 34:case 39:return Le;default:return Pe}}function F(t){var e=[],n=t.split(""),i=n.length-1,s=W(n[0]);return qe.init(s),_(n,function(t,n){var s=W(t),r=qe.set(s,t);r&&e.push(r),n===i&&qe.saves&&(e.push(qe.saves),qe.reset())}),e}function B(t,e){for(;e.length;)t=t[e.shift()];return t}function V(t){return F($(t))}function G(t,n,i){var s=b(i),r=s.pop(),o=B(t,s);e(o)&&(o[r]=n)}function Z(t){var e=Ze.length;return Ze[e]=t,'"'+e+'"'}function J(t,e){return Ze[e]}function Q(t){var e=t.charAt(0),n=t.slice(1);return Be.test(n)?t:(n=n.indexOf('"')>-1?n.replace(Me,J):n,e+"scope."+n)}function X(t){return We.test(t)&&!Ue.test(t)&&0!==t.indexOf("Math.")}function K(t){return X(t)?"scope."+t:(t=(" "+t).replace(ze,Z),t=t.replace(He,Q),t=t.replace(Me,J))}function Y(t){if(Ge.test(t))return f("Avoid using unallow keyword in expression ["+t+"]"),l;try{return new Function("scope","return "+K(t)+";")}catch(e){return d("Invalid generated expression: ["+t+"]"),l}}function tt(t){var e=V(t);return e.length?function(t,n){G(t,n,e)}:(d("Invalid setter expression ["+t+"]"),l)}function et(t,e){var n=t&&t.__ob__,i=n&&n.dep.guid;if(i){if(Je.indexOf(i)>-1)return;Je.push(i)}_(t,function(t){et(t,!1)}),e&&(Je.length=0)}function nt(t,e,n,s){this.vm=t,g(this,e),this.callback=n,this.context=s||this,this.depIds=[],this.newDepIds=[],this.shallowIds=[],this.depends=[],this.newDepends=[];var r=e.once,o=e.expression,a=i(o);this.getter=a?o:Y(o),this.setter=!r&&e.duplex?tt(o):null,this.oldVal=null,this.value=r?this.getValue():this.get()}function it(t){this.parser=t,this.scope=t.scope}function st(t,e,n,i){this.vm=t,this.el=e,this.desc=n,this.scope=i,this.parse()}function rt(t){return t.prototype=Object.create(st.prototype)}function ot(t){return 1===t.nodeType}function at(t){return 3===t.nodeType}function ht(t){for(;t.firstChild;)t.removeChild(t.firstChild);return t}function ut(t,e){return t.getAttribute(e)||""}function ct(t,e){t.removeAttribute(e)}function lt(t,e,n){return null==n||n===!1?ct(t,e):void(n===!0?(t[e]=n,ft(t,e)||t.setAttribute(e,"")):n!==ut(t,e)&&t.setAttribute(e,n))}function ft(t,e){return t.hasAttribute(e)}function dt(t,e){var n,i=t.classList;return i?i.contains(e):(n=" "+ut(t,"class")+" ",n.indexOf(" "+e+" ")>-1)}function pt(t,e){var n,i=t.classList;e&&!dt(t,e)&&(i?i.add(e):(n=" "+ut(t,"class")+" ",n.indexOf(" "+e+" ")===-1&<(t,"class",(n+e).trim())))}function vt(t,e){var n,i,s=t.classList;if(e&&dt(t,e)){if(s)s.remove(e);else{for(i=" "+e+" ",n=" "+ut(t,"class")+" ";n.indexOf(i)>-1;)n=n.replace(i," ");lt(t,"class",n.trim())}t.className||ct(t,"class")}}function _t(t,e,n,i){t.addEventListener(e,n,i)}function mt(t,e,n,i){t.removeEventListener(e,n,i)}function gt(){this.empty=ht,this.getAttr=ut,this.removeAttr=ct,this.setAttr=lt,this.hasAttr=ft,this.hasClass=dt,this.addClass=pt,this.removeClass=vt,this.addEvent=_t,this.removeEvent=mt}function bt(t){var e,n,i=$(t),s=i.match(en),r=s&&s[0];return r?(n=i.substr(0,i.indexOf(r)),e="["+r.substr(1,r.length-2)+"]"):n=i,{func:n,args:e}}function yt(t){var e={},n=t.trim();if(tn.test(n)){var i=n.length;n=n.substr(1,i-2).replace(/\s/g,"");var s=n.match(sn);_(s,function(t){var n=t.split(":"),i=n[0],s=n[1];i&&s&&(i=i.replace(nn,""),e[i]=s)})}return e}function wt(t,e){var n,i=t.indexOf("."),s="";i>-1?(n=t.substr(0,i),s=t.substr(i+1,t.length)):n=t;var r=bt(e),o=r.func,a=r.args;return{type:n,dress:s,func:o,args:a}}function xt(t){var e=[],n=t.args,i=t.expression;if(n)e.push(wt(n,i));else{var s=yt(i);_(s,function(t,n){e.push(wt(n,t))})}return e}function $t(t,e){var n,i=e.split("."),s=i.indexOf("self")>-1,r=i.indexOf("stop")>-1,o=i.indexOf("one")>-1,a=i.indexOf("prevent")>-1,h=i.indexOf("capture")>-1;return 0===t.indexOf("key")&&_(i,function(t){if(Ye.test(t))return n=+t,!1}),{self:s,stop:r,prevent:a,capture:h,keyCode:n,one:o}}function Ct(){this.cache={},this.funcWatchers=[],this.argsWatchers=[],st.apply(this,arguments)}function kt(){st.apply(this,arguments)}function Ot(t){for(var e=0;e=e&&t.call(t)},e)}function ne(t,e){for(var n=[],i=t.options,s=0;s-1?(n=i.substr(r+1),e=i.substr(0,r)):e=i,{args:n,attr:i,directive:e,expression:s}}function fe(t){t.__afterHook__||v(t,"__afterHook__",ut(t,"v-hook:after")),t.__beforeHook__||v(t,"__beforeHook__",ut(t,"v-hook:before"))}function de(t,e){var n,i,s;return function(r,o,a){var h=r.path;h===n&&o===i&&a===s||(t.apply(e,arguments),n=h,i=o,s=a)}}function pe(t){var n=t.model,s=t.view,r=t.computed,o=t.watchAll;return ot(s)?e(n)?(this.$queue=[],this.$data=n,this.$element=s,this.$regEles={},this.$directives=[],this.$context=t.context||this,this.$ob=jt(this.$data),r&&Lt(this.$data,r),this.$afters=[],this.$hooks=t.hooks||{},this.$customs=t.customs||{},this.$unifyCb=i(o)?de(o,this.$context):null,void(t.lazy||this.mount())):f("model must be a type of Object: ",n):f("view must be a type of DOMElement: ",s)}function ve(t){var n=t.context||t.model;_(t.model,function(e,s){i(e)&&(t.model[s]=e.bind(n))}),_(t.methods,function(e,i){t.model[i]=e.bind(n)}),this.__ct__=n,this.__bk__=b(t.model),this.__vm__=new pe(t),this.$data=this.__vm__.$data,this.$els=this.__vm__.$regEles,_(t.watches,function(t,n){i(t)?this.watch(n,t,!1):e(t)&&this.watch(n,t.handler,t.deep)},this)}var _e=Object.prototype,me=_e.hasOwnProperty,ge=window.console,be=/\s/g,ye=Object.create(null);ye.def=v,ye.each=_,ye.copy=b,ye.config=C,ye.extend=g,ye.hasOwn=p,ye.isFunc=i,ye.isBool=r,ye.isArray=n,ye.isObject=e,ye.isNumber=o,ye.isString=s,ye.isEmptyObject=h;var we=Object.create(null);we.get=O,we.post=A,we.load=N;var xe={id:1,length:0},$e=/\b\.Super\b/,Ce=Function.prototype.toString;E.extend=function(t){function e(t,e,n){var r=s[t];i(r)&&r.call(this,g(!0,n,e))}function n(){}var s=this.prototype,r=n.prototype=Object.create(s);return _(t,function(t,n){r[n]=D(e,t)}),t=null,n.extend=this.extend,r.constructor=n,n};var ke={fire:P,broadcast:R,notify:q,globalCast:M},Oe="map",Ae="array",Ne=E.extend({__rd__:{},create:function(t,e,n){if(!s(t))return f("Module name ["+t+"] must be a type of String");if(!i(e))return f("Module Class ["+e+"] must be a type of Component");var r=this.__rd__;if(p(r,Ae)||(r[Ae]=[],r[Oe]={}),r[Oe][t])return f("Module ["+t+"] is already exists!");var o=new e(n),a={name:t,id:xe.id++,pid:r.id||0};return o.__rd__=a,xe[a.id]=o,xe.length++,r[Ae].push(o),r[Oe][t]=o,i(o.init)&&o.init(n,this),o},getParent:function(){var t=this.__rd__,e=t&&t.pid;return xe[e]||null},getChild:function(t){var e=this.__rd__;return e&&e[Oe]&&e[Oe][t]||null},getChilds:function(t){var e=this.__rd__;return t=r(t)&&t,t?e[Ae]||[]:e[Oe]||{}},_removeChild:function(t){for(var e=this.__rd__,n=e[Oe]||{},i=e[Ae]||[],s=n[t],r=0,o=i.length;r-1;if("$remove"===e)return this.bindRemoveEvent(s,r);var a=this.getExpDesc(e),h=new nt(this.vm,a,function(t,e){this.off(s,e,o),this.bindEvent(s,r,t,n)},this),u=h.value;return i(u)?(this.bindEvent(s,r,u,n),void(a.once?h.destroy():this.funcWatchers.push(h))):(h.destroy(),f("Directive ["+this.desc.attr+"] must be a type of Function"))},an.bindRemoveEvent=function(t,e){var n=this.scope;if(!n)return f("The specify event $remove must be used in v-for scope");var i=n.__alias__;this.bindEvent(t,e,function(){n.__viterator__.$remove(n[i])},"["+i+"]")},an.bindEvent=function(t,e,n,i){var s=$t(t,e),r=s.self,o=s.stop,a=s.prevent,h=s.capture,u=s.keyCode,c=s.one;v(this.scope||this.vm.$data,"$event","__e__");var l=[];if(i){var f=this.getExpDesc(i),d=new nt(this.vm,f,function(t){l=t},this);l=d.value,f.once?d.destroy():this.argsWatchers.push(d)}var p,m=this.el,g=function(t){r&&t.target!==m||u&&u!==t.keyCode||(l.length?_(l,function(e,n){("__e__"===e||e instanceof Event)&&(l[n]=t)}):l.push(t),a&&t.preventDefault(),o&&t.stopPropagation(),n.apply(this,l))},b=rn++,y=this;c?(p=function(e){g(e),y.off(t,p,h)},p[on]=b):(n[on]=b,p=g),this.cache[b]=p,this.on(t,p,h)},an.on=function(t,e,n){_t(this.el,t,e,n)},an.off=function(t,e,n){var i=this.cache,s=e[on],r=i[s];r&&(mt(this.el,t,r,n),delete i[s])},an._destroy=function(){m(this.cache),_(this.funcWatchers,function(t){t.destroy()}),_(this.argsWatchers,function(t){t.destroy()})};var hn=rt(kt);hn.parse=function(){this.scope?f("v-el can not be used inside v-for! Consider use v-custom to handle v-for element."):this.vm.$regEles[this.desc.expression]=this.el};var un="__proto__"in{},cn=Array.prototype,ln=Object.create(cn);_(["pop","push","sort","shift","splice","unshift","reverse"],function(t){var e=cn[t];v(ln,t,function(){for(var n=arguments,i=[],s=this.__ob__,r=0;r=this.length&&(t=this.length),this.splice(t,1,e)[0]}),v(cn,"$remove",function(t){var e=this.indexOf(t);if(e>-1)return this.splice(e,1)});var fn=Object.getOwnPropertyNames(ln),dn="__vfor__",pn="__vforid__",vn=/(.*) (?:in|of) (.*)/,_n="push|pop|shift|unshift|splice".split("|"),mn=rt(qt);mn.parse=function(){var t=this.el,e=this.desc,n=t.parentNode,i=e.expression,s=i.match(vn);if(!s)return f('The format of v-for must be like "item in/of items"!');if(1!==n.nodeType)return f("v-for cannot use in the root element!");if(ft(t,"v-if"))return f("Do not use v-if and v-for on the same element! Consider filtering the source Array instead.");var r=s[1],o=s[2];this.length=0,this.scopes=[],this.init=!0,this.alias=r,this.partly=!1,this.partlyArgs=[],this.$parent=n,this.end=t.nextSibling,this.start=t.previousSibling,this.bodyDirs=t.__dirs__,this.tpl=t.cloneNode(!0),this.hooks=Pt(this.vm,t),this.isOption="OPTION"===t.tagName&&"SELECT"===n.tagName,e.expression=o,this.bind(),this.updateModel()},mn.updateModel=function(){if(this.isOption){var t=this.$parent.__vmodel__;t&&t.forceUpdate()}},mn.hook=function(t,e,n){var s=this.hooks[t];i(s)&&(s.call(this.vm.$context,e,n,e[pn]),e=null)},mn.update=function(t,e,n,i){this.length=t&&t.length,this.init?(this.$parent.replaceChild(this.buildList(t),this.el),this.el=null,this.init=!1):i&&_n.indexOf(i.method)>-1?(this.partly=!0,this.updatePartly(t,i),this.partly=!1):(this.recompileList(t),this.updateModel())},mn.updatePartly=function(t,e){var n=[],i=e.args,s=e.method,r=this.scopes;switch(this[s].call(this,t,i),s){case"pop":case"shift":break;case"push":case"unshift":n=this.partlyArgs;break;case"splice":n=i.slice(0,2),Array.prototype.push.apply(n,this.partlyArgs)}r[s].apply(r,n),this.partlyArgs.length=0,_(r,function(t,e){t.$index=e})},mn.recompileList=function(t){for(var e=this,n=0,i=this.$parent,s=i.childNodes,r=0;r1&&n.block(this.el),v(u,dn,h),v(u,pn,Rt()),n.compile(u,!0,l,this.desc.once),r.appendChild(u),this.hook("after",u,a)},this),r},mn.getChilds=function(){for(var t=this,e=[],n=this.$parent.childNodes,i=0;i=n&&e0,An={bind:function(){function t(t){i&&(t=t.trim());var e=ie(t,r);o?ee(function(){n.onDebounce=!0,a.set(e)},c(o)):a.set(e)}var e,n=this,i=this.trim,s=this.lazy,r=this.number,o=this.debounce,a=this.directive;this.on("compositionstart",function(){e=!0}),this.on("compositionend",function(){e=!1,s||t(this.value)}),this.on("input",function(){e||s||t(this.value)}),this.on("blur",function(){t(this.value)}),this.on("change",function(){t(this.value)}),On&&(this.on("cut",function(){t(this.value)}),this.on("keyup",function(e){var n=e.keyCode;8!==n&&46!==n||t(this.value)}))},update:function(t){var e=this.el,n=u(t);e.value===n||this.onDebounce||(e.value=n)}},Nn={bind:function(){var t=this.number,e=this.directive;this.on("change",function(){e.set(ie(this.value,t))})},update:function(t){var e=this.el;e.checked=e.value===u(t)}},Dn={bind:function(){var t=this.multi,e=this.number,n=this.directive;this.on("change",function(){var i=t?ne(this,e):ie(this.value,e);n.set(i)}),this.vm.after(this.forceUpdate,this)},update:function(t){var e=this.el,i=this.multi,s=this.desc.expression;if(e.selectedIndex=-1,i&&!n(t))return f(" has no multiple propperty");for(var r=e.options,o=0;o-1:h===u(t)}},forceUpdate:function(){this.update(this.directive.get())}},En={bind:function(){var t=this.number,e=this.directive;this.on("change",function(){var i=e.get(),s=this.checked;if(r(i))e.set(s);else if(n(i)){var o=ie(this.value,t),a=se(o,i);s&&a===-1?i.push(o):a>-1&&i.splice(a,1)}})},update:function(t){var e=this.el,i=ie(e.value,this.number);return n(t)||r(t)?void(e.checked=r(t)?t:se(i,t)>-1):f("Checkbox v-model value must be a type of Boolean or Array")}},Sn=["input","select","textarea"],jn=rt(re);jn.parse=function(){var t=this.el,e=this.desc,n=t.tagName.toLowerCase(),i="input"===n?ut(t,"type"):n;return Sn.indexOf(n)<0?f("v-model only for using in "+Sn.join(", ")):X(e.expression)?(e.duplex=!0,void this.bindDuplex(i)):f("v-model directive value can be use by static expression")},jn.bindDuplex=function(t){var e,n=this.el;switch(t){case"text":case"password":case"textarea":e=An,this.trim=ft(n,"trim"),this.lazy=ft(n,"lazy"),this.debounce=ut(n,"debounce");break;case"radio":e=Nn;break;case"checkbox":e=En;break;case"select":e=Dn,v(n,"__vmodel__",this),this.multi=ft(n,"multiple"),this.forceUpdate=Dn.forceUpdate.bind(this)}return e?(this.number=ft(n,"number"),this.update=e.update.bind(this),this.bind(),void(this.desc.once||e.bind.call(this))):f("Do not use incorrect form-type with v-model: ",n)},jn.on=function(t,e){_t(this.el,t,e,!1)};var In=rt(oe);In.parse=function(){var t=this.desc,e=this.vm.$customs[t.args];return i(e)?(this.update=e,void this.bind()):f("Custom directive ["+t.attr+"] must define with a refresh function!")};var Tn={von:Ct,vel:kt,vif:Ht,vfor:qt,vtext:Wt,vhtml:Ft,vshow:Gt,vbind:te,vmodel:re,vcustom:oe},Ln=/\n/g,Pn=/\{\{(.+?)\}\}/g,Rn=/(\{\{.*\}\})/,qn=["velse","vpre","vcloak","vonce","vhook"],Mn=pe.prototype;Mn.mount=function(){this.$done=!1,this.$fragment=x(this.$element),this.compile(this.$fragment,!0)},Mn.compile=function(t,e,n,i){var s=this,r=t.childNodes,o=!!i||he(t);e&&ce(t)&&this.$queue.push([t,n]),v(t,"__vonce__",o);for(var a=0;a1&&o!==a.length-1){var f=a.splice(o,1)[0];a.push(f),f=null}i&&(v(e,"__dirs__",a.length),a=[i],i=null),_(a,function(t){this.parse(e,t,n)},this)}else at(e)&&this.parseText(e,n)},Mn.parse=function(t,e,n){var i=t.__vonce__,s=le(e),r=s.directive,o="v"+r.substr(2),a=Tn[o];if(ct(t,s.attr),!(qn.indexOf(o)>-1))if(a){s.once=i;var h=new a(this,t,s,n);i?h.destroy():n||this.$directives.push(h)}else f("["+r+"] is an unknown directive!")},Mn.parseText=function(t,e){var n=[],i={},s=t.parentNode&&t.parentNode.__vonce__,r=t.textContent.trim().replace(Ln,""),o=r.split(Pn),a=r.match(Pn);_(o,function(t){a.indexOf("{{"+t+"}}")>-1?n.push("("+t+")"):t&&n.push('"'+t+'"')}),i.once=s,i.expression=n.join("+");var h=new Tn.vtext(this,t,i,e);s?h.destroy():e||this.$directives.push(h)},Mn.block=function(t){_(this.$queue,function(e){if(t===e[0])return null})},Mn.after=function(t,e){this.$afters.push([t,e])},Mn.completed=function(){0!==this.$queue.length||this.$done||(this.$done=!0,this.$element.appendChild(this.$fragment),_(this.$afters,function(t){return t[0].call(t[1]),null}))},Mn.destroy=function(){this.$data=null,ht(this.$element),_(this.$directives,function(t){return t.destroy(),null})};var Un=ve.prototype; -Un.mount=function(){this.__vm__.mount()},Un.get=function(t){var e=this.$data;return s(t)?C(e,t):e},Un.getCopy=function(t){return b(this.get(t))},Un.set=function(t,n){var i=this.$data;s(t)?C(i,t,n):e(t)&&_(t,function(t,e){C(i,e,t)})},Un.reset=function(t){var e=this.$data,i=b(this.__bk__);s(t)?e[t]=i[t]:n(t)?_(t,function(t){e[t]=i[t]}):_(e,function(t,n){e[n]=i[n]})},Un.watch=function(t,e,n){return new nt(this,{deep:n,expression:t},e.bind(this.__ct__))},Un.destroy=function(){this.__vm__.destroy(),this.__vm__=this.__ct__=this.__bk__=this.$data=this.$els=null};var zn=1e3,Hn="__eventid__",Wn=Ne.extend({init:function(t){this.__config__=g(!0,{target:null,replace:!1,tag:"div",css:null,attr:null,class:"",view:"",template:"",tplParam:null,model:null,methods:null,watches:null,watchAll:null,computed:null,customs:null,hooks:null,lazy:!1,childs:null,cbRender:"afterRender"},t),this.el=null,this.vm=null,this.$=new gt,this.__visible__="",this.__ready__=!1,this.__listeners__={},i(this.beforeRender)&&this.beforeRender(),this.getConfig("template")?this._loadTemplate():this._render()},_loadTemplate:function(){var t=this.getConfig(),e=t.template;we.load(e,t.tplParam,function(t,n){var i;t?(i=t.status+": "+e,f(t)):i=n.result,this.setConfig("view",i),this._render()},this)},_render:function(){if(this.__ready__)return this;this.__ready__=!0;var t=this.getConfig(),n=t.target,r=n instanceof HTMLElement;r?this.el=y(t.tag):this.el=document.querySelector(n);var o=t.class;o&&s(o)&&_(o.split(" "),function(t){pt(this.el,t)},this),e(t.css)&&_(t.css,function(t,e){this.el.style[e]=t},this),e(t.attr)&&_(t.attr,function(t,e){lt(this.el,e,t)},this),t.view&&(this.el.innerHTML=u(t.view));var a=t.model;e(a)&&(this.vm=new ve({view:this.el,model:a,methods:t.methods,watches:t.watches,watchAll:t.watchAll,computed:t.computed,customs:t.customs,hooks:t.hooks,context:this,lazy:t.lazy}));var h=this.el.style.display;this.__visible__="none"===h?"":h,_(t.childs,this._buildBatchChilds,this),r&&(t.replace?n.parentNode.replaceChild(this.el,n):n.appendChild(this.el));var c=this[t.cbRender];i(c)&&c.call(this)},_buildBatchChilds:function(t,e){var n=this,i=this.queryAll(e.toLowerCase());switch(i.length||(i=this.queryAll("[name="+e+"]")),i.length){case 0:f("Cannot find target element for sub component ["+e+"]");break;case 1:this._createChild(i[0],e,t);break;default:for(var s=0;s1&&p(t,i[0]);)t=t[i.shift()];return e=i[0],"undefined"!=typeof n?void(t[e]=n):t[e]}function k(t,e,n,i,s,r){var o=r||this,a=new XMLHttpRequest;return a.open(n,e,!0),a.onreadystatechange=function(){var e=a.status,n=null,i=null;if(4===a.readyState){var r=a.responseText;if("text"!==t)try{r=JSON.parse(r)}catch(t){}200===e?n={success:!0,result:r}:i={result:null,success:!1,status:e},s.call(o,i,n)}},i&&a.setRequestHeader("Content-type","application/x-www-form-urlencoded"),a.send(i),a}function O(t,e,n,s,r){var o=[];return i(e)&&(r=s,s=n,n=e,e=null),_(e,function(t,e){o.push(e+"="+encodeURIComponent(t))}),o.length&&(t=t+"?"+o.join("&")),k(r||"json",t,"GET",null,n,s)}function A(t,e,n,i){return k("json",t,"POST",e?JSON.stringify(e):null,n,i)}function N(t,e,n,i){return O(t,e,n,i,"text")}function D(t,e){return i(e)&&Ce.test(ke.call(e))?function(){this.Super=t,e.apply(this,arguments)}:e}function E(){}function S(t){return t.charAt(0).toUpperCase()+t.substr(1)}function j(t){var e=null;return _($e,function(n){if((n.__rd__&&n.__rd__.name)===t)return e=n,!1}),e}function I(t,e,n,i){return{type:t,from:e,to:null,count:0,name:n,param:i,method:"on"+S(n),returns:null}}function T(t,e){var n=t[e.method];if(i(n))return e.to=t,++e.count,n.call(t,e)}function L(t,e,n){i(e)&&e.call(n,t)}function P(t,e,n,i,s){for(var r=I("fire",t,e,n),o=t.getParent();o;){var a=T(o,r);if(a===!1)return void L(r,i,s);r.from=o,o=o.getParent()}L(r,i,s)}function R(t,e,n,i,s){for(var r=I("broadcast",t,e,n),o=t.getChilds(!0).slice(0);o.length;){var a=o.shift(),h=T(a,r);h!==!1&&(r.from=a,Array.prototype.push.apply(o,a.getChilds(!0)))}L(r,i,s)}function q(t,n,i,r,o,a){if(s(n)){var h,u=n.split("."),c=j(u.shift());u.length?_(u,function(t){return h=c.getChild(t),c=h,null}):h=c,c=null,e(h)&&(n=h)}var l=I("notify",t,i,r);return e(n)?(T(n,l),void L(l,o,a)):(L(l,o,a),f("Component: ["+n+"] is not exist!"))}function M(t,n,i,s){var r=I("globalCast","__core__",t,n);_($e,function(t,n){e(t)&&"0"!==n&&T(t,r)}),L(r,i,s)}function U(t){this.path=t,this.watchers=[],this.guid=je++}function z(t){return t}function F(t){return""}function H(t){var e=t.charCodeAt(0);if(e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57)return Le;switch(e){case 91:case 93:case 46:case 34:case 39:return Pe;default:return Re}}function W(t){var e=[],n=t.split(""),i=n.length-1,s=H(n[0]);return Me.init(s),_(n,function(t,n){var s=H(t),r=Me.set(s,t);r&&e.push(r),n===i&&Me.saves&&(e.push(Me.saves),Me.reset())}),e}function B(t,e){for(;e.length;)t=t[e.shift()];return t}function V(t){return W($(t))}function G(t,n,i){var s=b(i),r=s.pop(),o=B(t,s);e(o)&&(o[r]=n)}function Z(t){var e=Je.length;return Je[e]=t,'"'+e+'"'}function J(t,e){return Je[e]}function Q(t){var e=t.charAt(0),n=t.slice(1);return Ve.test(n)?t:(n=n.indexOf('"')>-1?n.replace(Ue,J):n,e+"scope."+n)}function X(t){return We.test(t)&&!ze.test(t)&&0!==t.indexOf("Math.")}function K(t){return X(t)?"scope."+t:(t=(" "+t).replace(Fe,Z),t=t.replace(He,Q),t=t.replace(Ue,J))}function Y(t){if(Ze.test(t))return f("Avoid using unallow keyword in expression ["+t+"]"),l;try{return new Function("scope","return "+K(t)+";")}catch(e){return d("Invalid generated expression: ["+t+"]"),l}}function tt(t){var e=V(t);return e.length?function(t,n){G(t,n,e)}:(d("Invalid setter expression ["+t+"]"),l)}function et(t,e){var n=t&&t.__ob__,i=n&&n.dep.guid;if(i){if(Qe.indexOf(i)>-1)return;Qe.push(i)}_(t,function(t){et(t,!1)}),e&&(Qe.length=0)}function nt(t,e,n,s){this.vm=t,g(this,e),this.callback=n,this.context=s||this,this.depIds=[],this.newDepIds=[],this.shallowIds=[],this.depends=[],this.newDepends=[];var r=e.once,o=e.expression,a=i(o);this.getter=a?o:Y(o),this.setter=!r&&e.duplex?tt(o):null,this.oldVal=null,this.value=r?this.getValue():this.get()}function it(t){this.parser=t,this.scope=t.scope}function st(t,e,n,i){this.vm=t,this.el=e,this.desc=n,this.scope=i,this.parse()}function rt(t){return t.prototype=Object.create(st.prototype)}function ot(t){return 1===t.nodeType}function at(t){return 3===t.nodeType}function ht(t){for(;t.firstChild;)t.removeChild(t.firstChild);return t}function ut(t,e){return t.getAttribute(e)||""}function ct(t,e){t.removeAttribute(e)}function lt(t,e,n){return null==n||n===!1?ct(t,e):void(n===!0?(t[e]=n,ft(t,e)||t.setAttribute(e,"")):n!==ut(t,e)&&t.setAttribute(e,n))}function ft(t,e){return t.hasAttribute(e)}function dt(t,e){var n,i=t.classList;return i?i.contains(e):(n=" "+ut(t,"class")+" ",n.indexOf(" "+e+" ")>-1)}function pt(t,e){var n,i=t.classList;e&&!dt(t,e)&&(i?i.add(e):(n=" "+ut(t,"class")+" ",n.indexOf(" "+e+" ")===-1&<(t,"class",(n+e).trim())))}function vt(t,e){var n,i,s=t.classList;if(e&&dt(t,e)){if(s)s.remove(e);else{for(i=" "+e+" ",n=" "+ut(t,"class")+" ";n.indexOf(i)>-1;)n=n.replace(i," ");lt(t,"class",n.trim())}t.className||ct(t,"class")}}function _t(t,e,n,i){t.addEventListener(e,n,i)}function mt(t,e,n,i){t.removeEventListener(e,n,i)}function gt(){this.empty=ht,this.getAttr=ut,this.removeAttr=ct,this.setAttr=lt,this.hasAttr=ft,this.hasClass=dt,this.addClass=pt,this.removeClass=vt,this.addEvent=_t,this.removeEvent=mt}function bt(t){try{return new Function("scope",K(t))}catch(e){return d("Invalid generated expression: ["+t+"]"),l}}function yt(t){var e,n,i=$(t),s=i.match(nn),r=s&&s[0];return r?(n=i.substr(0,i.indexOf(r)),e="["+r.substr(1,r.length-2)+"]"):n=i,{func:n,args:e}}function wt(t){var e={},n=t.trim();if(en.test(n)){var i=n.length;n=n.substr(1,i-2).replace(/\s/g,"");var s=n.match(rn);_(s,function(t){var n=t.split(":"),i=n[0],s=n[1];i&&s&&(i=i.replace(sn,""),e[i]=s)})}return e}function xt(t,e){var n,i=t.indexOf("."),s="";i>-1?(n=t.substr(0,i),s=t.substr(i+1,t.length)):n=t;var r=yt(e),o=r.func,a=r.args;return X(o)||(o=bt(e)),{type:n,dress:s,func:o,args:a}}function $t(t){var e=[],n=t.args,i=t.expression;if(n)e=[xt(n,i)];else{var s=wt(i);_(s,function(t,n){e.push(xt(n,t))})}return e}function Ct(t,e){var n,i=e.split("."),s=i.indexOf("self")>-1,r=i.indexOf("stop")>-1,o=i.indexOf("one")>-1,a=i.indexOf("prevent")>-1,h=i.indexOf("capture")>-1;return 0===t.indexOf("key")&&_(i,function(t){if(tn.test(t))return n=+t,!1}),{self:s,stop:r,prevent:a,capture:h,keyCode:n,one:o}}function kt(){this.cache={},this.funcWatchers=[],this.argsWatchers=[],st.apply(this,arguments)}function Ot(){st.apply(this,arguments)}function At(t){for(var e=0;e=e&&t.call(t)},e)}function ie(t,e){for(var n=[],i=t.options,s=0;s-1?(n=i.substr(r+1),e=i.substr(0,r)):e=i,{args:n,attr:i,directive:e,expression:s}}function de(t){t.__afterHook__||v(t,"__afterHook__",ut(t,"v-hook:after")),t.__beforeHook__||v(t,"__beforeHook__",ut(t,"v-hook:before"))}function pe(t,e){var n,i,s;return function(r,o,a){var h=r.path;h===n&&o===i&&a===s||(t.apply(e,arguments),n=h,i=o,s=a)}}function ve(t){var n=t.model,s=t.view,r=t.computed,o=t.watchAll;return ot(s)?e(n)?(this.$queue=[],this.$data=n,this.$element=s,this.$regEles={},this.$directives=[],this.$context=t.context||this,this.$ob=It(this.$data),r&&Pt(this.$data,r),this.$afters=[],this.$hooks=t.hooks||{},this.$customs=t.customs||{},this.$unifyCb=i(o)?pe(o,this.$context):null,void(t.lazy||this.mount())):f("model must be a type of Object: ",n):f("view must be a type of DOMElement: ",s)}function _e(t){var n=t.context||t.model;_(t.model,function(e,s){i(e)&&(t.model[s]=e.bind(n))}),_(t.methods,function(e,i){t.model[i]=e.bind(n)}),this.__ct__=n,this.__bk__=b(t.model),this.__vm__=new ve(t),this.$data=this.__vm__.$data,this.$els=this.__vm__.$regEles,_(t.watches,function(t,n){i(t)?this.watch(n,t,!1):e(t)&&this.watch(n,t.handler,t.deep)},this)}var me=Object.prototype,ge=me.hasOwnProperty,be=window.console,ye=/\s/g,we=Object.create(null);we.def=v,we.each=_,we.copy=b,we.config=C,we.extend=g,we.hasOwn=p,we.isFunc=i,we.isBool=r,we.isArray=n,we.isObject=e,we.isNumber=o,we.isString=s,we.isEmptyObject=h;var xe=Object.create(null);xe.get=O,xe.post=A,xe.load=N;var $e={id:1,length:0},Ce=/\b\.Super\b/,ke=Function.prototype.toString;E.extend=function(t){function e(t,e,n){var r=s[t];i(r)&&r.call(this,g(!0,n,e))}function n(){}var s=this.prototype,r=n.prototype=Object.create(s);return _(t,function(t,n){r[n]=D(e,t)}),t=null,n.extend=this.extend,r.constructor=n,n};var Oe={fire:P,broadcast:R,notify:q,globalCast:M},Ae="map",Ne="array",De=E.extend({__rd__:{},create:function(t,e,n){if(!s(t))return f("Module name ["+t+"] must be a type of String");if(!i(e))return f("Module Class ["+e+"] must be a type of Component");var r=this.__rd__;if(p(r,Ne)||(r[Ne]=[],r[Ae]={}),r[Ae][t])return f("Module ["+t+"] is already exists!");var o=new e(n),a={name:t,id:$e.id++,pid:r.id||0};return o.__rd__=a,$e[a.id]=o,$e.length++,r[Ne].push(o),r[Ae][t]=o,i(o.init)&&o.init(n,this),o},getParent:function(){var t=this.__rd__,e=t&&t.pid;return $e[e]||null},getChild:function(t){var e=this.__rd__;return e&&e[Ae]&&e[Ae][t]||null},getChilds:function(t){var e=this.__rd__;return t=r(t)&&t,t?e[Ne]||[]:e[Ae]||{}},_removeChild:function(t){for(var e=this.__rd__,n=e[Ae]||{},i=e[Ne]||[],s=n[t],r=0,o=i.length;r-1;if(i(e))return this.bindAnonymousEvent(s,r,e);if("$remove"===e)return this.bindRemoveEvent(s,r);var a=this.getExpDesc(e),h=new nt(this.vm,a,function(t,e){this.off(s,e,o),this.bindEvent(s,r,t,n)},this),u=h.value;return i(u)?(this.bindEvent(s,r,u,n),void(a.once?h.destroy():this.funcWatchers.push(h))):(h.destroy(),f("Directive ["+this.desc.attr+"] must be a type of Function"))},hn.bindAnonymousEvent=function(t,e,n){var i=this.scope||this.vm.$data;this.bindEvent(t,e,n.bind(i,i))},hn.bindRemoveEvent=function(t,e){var n=this.scope;if(!n)return f("The specify event $remove must be used in v-for scope");var i=n.__alias__;this.bindEvent(t,e,function(){n.__viterator__.$remove(n[i])},"["+i+"]")},hn.bindEvent=function(t,e,n,i){var s=Ct(t,e),r=s.self,o=s.stop,a=s.prevent,h=s.capture,u=s.keyCode,c=s.one;v(this.scope||this.vm.$data,"$event","__e__");var l=[];if(i){var f=this.getExpDesc(i),d=new nt(this.vm,f,function(t){l=t},this);l=d.value,f.once?d.destroy():this.argsWatchers.push(d)}var p,m=this.el,g=function(t){r&&t.target!==m||u&&u!==t.keyCode||(l.length?_(l,function(e,n){("__e__"===e||e instanceof Event)&&(l[n]=t)}):l.push(t),a&&t.preventDefault(),o&&t.stopPropagation(),n.apply(this,l))},b=on++,y=this;c?(p=function(e){g(e),y.off(t,p,h)},p[an]=b):(n[an]=b,p=g),this.cache[b]=p,this.on(t,p,h)},hn.on=function(t,e,n){_t(this.el,t,e,n)},hn.off=function(t,e,n){var i=this.cache,s=e[an],r=i[s];r&&(mt(this.el,t,r,n),delete i[s])},hn._destroy=function(){m(this.cache),_(this.funcWatchers,function(t){t.destroy()}),_(this.argsWatchers,function(t){t.destroy()})};var un=rt(Ot);un.parse=function(){this.scope?f("v-el can not be used inside v-for! Consider use v-custom to handle v-for element."):this.vm.$regEles[this.desc.expression]=this.el};var cn="__proto__"in{},ln=Array.prototype,fn=Object.create(ln);_(["pop","push","sort","shift","splice","unshift","reverse"],function(t){var e=ln[t];v(fn,t,function(){for(var n=arguments,i=[],s=this.__ob__,r=0;r=this.length&&(t=this.length),this.splice(t,1,e)[0]}),v(ln,"$remove",function(t){var e=this.indexOf(t);if(e>-1)return this.splice(e,1)});var dn=Object.getOwnPropertyNames(fn),pn="__vfor__",vn="__vforid__",_n=/(.*) (?:in|of) (.*)/,mn="push|pop|shift|unshift|splice".split("|"),gn=rt(Mt);gn.parse=function(){var t=this.el,e=this.desc,n=t.parentNode,i=e.expression,s=i.match(_n);if(!s)return f('The format of v-for must be like "item in/of items"!');if(1!==n.nodeType)return f("v-for cannot use in the root element!");if(ft(t,"v-if"))return f("Do not use v-if and v-for on the same element! Consider filtering the source Array instead.");var r=s[1],o=s[2];this.length=0,this.scopes=[],this.init=!0,this.alias=r,this.partly=!1,this.partlyArgs=[],this.$parent=n,this.end=t.nextSibling,this.start=t.previousSibling,this.bodyDirs=t.__dirs__,this.tpl=t.cloneNode(!0),this.hooks=Rt(this.vm,t),this.isOption="OPTION"===t.tagName&&"SELECT"===n.tagName,e.expression=o,this.bind(),this.updateModel()},gn.updateModel=function(){if(this.isOption){var t=this.$parent.__vmodel__;t&&t.forceUpdate()}},gn.hook=function(t,e,n){var s=this.hooks[t];i(s)&&(s.call(this.vm.$context,e,n,e[vn]),e=null)},gn.update=function(t,e,n,i){this.length=t&&t.length,this.init?(this.$parent.replaceChild(this.buildList(t),this.el),this.el=null,this.init=!1):i&&mn.indexOf(i.method)>-1?(this.partly=!0,this.updatePartly(t,i),this.partly=!1):(this.recompileList(t),this.updateModel())},gn.updatePartly=function(t,e){var n=[],i=e.args,s=e.method,r=this.scopes;switch(this[s].call(this,t,i),s){case"pop":case"shift":break;case"push":case"unshift":n=this.partlyArgs;break;case"splice":n=i.slice(0,2),Array.prototype.push.apply(n,this.partlyArgs)}r[s].apply(r,n),this.partlyArgs.length=0,_(r,function(t,e){t.$index=e})},gn.recompileList=function(t){for(var e=this,n=0,i=this.$parent,s=i.childNodes,r=0;r1&&n.block(this.el),v(u,pn,h),v(u,vn,qt()),n.compile(u,!0,l,this.desc.once),r.appendChild(u),this.hook("after",u,a)},this),r},gn.getChilds=function(){for(var t=this,e=[],n=this.$parent.childNodes,i=0;i=n&&e0,Nn={bind:function(){function t(t){i&&(t=t.trim());var e=se(t,r);o?ne(function(){n.onDebounce=!0,a.set(e)},c(o)):a.set(e)}var e,n=this,i=this.trim,s=this.lazy,r=this.number,o=this.debounce,a=this.directive;this.on("compositionstart",function(){e=!0}),this.on("compositionend",function(){e=!1,s||t(this.value)}),this.on("input",function(){e||s||t(this.value)}),this.on("blur",function(){t(this.value)}),this.on("change",function(){t(this.value)}),An&&(this.on("cut",function(){t(this.value)}),this.on("keyup",function(e){var n=e.keyCode;8!==n&&46!==n||t(this.value)}))},update:function(t){var e=this.el,n=u(t);e.value===n||this.onDebounce||(e.value=n)}},Dn={bind:function(){var t=this.number,e=this.directive;this.on("change",function(){e.set(se(this.value,t))})},update:function(t){var e=this.el;e.checked=e.value===u(t)}},En={bind:function(){var t=this.multi,e=this.number,n=this.directive;this.on("change",function(){var i=t?ie(this,e):se(this.value,e);n.set(i)}),this.vm.after(this.forceUpdate,this)},update:function(t){var e=this.el,i=this.multi,s=this.desc.expression;if(e.selectedIndex=-1,i&&!n(t))return f(" has no multiple propperty");for(var r=e.options,o=0;o-1:h===u(t)}},forceUpdate:function(){this.update(this.directive.get())}},Sn={bind:function(){var t=this.number,e=this.directive;this.on("change",function(){var i=e.get(),s=this.checked;if(r(i))e.set(s);else if(n(i)){var o=se(this.value,t),a=re(o,i);s&&a===-1?i.push(o):a>-1&&i.splice(a,1)}})},update:function(t){var e=this.el,i=se(e.value,this.number);return n(t)||r(t)?void(e.checked=r(t)?t:re(i,t)>-1):f("Checkbox v-model value must be a type of Boolean or Array")}},jn=["input","select","textarea"],In=rt(oe);In.parse=function(){var t=this.el,e=this.desc,n=t.tagName.toLowerCase(),i="input"===n?ut(t,"type"):n;return jn.indexOf(n)<0?f("v-model only for using in "+jn.join(", ")):X(e.expression)?(e.duplex=!0,void this.bindDuplex(i)):f("v-model directive value can be use by static expression")},In.bindDuplex=function(t){var e,n=this.el;switch(t){case"text":case"password":case"textarea":e=Nn,this.trim=ft(n,"trim"),this.lazy=ft(n,"lazy"),this.debounce=ut(n,"debounce");break;case"radio":e=Dn;break;case"checkbox":e=Sn;break;case"select":e=En,v(n,"__vmodel__",this),this.multi=ft(n,"multiple"),this.forceUpdate=En.forceUpdate.bind(this)}return e?(this.number=ft(n,"number"),this.update=e.update.bind(this),this.bind(),void(this.desc.once||e.bind.call(this))):f("Do not use incorrect form-type with v-model: ",n)},In.on=function(t,e){_t(this.el,t,e,!1)};var Tn=rt(ae);Tn.parse=function(){var t=this.desc,e=this.vm.$customs[t.args];return i(e)?(this.update=e,void this.bind()):f("Custom directive ["+t.attr+"] must define with a refresh function!")};var Ln={von:kt,vel:Ot,vif:Ht,vfor:Mt,vtext:Wt,vhtml:Bt,vshow:Zt,vbind:ee,vmodel:oe,vcustom:ae},Pn=/\n/g,Rn=/\{\{(.+?)\}\}/g,qn=/(\{\{.*\}\})/,Mn=["velse","vpre","vcloak","vonce","vhook"],Un=ve.prototype;Un.mount=function(){this.$done=!1,this.$fragment=x(this.$element),this.compile(this.$fragment,!0)},Un.compile=function(t,e,n,i){var s=this,r=t.childNodes,o=!!i||ue(t);e&&le(t)&&this.$queue.push([t,n]),v(t,"__vonce__",o);for(var a=0;a1&&o!==a.length-1){var f=a.splice(o,1)[0];a.push(f),f=null}i&&(v(e,"__dirs__",a.length),a=[i],i=null),_(a,function(t){this.parse(e,t,n)},this)}else at(e)&&this.parseText(e,n)},Un.parse=function(t,e,n){var i=t.__vonce__,s=fe(e),r=s.directive,o="v"+r.substr(2),a=Ln[o];if(ct(t,s.attr),!(Mn.indexOf(o)>-1))if(a){s.once=i;var h=new a(this,t,s,n);i?h.destroy():n||this.$directives.push(h)}else f("["+r+"] is an unknown directive!")},Un.parseText=function(t,e){var n=[],i={},s=t.parentNode&&t.parentNode.__vonce__,r=t.textContent.trim().replace(Pn,""),o=r.split(Rn),a=r.match(Rn);_(o,function(t){a.indexOf("{{"+t+"}}")>-1?n.push("("+t+")"):t&&n.push('"'+t+'"')}),i.once=s,i.expression=n.join("+");var h=new Ln.vtext(this,t,i,e);s?h.destroy():e||this.$directives.push(h)},Un.block=function(t){_(this.$queue,function(e){if(t===e[0])return null})},Un.after=function(t,e){this.$afters.push([t,e])},Un.completed=function(){0!==this.$queue.length||this.$done||(this.$done=!0, +this.$element.appendChild(this.$fragment),_(this.$afters,function(t){return t[0].call(t[1]),null}))},Un.destroy=function(){this.$data=null,ht(this.$element),_(this.$directives,function(t){return t.destroy(),null})};var zn=_e.prototype;zn.mount=function(){this.__vm__.mount()},zn.get=function(t){var e=this.$data;return s(t)?C(e,t):e},zn.getCopy=function(t){return b(this.get(t))},zn.set=function(t,n){var i=this.$data;s(t)?C(i,t,n):e(t)&&_(t,function(t,e){C(i,e,t)})},zn.reset=function(t){var e=this.$data,i=b(this.__bk__);s(t)?e[t]=i[t]:n(t)?_(t,function(t){e[t]=i[t]}):_(e,function(t,n){e[n]=i[n]})},zn.watch=function(t,e,n){return new nt(this,{deep:n,expression:t},e.bind(this.__ct__))},zn.destroy=function(){this.__vm__.destroy(),this.__vm__=this.__ct__=this.__bk__=this.$data=this.$els=null};var Fn=1e3,Hn="__eventid__",Wn=De.extend({init:function(t){this.__config__=g(!0,{target:null,replace:!1,tag:"div",css:null,attr:null,class:"",view:"",template:"",tplParam:null,model:null,methods:null,watches:null,watchAll:null,computed:null,customs:null,hooks:null,lazy:!1,childs:null,cbRender:"afterRender"},t),this.el=null,this.vm=null,this.$=new gt,this.__visible__="",this.__ready__=!1,this.__listeners__={},i(this.beforeRender)&&this.beforeRender(),this.getConfig("template")?this._loadTemplate():this._render()},_loadTemplate:function(){var t=this.getConfig(),e=t.template;xe.load(e,t.tplParam,function(t,n){var i;t?(i=t.status+": "+e,f(t)):i=n.result,this.setConfig("view",i),this._render()},this)},_render:function(){if(this.__ready__)return this;this.__ready__=!0;var t=this.getConfig(),n=t.target,r=n instanceof HTMLElement;r?this.el=y(t.tag):this.el=document.querySelector(n);var o=t.class;o&&s(o)&&_(o.split(" "),function(t){pt(this.el,t)},this),e(t.css)&&_(t.css,function(t,e){this.el.style[e]=t},this),e(t.attr)&&_(t.attr,function(t,e){lt(this.el,e,t)},this),t.view&&(this.el.innerHTML=u(t.view));var a=t.model;e(a)&&(this.vm=new _e({view:this.el,model:a,methods:t.methods,watches:t.watches,watchAll:t.watchAll,computed:t.computed,customs:t.customs,hooks:t.hooks,context:this,lazy:t.lazy}));var h=this.el.style.display;this.__visible__="none"===h?"":h,_(t.childs,this._buildBatchChilds,this),r&&(t.replace?n.parentNode.replaceChild(this.el,n):n.appendChild(this.el));var c=this[t.cbRender];i(c)&&c.call(this)},_buildBatchChilds:function(t,e){var n=this,i=this.queryAll(e.toLowerCase());switch(i.length||(i=this.queryAll("[name="+e+"]")),i.length){case 0:f("Cannot find target element for sub component ["+e+"]");break;case 1:this._createChild(i[0],e,t);break;default:for(var s=0;s