diff --git a/avalon.js b/avalon.js index 9f284835a..d0957d311 100644 --- a/avalon.js +++ b/avalon.js @@ -1640,7 +1640,8 @@ legend: [1, "
"], option: [1, ""],thead:[1,"","
"],tr:[2,""],td:[3,"
"],g:[1,'',""],_default:w? -[0,""]:[1,"X
"]};E.optgroup=E.option;E.tbody=E.tfoot=E.colgroup=E.caption=E.thead;E.th=E.td;"circle,defs,ellipse,image,line,path,polygon,polyline,rect,symbol,text,use".replace(z,function(b){E[b]=E.g});var Rc=/<([\w:]+)/,Sc=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Qb=w?/[^\d\D]/:/(<(?:script|link|style|meta|noscript))/ig,Tc=M(["","text/javascript","text/ecmascript","application/ecmascript","application/javascript"]),Uc=/<(?:tb|td|tf|th|tr|col|opt|leg|cap|area)/, -Vc=p.createElement("script");avalon.parseHTML=function(b){"string"!==typeof b&&(b+="");b=b.replace(Sc,"<$1>").trim();var c=(Rc.exec(b)||["",""])[1].toLowerCase(),d=E[c]||E._default,e=I.cloneNode(!1),f=ea,g;w||(b=b.replace(Qb,"
$1"));f.innerHTML=d[1]+b+(d[2]||"");b=f.getElementsByTagName("script");if(b.length)for(var h=0,k;k=b[h++];)Tc[k.type]&&(g=Vc.cloneNode(!1),L.forEach.call(k.attributes,function(b){b&&b.specified&&(g[b.name]=b.value,g.setAttribute(b.name,b.value))}),g.text= -k.text,k.parentNode.replaceChild(g,k));for(h=d[0];h--;f=f.lastChild);if(!w){b=f.getElementsByTagName("br");for(h=0;k=b[h++];)k.className&&"msNoScope"===k.className&&(k.parentNode.removeChild(k),h--);b=f.all;for(h=0;k=b[h++];)gb(k)&&bc(k)}if(p.createStyleSheet&&"tr"===c){b=f.children;for(h=0;k=b[h++];)""===k.nodeName&&(k.parentNode.removeChild(k),h--)}for(;c=f.firstChild;)e.appendChild(c);return e};avalon.innerHTML=function(b,c){if(!w&&!Qb.test(c)&&!Uc.test(c))try{b.innerHTML=c;return}catch(d){}var e= -this.parseHTML(c);this.clearHTML(b).appendChild(e)};avalon.clearHTML=function(b){for(b.textContent="";b.firstChild;)b.removeChild(b.firstChild);return b};var R={$watch:function(b,c){if("function"===typeof c){var d=this.$events[b];d?d.push(c):this.$events[b]=[c]}else this.$events=this.$watch.backup;return this},$unwatch:function(b,c){var d=arguments.length;if(0===d)this.$watch.backup=this.$events,this.$events={};else if(1===d)this.$events[b]=[];else for(var d=this.$events[b]||[],e=d.length;0>~--e;)if(d[e]=== -c)return d.splice(e,1);return this},$fire:function(b){var c;/^(\w+)!(\S+)$/.test(b)&&(c=RegExp.$1,b=RegExp.$2);var d=this.$events,e=$.call(arguments,1),f=[b].concat(e);if("all"===c)for(var g in avalon.vmodels)e=avalon.vmodels[g],e!==this&&e.$fire.apply(e,f);else if("up"===c||"down"===c){if(d=d.expr&&Rb(d.expr)){for(g in avalon.vmodels)if(e=avalon.vmodels[g],e!==this&&e.$events.expr){var h=Rb(e.$events.expr);if(h&&("down"===c?d.contains(h):h.contains(d)))h._avalon=e}g=p.getElementsByTagName("*");var k= -[];Array.prototype.forEach.call(g,function(b){b._avalon&&(k.push(b._avalon),b._avalon="",b.removeAttribute("_avalon"))});"up"===c&&k.reverse();for(g=0;(c=k[g++])&&!1!==c.$fire.apply(c,f););}}else{f=d[b]||[];c=d.$all||[];for(g=0;d=f[g++];)V(d)&&d.apply(this,e);for(g=0;d=c[g++];)V(d)&&d.apply(this,arguments)}}},Wc=/(\w+)\[(avalonctrl)="(\S+)"\]/,Rb=p.querySelector?function(b){return p.querySelector(b)}:function(b){b=b.match(Wc);for(var c=p.getElementsByTagName(b[1]),d=0,e;e=c[d++];)if(e.getAttribute(b[2])=== -b[3])return e},cc=/^(duplex|on)$/,S=[],za=0,dc=200,jb=new Date,kb,Oa={};avalon.scanCallback=function(b,c){c=c||"$all";(Oa[c]||(Oa[c]=[])).push(b)};avalon.scan=function(b,c,d){b=b||B;var e=Oa[d||"$all"]||[];c=c?[].concat(c):[];var f=0,g=!1,h,k=!1;c.cb=function(b){f+=b;k=!0;setTimeout(function(){if(0>=f&&!g)for(g=!0;h=e.shift();)h()})};lb(b,c);if(!k)for(;h=e.shift();)h()};var hc=M("AREA,BASE,BASEFONT,BR,COL,COMMAND,EMBED,HR,IMG,INPUT,LINK,META,PARAM,SOURCE,TRACK,WBR,NOSCRIPT,SCRIPT,STYLE,TEXTAREA"), -tb=/ms-(\w+)-?(.*)/,ub={"if":10,repeat:90,data:100,widget:110,each:1400,"with":1500,duplex:2E3,on:3E3},fc=M("animationend,blur,change,input,click,dblclick,focus,keydown,keypress,keyup,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,scan,scroll,submit"),gc=M("value,title,alt,checked,selected,disabled,readonly,enabled");if(!"1"[0])var Pa=Da(512),Xc=/\s+(ms-[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,Yc=/^['"]/,Zc=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/i,$c=/&/g,sb=function(b){b=b.outerHTML; -if(".avalonHide{ display: none!important }"; -var gd=/(?:[\s\S]+?)<\/noscript>/img,hd=/([\s\S]+?)<\/noscript>/im,Sa=function(){return new (r.XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP")},fa=function(b,c,d){if(b=b.getAttribute(c)){c=0;for(var e;e=d[c++];)if(e.hasOwnProperty(b)&&"function"===typeof e[b])return e[b]}},Ta=avalon.templateCache={};avalon.contains=Za;var Ua={};"autofocus,autoplay,async,allowTransparency,checked,controls,declare,disabled,defer,defaultChecked,defaultSelectedcontentEditable,isMap,loop,multiple,noHref,noResize,noShade,open,readOnly,selected".replace(z, +c,d){c=[].concat(c);for(var e=La["option:get"],f=0,g;g=b.options[f++];)if(g.selected=0<=c.indexOf(e(g)))d=!0;d||(b.selectedIndex=-1)}},E={area:[1,""],param:[1,""],col:[2,"
","
"],legend:[1,"
"],option:[1,""], thead: [1, "", "
"], - tr: [2, ""], + //如果这里不写
,在IE6-9会在多出一个奇怪的caption标签 + tr: [2, "", "
"], td: [3, ""], g: [1, '', ''], //IE6-8在用innerHTML生成节点时,不能直接创建no-scope元素与HTML5的新标签 @@ -1707,15 +1708,6 @@ } } } - if (DOC.createStyleSheet && tag === "tr") { - for (els = wrapper.children, i = 0; el = els[i++]; ) { - // IE6-9,如果动态生成tr元素,必须会在后面添加早已废弃caption的标签,其nodeName,innerHTML都为"" - if (el.nodeName === "") { - el.parentNode.removeChild(el) - i-- - } - } - } while (firstChild = wrapper.firstChild) { // 将wrapper上的节点转移到文档碎片上! fragment.appendChild(firstChild) }