diff --git a/avalon.js b/avalon.js index ce444d720..10b98be90 100644 --- a/avalon.js +++ b/avalon.js @@ -1874,7 +1874,6 @@ var c = ronduplex.test(data.type) ? data : fn.apply(0, data.args) data.handler(c, data.element, data) } catch (e) { - console.log(fn + "") log("warning:exception throwed in [registerSubscriber] " + e) delete data.evaluator var node = data.element @@ -2465,7 +2464,7 @@ if (!assigns.length && dataType === "duplex") { return } - if (dataType !== "duplex") { + if (dataType !== "duplex" && (code.indexOf("||") > -1 || code.indexOf("&&") > -1)) { //https://github.com/RubyLouvre/avalon/issues/583 data.vars.forEach(function(v) { var reg = new RegExp("\\b" + v + "(?:\\.\\w+|\\[\\w+\\])+", "ig") diff --git a/avalon.min.js b/avalon.min.js index 3c286466f..5b14ea8e0 100644 --- a/avalon.min.js +++ b/avalon.min.js @@ -6,36 +6,36 @@ d;f.$events=g;for(e in R)c=R[e],w||(c=c.bind(f)),f[e]=c;f.hasOwnProperty=functio return h}function Z(b,c,d){b="for(var "+b+"i=0,n = this.length; i < n; i++){"+c.replace("_","((i in this) && fn.call(scope,this[i],i,this))")+"}"+d;return Function("fn,scope",b)}function Za(b,c){try{for(;c=c.parentNode;)if(c===b)return!0;return!1}catch(d){return!1}}function $a(){return(new XMLSerializer).serializeToString(this)}function u(b){for(var c in b)if(O.call(b,c)){var d=b[c];if("function"===typeof u.plugins[c])u.plugins[c](d);else"object"===typeof u[c]?avalon.mix(u[c],d):u[c]=d}return this} function ab(b){return b.replace(/([a-z\d])([A-Z]+)/g,"$1-$2").toLowerCase()}function oa(b){return 0>b.indexOf("-")&&0>b.indexOf("_")?b:b.replace(/[-_][^-_]/g,function(b){return b.charAt(1).toUpperCase()})}function bb(b){if(!("classList"in b)){b.classList={node:b};for(var c in cb)b.classList[c.slice(1)]=cb[c]}return b.classList}function db(b){try{b="true"===b?!0:"false"===b?!1:"null"===b?null:+b+""===b?+b:$b.test(b)?avalon.parseJSON(b):b}catch(c){}return b}function eb(b,c){if(0>=b.offsetWidth){if(ac.test(x["@:get"](b, "display"))){var d={node:b},e;for(e in fb)d[e]=b.style[e],b.style[e]=fb[e];c.push(d)}(d=b.parentNode)&&1===d.nodeType&&eb(d,c)}}function gb(b){var c=b.nodeName;return c.toLowerCase()===c&&b.scopeName&&""===b.outerText}function bc(b){"url(#default#VML)"!==b.currentStyle.behavior&&(b.style.behavior="url(#default#VML)",b.style.display="inline-block",b.style.zoom=1)}function ya(b){Y[A]=b;avalon.openComputedCollect=!0;var c=b.evaluator;if(c)try{var d=cc.test(b.type)?b:c.apply(0,b.args);b.handler(d,b.element, -b)}catch(e){console.log(c+""),v("warning:exception throwed in [registerSubscriber] "+e),delete b.evaluator,c=b.element,3===c.nodeType&&(d=c.parentNode,u.commentInterpolate?d.replaceChild(p.createComment(b.value),c):c.data=P+b.value+Q)}avalon.openComputedCollect=!1;delete Y[A]}function ka(b){var c=Y[A];b&&(c&&avalon.Array.ensure(b,c)&&c.element)&&hb(c,b)}function hb(b,c){b.$uuid=b.$uuid||ha();c.$uuid=c.$uuid||ha();var d={data:b,list:c,toString:function(){return b.$uuid+" "+c.$uuid}};S[d]||(S[d]=1, -S.push(d))}function ib(){for(var b=za,c=za+dc;b"))&&ob(b,c)}}function Ca(b,c){b.length&&c.cb(b.length);for(var d=0,e;e=b[d++];)e.vmodels=c,C[e.type](e,c),e.evaluator&&(e.element&&1===e.element.nodeType)&&e.element.removeAttribute(e.name);b.length=0}function rb(b,c){0b&&delete c[d.shift()];return c[e]=f}var d=[];return c}function xb(b,c,d){var e=d.type,f=d.filters?d.filters.join(""):"",g=c.map(function(b){return String(b.$id).replace(oc,"$1")})+b+e+f,h=pc(b).concat(),k=[],l=[],m=[],n="";c=wb(c);d.vars=[];for(var q=0,n=c.length;q>0)-(d.clientLeft>>0),c.pageY=b.clientY+(d.scrollTop>>0)-(d.clientTop>>0),c.wheelDeltaY=c.wheelDelta,c.wheelDeltaX=0);c.timeStamp=new Date-0;c.originalEvent=b;c.preventDefault=function(){b.returnValue=!1};c.stopPropagation=function(){b.cancelBubble=!0};return c}function Xb(b){var c=[];c.$id=ha();c.$model=b;c.$events={};c.$events[G]=[];c._=N({length:b.length});c._.$watch("length",function(b,d){c.$fire("length",b,d)});for(var d in R)c[d]=R[d]; -avalon.mix(c,Ab);return c}function Bb(b,c,d,e){var f=avalon.parseHTML(b.template),g=avalon.slice(f.childNodes);c.appendChild(f);d.$outer=b.$outer;b=b.vmodels;d=[d].concat(b);d.cb=b.cb;e.push({nodes:g,vmodels:d})}function Ha(b,c){var d=b.endRepeat,e=[],f=b.element.nextSibling;if(f!==d){do if(f!==d)e.push(f);else break;while(f=f.nextSibling)}return e[b.group*c]||d}function Cb(b,c,d){c*=d||1;d=[b];for(var e=1,f=I;eu.maxRepeatSize&&da.pop()}b.length=0}function T(){p.body&&(D?(s["ready!"].state=2,D.checkDeps()):Fb.forEach(function(b){b(avalon)}), -T=y)}function Gb(){try{B.doScroll("left"),T()}catch(b){setTimeout(Gb)}}var A=new Date-0,G="$"+A,r=Function("return this")(),Ac=r.require,Bc=r.define,ja=!1,z=/[^, ]+/g,Hb=/\[native code\]/,wa=/^(?:object|array)$/,Ib=/^\[object SVG\w*Element\]$/,Vb=/^\[object (?:Window|DOMWindow|global)\]$/,Ia=Object.prototype,O=Ia.hasOwnProperty,ia=Ia.toString,L=Array.prototype,$=L.slice,Y={},w=r.dispatchEvent,B=p.documentElement,J=p.getElementsByTagName("head")[0],I=p.createDocumentFragment(),ea=p.createElement("div"), -Jb={};"Boolean Number String Function Array Date RegExp Object Error".replace(z,function(b){Jb["[object "+b+"]"]=b.toLowerCase()});avalon=function(b){return new avalon.init(b)};avalon.init=function(b){this[0]=this.element=b};avalon.fn=avalon.prototype=avalon.init.prototype;avalon.type=function(b){return null==b?String(b):"object"===typeof b||"function"===typeof b?Jb[ia.call(b)]||"object":typeof b};var V="object"===typeof alert?function(b){try{return/^\s*\bfunction\b/.test(b+"")}catch(c){return!1}}: -function(b){return"[object Function]"==ia.call(b)};avalon.isFunction=V;avalon.isWindow=function(b){return!b?!1:b==b.document&&b.document!=b};Ya(r)&&(avalon.isWindow=Ya);for(var Cc in avalon({}))break;var Dc="0"!==Cc;avalon.isPlainObject=function(b,c){if(!b||"object"!==avalon.type(b)||b.nodeType||avalon.isWindow(b))return!1;try{if(b.constructor&&!O.call(b,"constructor")&&!O.call(b.constructor.prototype,"isPrototypeOf"))return!1}catch(d){return!1}if(Dc)for(c in b)return O.call(b,c);for(c in b);return void 0=== -c||O.call(b,c)};Hb.test(Object.getPrototypeOf)&&(avalon.isPlainObject=function(b){return!!b&&"object"===typeof b&&Object.getPrototypeOf(b)===Ia});avalon.mix=avalon.fn.mix=function(){var b,c,d,e,f,g=arguments[0]||{},h=1,k=arguments.length,l=!1;"boolean"===typeof g&&(l=g,g=arguments[1]||{},h++);"object"!==typeof g&&"function"!==avalon.type(g)&&(g={});h===k&&(g=this,h--);for(;hb&&delete c[d.shift()];return c[e]=f}var d=[];return c}function xb(b,c,d){var e=d.type,f=d.filters?d.filters.join(""):"",g=c.map(function(b){return String(b.$id).replace(oc,"$1")})+b+e+f,h=pc(b).concat(),k=[],l=[],m=[],n="";c=wb(c);d.vars=[];for(var q=0,n=c.length;q>0)-(d.clientLeft>>0),c.pageY=b.clientY+(d.scrollTop>>0)-(d.clientTop>>0),c.wheelDeltaY=c.wheelDelta,c.wheelDeltaX=0);c.timeStamp=new Date-0;c.originalEvent=b;c.preventDefault=function(){b.returnValue=!1};c.stopPropagation=function(){b.cancelBubble=!0};return c}function Xb(b){var c=[];c.$id=ha();c.$model=b;c.$events={};c.$events[G]=[];c._=N({length:b.length});c._.$watch("length", +function(b,d){c.$fire("length",b,d)});for(var d in R)c[d]=R[d];avalon.mix(c,Ab);return c}function Bb(b,c,d,e){var f=avalon.parseHTML(b.template),g=avalon.slice(f.childNodes);c.appendChild(f);d.$outer=b.$outer;b=b.vmodels;d=[d].concat(b);d.cb=b.cb;e.push({nodes:g,vmodels:d})}function Ha(b,c){var d=b.endRepeat,e=[],f=b.element.nextSibling;if(f!==d){do if(f!==d)e.push(f);else break;while(f=f.nextSibling)}return e[b.group*c]||d}function Cb(b,c,d){c*=d||1;d=[b];for(var e=1,f=I;eu.maxRepeatSize&& +da.pop()}b.length=0}function T(){p.body&&(D?(s["ready!"].state=2,D.checkDeps()):Fb.forEach(function(b){b(avalon)}),T=y)}function Gb(){try{B.doScroll("left"),T()}catch(b){setTimeout(Gb)}}var A=new Date-0,G="$"+A,r=Function("return this")(),Ac=r.require,Bc=r.define,ja=!1,z=/[^, ]+/g,Hb=/\[native code\]/,wa=/^(?:object|array)$/,Ib=/^\[object SVG\w*Element\]$/,Vb=/^\[object (?:Window|DOMWindow|global)\]$/,Ia=Object.prototype,O=Ia.hasOwnProperty,ia=Ia.toString,L=Array.prototype,$=L.slice,Y={},w=r.dispatchEvent, +B=p.documentElement,J=p.getElementsByTagName("head")[0],I=p.createDocumentFragment(),ea=p.createElement("div"),Jb={};"Boolean Number String Function Array Date RegExp Object Error".replace(z,function(b){Jb["[object "+b+"]"]=b.toLowerCase()});avalon=function(b){return new avalon.init(b)};avalon.init=function(b){this[0]=this.element=b};avalon.fn=avalon.prototype=avalon.init.prototype;avalon.type=function(b){return null==b?String(b):"object"===typeof b||"function"===typeof b?Jb[ia.call(b)]||"object": +typeof b};var V="object"===typeof alert?function(b){try{return/^\s*\bfunction\b/.test(b+"")}catch(c){return!1}}:function(b){return"[object Function]"==ia.call(b)};avalon.isFunction=V;avalon.isWindow=function(b){return!b?!1:b==b.document&&b.document!=b};Ya(r)&&(avalon.isWindow=Ya);for(var Cc in avalon({}))break;var Dc="0"!==Cc;avalon.isPlainObject=function(b,c){if(!b||"object"!==avalon.type(b)||b.nodeType||avalon.isWindow(b))return!1;try{if(b.constructor&&!O.call(b,"constructor")&&!O.call(b.constructor.prototype, +"isPrototypeOf"))return!1}catch(d){return!1}if(Dc)for(c in b)return O.call(b,c);for(c in b);return void 0===c||O.call(b,c)};Hb.test(Object.getPrototypeOf)&&(avalon.isPlainObject=function(b){return!!b&&"object"===typeof b&&Object.getPrototypeOf(b)===Ia});avalon.mix=avalon.fn.mix=function(){var b,c,d,e,f,g=arguments[0]||{},h=1,k=arguments.length,l=!1;"boolean"===typeof g&&(l=g,g=arguments[1]||{},h++);"object"!==typeof g&&"function"!==avalon.type(g)&&(g={});h===k&&(g=this,h--);for(;h 0 Then","\t\t["+b+'] = [__proxy__]([__data__],"'+b+'")',"\tEnd If","\tOn Error Goto 0","\tEnd Property");f.push("End Class");b=f.join("\r\n"); b=r.findOrDefineVBClass(e,b);b===e&&r.parseVB(["Function "+e+"Factory(a, b)","\tDim o","\tSet o = (New "+e+")(a, b)","\tSet "+e+"Factory = o","End Function"].join("\r\n"));return r[b+"Factory"](c,Ec)}}if(!"\u53f8\u5f92\u6b63\u7f8e".trim){var Fc=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;String.prototype.trim=function(){return this.replace(Fc,"")}}var Gc=!{toString:null}.propertyIsEnumerable("toString"),Hc=function(){}.propertyIsEnumerable("prototype"),Kb="toString toLocaleString valueOf hasOwnProperty isPrototypeOf propertyIsEnumerable constructor".split(" "), diff --git a/avalon.modern.js b/avalon.modern.js index aee5ce66b..29a82bb14 100644 --- a/avalon.modern.js +++ b/avalon.modern.js @@ -1864,7 +1864,7 @@ if (!assigns.length && isDuplex) { return } - if (!isDuplex) { + if (!isDuplex && (code.indexOf("||") > -1 || code.indexOf("&&") > -1)) { //https://github.com/RubyLouvre/avalon/issues/583 data.vars.forEach(function(v) { var reg = new RegExp("\\b" + v + "(?:\\.\\w+|\\[\\w+\\])+", "ig") diff --git a/avalon.modern.min.js b/avalon.modern.min.js index 0a851449a..dcc26e999 100644 --- a/avalon.modern.min.js +++ b/avalon.modern.min.js @@ -14,23 +14,23 @@ e)};e.length&&(f.filters=e);e=[f]}else e=ua(b.data);if(e.length){for(var g=0;f=e l&&(b.msData=b.msData||f)))}f["ms-checked"]&&f["ms-duplex"]&&u("warning!\u4e00\u4e2a\u5143\u7d20\u4e0a\u4e0d\u80fd\u540c\u65f6\u5b9a\u4e49ms-checked\u4e0ems-duplex");e.sort(function(b,c){return b.priority-c.priority});d=e[0]||{};switch(d.type){case "if":case "repeat":case "widget":va([d],c);break;default:va(e,c),!Gb[b.tagName]&&bb.test(b.innerHTML+b.textContent)&&Xa(b,c)}}function va(b,c){b.length&&c.cb(b.length);for(var d=0,e;e=b[d++];)e.vmodels=c,y[e.type](e,c),e.evaluator&&(e.element&&1===e.element.nodeType)&& e.element.removeAttribute(e.name);b.length=0}function $a(b,c){0b&&delete c[d.shift()];return c[e]=f}var d=[];return c}function eb(b,c,d){var e=d.type,f="duplex"===e,g=d.filters?d.filters.join(""): -"",h=c.map(function(b){return b.$id.replace(Lb,"$1")})+b+e+g,k=Mb(b).concat(),l=[],m=[],q=[],n="";d.vars=[];c=cb(c);for(var t=0,n=c.length;ts.maxRepeatSize&&$.pop()}b.length=0}function aa(){A?(r["ready!"].state=2,A.checkDeps()):lb.forEach(function(b){b(avalon)});aa=v}var B=Date.now(),F="$"+B,x=Function("return this")(),Wb=x.require,Xb=x.define,da=!1,w=/[^, ]+/g,La=/^(?:object|array)$/,mb=/^\[object SVG\w*Element\]$/,Yb=/^\[object (Window|DOMWindow|global)\]$/,Aa=Object.prototype,Ma=Aa.hasOwnProperty, -Ba=Aa.toString,N=Array.prototype,ja=N.slice,W={},G=p.head,D=p.documentElement,H=p.createDocumentFragment(),ma=p.createElement("div"),nb={};"Boolean Number String Function Array Date RegExp Object Error".replace(w,function(b){nb["[object "+b+"]"]=b.toLowerCase()});x.avalon=function(b){return new avalon.init(b)};avalon.init=function(b){this[0]=this.element=b};avalon.fn=avalon.prototype=avalon.init.prototype;avalon.isFunction=S;avalon.type=function(b){return null==b?String(b):"object"===typeof b||"function"=== -typeof b?nb[Ba.call(b)]||"object":typeof b};avalon.isWindow=function(b){return Yb.test(Ba.call(b))};avalon.isPlainObject=function(b){return!!b&&"object"===typeof b&&Object.getPrototypeOf(b)===Aa};avalon.mix=avalon.fn.mix=function(){var b,c,d,e,f,g=arguments[0]||{},h=1,k=arguments.length,l=!1;"boolean"===typeof g&&(l=g,g=arguments[1]||{},h++);"object"!==typeof g&&"function"!==avalon.type(g)&&(g={});h===k&&(g=this,h--);for(;h';if(!mb.test(ob.firstChild)){var Ca=function(b,c){if(b&&b.childNodes)for(var d=b.childNodes,e=0,f;f=d[e++];)if(f.tagName){var g=p.createElementNS("http://www.w3.org/2000/svg",f.tagName.toLowerCase());N.forEach.call(f.attributes,function(b){g.setAttribute(b.name,b.value)});Ca(f, -g);c.appendChild(g)}};Object.defineProperties(SVGElement.prototype,{outerHTML:{enumerable:!0,configurable:!0,get:function(){return(new XMLSerializer).serializeToString(this)},set:function(b){var c=this.tagName.toLowerCase(),d=this.parentNode;b=avalon.parseHTML(b);"svg"===c?d.insertBefore(b,this):(c=p.createDocumentFragment(),Ca(b,c),d.insertBefore(c,this));d.removeChild(this)}},innerHTML:{enumerable:!0,configurable:!0,get:function(){var b=RegExp("$","i");return this.outerHTML.replace(RegExp("<"+ +"",h=c.map(function(b){return b.$id.replace(Lb,"$1")})+b+e+g,k=Mb(b).concat(),l=[],m=[],q=[],n="";d.vars=[];c=cb(c);for(var t=0,n=c.length;ts.maxRepeatSize&&$.pop()}b.length=0}function aa(){A?(r["ready!"].state=2,A.checkDeps()):lb.forEach(function(b){b(avalon)});aa=v}var B=Date.now(),F="$"+B,x=Function("return this")(),Wb=x.require,Xb=x.define,da=!1,w=/[^, ]+/g,La=/^(?:object|array)$/,mb=/^\[object SVG\w*Element\]$/,Yb=/^\[object (Window|DOMWindow|global)\]$/, +Aa=Object.prototype,Ma=Aa.hasOwnProperty,Ba=Aa.toString,N=Array.prototype,ja=N.slice,W={},G=p.head,D=p.documentElement,H=p.createDocumentFragment(),ma=p.createElement("div"),nb={};"Boolean Number String Function Array Date RegExp Object Error".replace(w,function(b){nb["[object "+b+"]"]=b.toLowerCase()});x.avalon=function(b){return new avalon.init(b)};avalon.init=function(b){this[0]=this.element=b};avalon.fn=avalon.prototype=avalon.init.prototype;avalon.isFunction=S;avalon.type=function(b){return null== +b?String(b):"object"===typeof b||"function"===typeof b?nb[Ba.call(b)]||"object":typeof b};avalon.isWindow=function(b){return Yb.test(Ba.call(b))};avalon.isPlainObject=function(b){return!!b&&"object"===typeof b&&Object.getPrototypeOf(b)===Aa};avalon.mix=avalon.fn.mix=function(){var b,c,d,e,f,g=arguments[0]||{},h=1,k=arguments.length,l=!1;"boolean"===typeof g&&(l=g,g=arguments[1]||{},h++);"object"!==typeof g&&"function"!==avalon.type(g)&&(g={});h===k&&(g=this,h--);for(;h';if(!mb.test(ob.firstChild)){var Ca=function(b,c){if(b&&b.childNodes)for(var d=b.childNodes,e=0,f;f=d[e++];)if(f.tagName){var g=p.createElementNS("http://www.w3.org/2000/svg",f.tagName.toLowerCase());N.forEach.call(f.attributes,function(b){g.setAttribute(b.name, +b.value)});Ca(f,g);c.appendChild(g)}};Object.defineProperties(SVGElement.prototype,{outerHTML:{enumerable:!0,configurable:!0,get:function(){return(new XMLSerializer).serializeToString(this)},set:function(b){var c=this.tagName.toLowerCase(),d=this.parentNode;b=avalon.parseHTML(b);"svg"===c?d.insertBefore(b,this):(c=p.createDocumentFragment(),Ca(b,c),d.insertBefore(c,this));d.removeChild(this)}},innerHTML:{enumerable:!0,configurable:!0,get:function(){var b=RegExp("$","i");return this.outerHTML.replace(RegExp("<"+ this.nodeName+'\\b(?:(["\'])[^"]*?(\\1)|[^>])*>',"i"),"").replace(b,"")},set:function(b){avalon.clearHTML&&(avalon.clearHTML(this),b=avalon.parseHTML(b),Ca(b,this))}}})}}var la=avalon.vmodels={};avalon.define=function(b,c){var d=b.$id||b;d||u("warning: \u5fc5\u987b\u6307\u5b9a$id");la[d]&&u("warning: "+d+" \u5df2\u7ecf\u5b58\u5728\u4e8eavalon.vmodels\u4e2d");if("object"===typeof b)var e=K(b);else e={$watch:v},c(e),e=K(e),da=!0,c(e),da=!1;e.$id=d;return la[d]=e};var Ka="$id,$watch,$unwatch,$fire,$events,$model,$skipArray".match(w), fa=Object.is||function(b,c){return 0===b&&0===c?1/b===1/c:b!==b?c!==c:b===c},T={},ga=0,pa={},L,M,X,pb,bb,qb=/[-.*+?^${}()|[\]\/\\]/g,A=v,O={loader:function(b){x.define=b?A.define:Xb;x.require=b?A:Wb},interpolate:function(b){L=b[0];M=b[1];L===M?avalon.error("openTag!==closeTag",SyntaxError):"\x3c!--,--\x3e"===b+""?s.commentInterpolate=!0:(b=L+"test"+M,ma.innerHTML=b,ma.innerHTML!==b&&0<=ma.innerHTML.indexOf("<")&&avalon.error("\u6b64\u5b9a\u754c\u7b26\u4e0d\u5408\u6cd5",SyntaxError),ma.innerHTML= "");b=(L+"").replace(qb,"\\$&");var c=(M+"").replace(qb,"\\$&");X=RegExp(b+"(.*?)"+c);pb=RegExp(b+"(.*?)"+c,"g");bb=RegExp(b+".*?"+c+"|\\sms-")}};s.debug=!0;s.plugins=O;s.plugins.interpolate(["{{","}}"]);s.paths={};s.shim={};s.maxRepeatSize=100;avalon.config=s;"add,remove".replace(w,function(b){avalon.fn[b+"Class"]=function(c){var d=this[0];c&&("string"===typeof c&&d&&1===d.nodeType)&&c.replace(/\S+/g,function(c){d.classList[b](c)});return this}});avalon.fn.mix({hasClass:function(b){var c=this[0]|| diff --git a/examples/avalon.shim.js b/examples/avalon.shim.js index 085675a2b..72f225ce4 100644 --- a/examples/avalon.shim.js +++ b/examples/avalon.shim.js @@ -1639,7 +1639,7 @@ col: [2, "", "
"], legend: [1, "
"], option: [1, "