diff --git a/avalon.js b/avalon.js index a300e2254..77db1e4f6 100644 --- a/avalon.js +++ b/avalon.js @@ -2278,7 +2278,7 @@ function parseExpr(code, scopes, data) { var dataType = data.type - var filters = dataType === "html" || dataType === "text" ? data.filters : "" + var filters = data.filters ? data.filters.join("") : "" var exprId = scopes.map(function(el) { return el.$id.replace(rproxy, "$1") }) + code + dataType + filters @@ -3896,7 +3896,7 @@ $val: 1, $key: 1 }) - proxy.$id = "$proxy$with" + Math.random() + proxy.$id = ("$proxy$with" + Math.random()).replace(/0\./, "") return proxy } var eachProxyPool = [] @@ -3930,7 +3930,7 @@ proxy.$watch(param, function(val) { data.getter().set(proxy.$index, val) }) - proxy.$id = "$proxy$" + data.type + Math.random() + proxy.$id = ("$proxy$" + data.type + Math.random()).replace(/0\./, "") return proxy } function recycleEachProxies(array) { @@ -3995,7 +3995,7 @@ // IE67chrome // IE67chrome sanitize: function(str) { - return str.replace(rscripts, "").replace(ropen, function(a, b) { + return str.replace(rscripts, "").replace(ropen, function(a, b) { var match = a.toLowerCase().match(/<(\w+)\s/) if (match) {//处理a标签的href属性,img标签的src属性,form标签的action属性 var reg = rsanitize[match[1]] diff --git a/avalon.min.js b/avalon.min.js index bf03f9762..e5f79bcad 100644 --- a/avalon.min.js +++ b/avalon.min.js @@ -14,7 +14,7 @@ f.replaceNodes=[h],k.length||delete d.filters);d.push(f)}Q.appendChild(h)}b.pare k="ms-attr-"+m,b.setAttribute(k,n),g=[k],f[k]=n;"function"===typeof E[l]&&(n={type:l,param:m,element:b,name:g[0],value:n,priority:l in ob?ob[l]:10*l.charCodeAt(0)+(Number(m)||0)},"if"===l&&-1"))&&ya(b,c)}if(b.patchRepeat){b.patchRepeat();try{b.patchRepeat="",b.removeAttribute("patchRepeat"),b.removeAttribute("avalonctrl")}catch(p){}}}function Aa(b,c){for(var d=0,e;e=b[d++];)e.vmodels=c,E[e.type](e,c),e.evaluator&&e.name&&e.element.removeAttribute(e.name);b.length=0}function lb(b,c){0b&&delete c[d.shift()];return c[e]=f}var d=[];return c}function ra(b,c,d){var e=d.type,f="html"===e||"text"===e?d.filters:"",g=c.map(function(b){return b.$id.replace(fc,"$1")})+b+e+f,h=gc(b).concat(),k=[],l=[],m=[],n="";c=rb(c);for(var p=0,n=c.length;pb&&delete c[d.shift()];return c[e]=f}var d=[];return c}function ra(b,c,d){var e=d.type,f=d.filters?d.filters.join(""):"",g=c.map(function(b){return b.$id.replace(fc,"$1")})+b+e+f,h=gc(b).concat(),k=[],l=[],m=[],n="";c=rb(c);for(var p=0,n=c.length;ps.maxRepeatSize&&$.pop()}b.length=0}function aa(b,d){if(b&&Array.isArray(d=b[w]))d.forEach(function(b){b.evaluator&&(b.evaluator=b.element=b.node=null)}),d.length=0}function ba(){A? -(r["ready!"].state=2,A.checkDeps()):cb.forEach(function(b){b(avalon)});ba=B}var ta="ms-",x=Date.now(),w="$"+x,u=this||(0,eval)("this"),Pb=u.require,Qb=u.define,ea=!1,C=/[^, ]+/g,oa=/^(?:object|array)$/,db=/^\[object SVG\w*Element\]$/,Rb=/^\[object (Window|DOMWindow|global)\]$/,Ba=Object.prototype,La=Ba.hasOwnProperty,ma=Ba.toString,K=Array.prototype,ia=K.slice,Q={},L=q.head,D=q.documentElement,N=q.createDocumentFragment(),O=q.createElement("div"),eb={};"Boolean Number String Function Array Date RegExp Object Error".replace(C, -function(b){eb["[object "+b+"]"]=b.toLowerCase()});u.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?eb[ma.call(b)]||"object":typeof b};avalon.isWindow=function(b){return Rb.test(ma.call(b))};avalon.isPlainObject=function(b){return!!b&&"object"===typeof b&&Object.getPrototypeOf(b)===Ba};avalon.mix=avalon.fn.mix=function(){var b, -d,c,e,f,g=arguments[0]||{},h=1,l=arguments.length,k=!1;"boolean"===typeof g&&(k=g,g=arguments[1]||{},h++);"object"!==typeof g&&"function"!==avalon.type(g)&&(g={});h===l&&(g=this,h--);for(;h';if(!db.test(fb.firstChild)){var Ca=function(b,d){if(b&&b.childNodes)for(var c=b.childNodes,e=0,f;f=c[e++];)if(f.tagName){var g=document.createElementNS("http://www.w3.org/2000/svg",f.tagName.toLowerCase());K.forEach.call(f.attributes,function(b){g.setAttribute(b.name, -b.value)});Ca(f,g);d.appendChild(g)}};Object.defineProperties(SVGElement.prototype,{outerHTML:{enumerable:!0,configurable:!0,get:function(){return(new XMLSerializer).serializeToString(this)},set:function(b){var d=this.tagName.toLowerCase(),c=this.parentNode;b=avalon.parseHTML(b);"svg"===d?c.insertBefore(b,this):(d=document.createDocumentFragment(),Ca(b,d),c.insertBefore(d,this));c.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 S=avalon.vmodels={};avalon.define=function(b,d){var c=b.$id||b;c||E("warning: \u5fc5\u987b\u6307\u5b9a$id");S[b]&&E("warning: "+c+" \u5df2\u7ecf\u5b58\u5728\u4e8eavalon.vmodels\u4e2d");if("object"===typeof b)var e=F(b);else e={$watch:B},d(e),e=F(e),ea=!0,d(e),ea=!1;e.$id=c;return S[c]= -e};var pb=String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray,$accessors,"+w).match(C),V=Object.is||function(b,d){return 0===b&&0===d?1/b===1/d:b!==b?d!==d:b===d},R={},fa=0,pa={},H,I,W,gb,xa,hb=/[-.*+?^${}()|[\]\/\\]/g,M={loader:function(b){u.define=b?A.define:Qb;u.require=b?A:Pb},interpolate:function(b){H=b[0];I=b[1];H===I?avalon.error("openTag!==closeTag",SyntaxError):"\x3c!--,--\x3e"===b+""?s.commentInterpolate=!0:(b=H+"test"+I,O.innerHTML=b,O.innerHTML!==b&&0<=O.innerHTML.indexOf("<")&& -avalon.error("\u6b64\u5b9a\u754c\u7b26\u4e0d\u5408\u6cd5",SyntaxError),O.innerHTML="");b=(H+"").replace(hb,"\\$&");var d=(I+"").replace(hb,"\\$&");W=RegExp(b+"(.*?)"+d);gb=RegExp(b+"(.*?)"+d,"g");xa=RegExp(b+".*?"+d+"|\\sms-")}};s.dettachVModels=s.debug=!0;s.plugins=M;s.plugins.interpolate(["{{","}}"]);s.paths={};s.shim={};s.maxRepeatSize=100;avalon.config=s;"add,remove".replace(C,function(b){avalon.fn[b+"Class"]=function(d){var c=this[0];d&&("string"===typeof d&&c&&1===c.nodeType)&&d.replace(/\S+/g, -function(d){c.classList[b](d)});return this}});avalon.fn.mix({hasClass:function(b){var d=this[0]||{};return 1===d.nodeType&&d.classList.contains(b)},toggleClass:function(b,d){for(var c,e=0,f=b.split(/\s+/),g="boolean"===typeof d;c=f[e++];)this[(g?d:!this.hasClass(c))?"addClass":"removeClass"](c);return this},attr:function(b,d){return 2===arguments.length?(this[0].setAttribute(b,d),this):this[0].getAttribute(b)},data:function(b,d){b="data-"+Ma(b||"");switch(arguments.length){case 2:return this.attr(b, -d),this;case 1:var c=this.attr(b);return ha(c);case 0:var e={};K.forEach.call(this[0].attributes,function(d){d&&(b=d.name,b.indexOf("data-")||(b=ga(b.slice(5)),e[b]=ha(d.value)))});return e}},removeData:function(b){b="data-"+Ma(b);this[0].removeAttribute(b);return this},css:function(b,d){if(avalon.isPlainObject(b))for(var c in b)avalon.css(this,c,b[c]);else var e=avalon.css(this,b,d);return void 0!==e?e:this},position:function(){var b,d,c=this[0],e={top:0,left:0};if(c)return"fixed"===this.css("position")? -d=c.getBoundingClientRect():(b=this.offsetParent(),d=this.offset(),"HTML"!==b[0].tagName&&(e=b.offset()),e.top+=avalon.css(b[0],"borderTopWidth",!0),e.left+=avalon.css(b[0],"borderLeftWidth",!0)),{top:d.top-e.top-avalon.css(c,"marginTop",!0),left:d.left-e.left-avalon.css(c,"marginLeft",!0)}},offsetParent:function(){for(var b=this[0].offsetParent||D;b&&"HTML"!==b.tagName&&"static"===avalon.css(b,"position");)b=b.offsetParent;return avalon(b||D)},bind:function(b,d,c){if(this[0])return avalon.bind(this[0], -b,d,c)},unbind:function(b,d,c){this[0]&&avalon.unbind(this[0],b,d,c);return this},val:function(b){var d=this[0];if(d&&1===d.nodeType){var c=0===arguments.length,e=c?":get":":set",f=Sb,g;g=d.tagName.toLowerCase();g="input"===g&&/checkbox|radio/.test(d.type)?"checked":g;if(e=f[g+e])var h=e(d,b);else{if(c)return(d.value||"").replace(/\r/g,"");d.value=b}}return c?h:this}});D.dataset&&(avalon.data=function(b,d){var c=this[0].dataset;switch(arguments.length){case 2:return c[b]=d,this;case 1:return d=c[b], -ha(d);case 0:var e={};for(b in c)e[b]=ha(c[b]);return e}});var ub=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/;avalon.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(b,d){avalon.fn[b]=function(c){var e=this[0]||{},f=e.window&&e.document?e:9===e.nodeType?e.defaultView:!1,g="scrollTop"===b;if(arguments.length)f?f.scrollTo(!g?c:avalon(f).scrollLeft(),g?c:avalon(f).scrollTop()):e[b]=c;else return f?f[d]:e[b]}});var v=avalon.cssHooks={},ib=["","-webkit-","-o-","-moz-","-ms-"],Da={"float":"cssFloat", -background:"backgroundColor"};avalon.cssNumber=P("columnCount,order,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom");avalon.cssName=function(b,d,c){if(Da[b])return Da[b];d=d||D.style;for(var e=0,f=ib.length;ek&&(e=e-avalon.css(d,"border"+c[0]+"Width",!0)-avalon.css(d,"border"+c[1]+"Width",!0));-4===k&&(e=e-avalon.css(d,"padding"+c[0],!0)-avalon.css(d,"padding"+c[1],!0));return e};v[d+"&get"]=function(b){var c=[];Na(b,c);for(var e=v[d+":get"](b),f=0,m;m=c[f++];){b=m.node;for(var n in m)"string"===typeof m[n]&&(b.style[n]=m[n])}return e};avalon.fn[d]=function(g){var h=this[0]; -if(0===arguments.length){if(h.setTimeout)return h["inner"+b]||h.document.documentElement[c];if(9===h.nodeType){var l=h.documentElement;return Math.max(h.body[e],l[e],h.body[f],l[f],l[c])}return v[d+"&get"](h)}return this.css(d,g)};avalon.fn["inner"+b]=function(){return v[d+":get"](this[0],void 0,-2)};avalon.fn["outer"+b]=function(b){return v[d+":get"](this[0],void 0,!0===b?2:0)}});avalon.fn.offset=function(){var b=this[0],d={left:0,top:0};if(!b||!b.tagName||!b.ownerDocument)return d;var c=b.ownerDocument, -e=c.documentElement,c=c.defaultView;if(!e.contains(b))return d;void 0!==b.getBoundingClientRect&&(d=b.getBoundingClientRect());return{top:d.top+c.pageYOffset-e.clientTop,left:d.left+c.pageXOffset-e.clientLeft}};var Sb={"select:get":function(b,d){for(var c,e=b.options,f=b.selectedIndex,g="select-one"===b.type||0>f,h=g?null:[],l=g?f+1:e.length,k=0>f?l:g?f:0;k]*)\/>/ig,Vb=P("text/javascript","text/ecmascript","application/ecmascript","application/javascript","text/vbscript"),jb=/<(?:tb|td|tf|th|tr|col|opt|leg|cap|area)/,kb=new function(){avalon.mix(this,{option:q.createElement("select"),thead:q.createElement("table"),td:q.createElement("tr"),area:q.createElement("map"),tr:q.createElement("tbody"), -col:q.createElement("colgroup"),legend:q.createElement("fieldset"),"*":q.createElement("div")});this.optgroup=this.option;this.tbody=this.tfoot=this.colgroup=this.caption=this.thead;this.th=this.td};avalon.clearHTML=function(b){b.textContent="";return b};var Wb=q.createElement("script");avalon.parseHTML=function(b){"string"!==typeof b&&(b+="");b=b.replace(Ub,"<$1>").trim();if(Xb.createContextualFragment&&!jb.test(b)&&!/