This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sizzle.js
1 lines (1 loc) · 13.7 KB
/
sizzle.js
1
(function(){var j=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,done=0,toString=Object.prototype.toString,hasDuplicate=false,baseHasDuplicate=true;[0,0].sort(function(){baseHasDuplicate=false;return 0});var k=function(a,b,c,d){c=c||[];var e=b=b||document;if(b.nodeType!==1&&b.nodeType!==9){return[]}if(!a||typeof a!=="string"){return c}var f=[],m,set,checkSet,extra,prune=true,contextXML=t(b),soFar=a;while((j.exec(""),m=j.exec(soFar))!==null){soFar=m[3];f.push(m[1]);if(m[2]){extra=m[3];break}}if(f.length>1&&o.exec(a)){if(f.length===2&&n.relative[f[0]]){set=u(f[0]+f[1],b)}else{set=n.relative[f[0]]?[b]:k(f.shift(),b);while(f.length){a=f.shift();if(n.relative[a]){a+=f.shift()}set=u(a,set)}}}else{if(!d&&f.length>1&&b.nodeType===9&&!contextXML&&n.match.ID.test(f[0])&&!n.match.ID.test(f[f.length-1])){var g=k.find(f.shift(),b,contextXML);b=g.expr?k.filter(g.expr,g.set)[0]:g.set[0]}if(b){var g=d?{expr:f.pop(),set:q(d)}:k.find(f.pop(),f.length===1&&(f[0]==="~"||f[0]==="+")&&b.parentNode?b.parentNode:b,contextXML);set=g.expr?k.filter(g.expr,g.set):g.set;if(f.length>0){checkSet=q(set)}else{prune=false}while(f.length){var h=f.pop(),pop=h;if(!n.relative[h]){h=""}else{pop=f.pop()}if(pop==null){pop=b}n.relative[h](checkSet,pop,contextXML)}}else{checkSet=f=[]}}if(!checkSet){checkSet=set}if(!checkSet){throw"Syntax error, unrecognized expression: "+(h||a);}if(toString.call(checkSet)==="[object Array]"){if(!prune){c.push.apply(c,checkSet)}else if(b&&b.nodeType===1){for(var i=0;checkSet[i]!=null;i++){if(checkSet[i]&&(checkSet[i]===true||checkSet[i].nodeType===1&&s(b,checkSet[i]))){c.push(set[i])}}}else{for(var i=0;checkSet[i]!=null;i++){if(checkSet[i]&&checkSet[i].nodeType===1){c.push(set[i])}}}}else{q(checkSet,c)}if(extra){k(extra,e,c,d);k.uniqueSort(c)}return c};k.uniqueSort=function(a){if(r){hasDuplicate=baseHasDuplicate;a.sort(r);if(hasDuplicate){for(var i=1;i<a.length;i++){if(a[i]===a[i-1]){a.splice(i--,1)}}}}return a};k.matches=function(a,b){return k(a,null,null,b)};k.find=function(a,b,c){var d,match;if(!a){return[]}for(var i=0,l=n.order.length;i<l;i++){var e=n.order[i],match;if((match=n.leftMatch[e].exec(a))){var f=match[1];match.splice(1,1);if(f.substr(f.length-1)!=="\\"){match[1]=(match[1]||"").replace(/\\/g,"");d=n.find[e](match,b,c);if(d!=null){a=a.replace(n.match[e],"");break}}}}if(!d){d=b.getElementsByTagName("*")}return{set:d,expr:a}};k.filter=function(a,b,c,d){var e=a,result=[],curLoop=b,match,anyFound,isXMLFilter=b&&b[0]&&t(b[0]);while(a&&b.length){for(var f in n.filter){if((match=n.match[f].exec(a))!=null){var g=n.filter[f],found,item;anyFound=false;if(curLoop===result){result=[]}if(n.preFilter[f]){match=n.preFilter[f](match,curLoop,c,result,d,isXMLFilter);if(!match){anyFound=found=true}else if(match===true){continue}}if(match){for(var i=0;(item=curLoop[i])!=null;i++){if(item){found=g(item,match,i,curLoop);var h=d^!!found;if(c&&found!=null){if(h){anyFound=true}else{curLoop[i]=false}}else if(h){result.push(item);anyFound=true}}}}if(found!==undefined){if(!c){curLoop=result}a=a.replace(n.match[f],"");if(!anyFound){return[]}break}}}if(a===e){if(anyFound==null){throw"Syntax error, unrecognized expression: "+a;}else{break}}e=a}return curLoop};var n=k.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(a){return a.getAttribute("href")}},relative:{"+":function(a,b){var c=typeof b==="string",isTag=c&&!/\W/.test(b),isPartStrNotTag=c&&!isTag;if(isTag){b=b.toLowerCase()}for(var i=0,l=a.length,elem;i<l;i++){if((elem=a[i])){while((elem=elem.previousSibling)&&elem.nodeType!==1){}a[i]=isPartStrNotTag||elem&&elem.nodeName.toLowerCase()===b?elem||false:elem===b}}if(isPartStrNotTag){k.filter(b,a,true)}},">":function(a,b){var c=typeof b==="string";if(c&&!/\W/.test(b)){b=b.toLowerCase();for(var i=0,l=a.length;i<l;i++){var d=a[i];if(d){var e=d.parentNode;a[i]=e.nodeName.toLowerCase()===b?e:false}}}else{for(var i=0,l=a.length;i<l;i++){var d=a[i];if(d){a[i]=c?d.parentNode:d.parentNode===b}}if(c){k.filter(b,a,true)}}},"":function(a,b,c){var d=done++,checkFn=dirCheck;if(typeof b==="string"&&!/\W/.test(b)){var e=b=b.toLowerCase();checkFn=dirNodeCheck}checkFn("parentNode",b,d,a,e,c)},"~":function(a,b,c){var d=done++,checkFn=dirCheck;if(typeof b==="string"&&!/\W/.test(b)){var e=b=b.toLowerCase();checkFn=dirNodeCheck}checkFn("previousSibling",b,d,a,e,c)}},find:{ID:function(a,b,c){if(typeof b.getElementById!=="undefined"&&!c){var m=b.getElementById(a[1]);return m?[m]:[]}},NAME:function(a,b){if(typeof b.getElementsByName!=="undefined"){var c=[],results=b.getElementsByName(a[1]);for(var i=0,l=results.length;i<l;i++){if(results[i].getAttribute("name")===a[1]){c.push(results[i])}}return c.length===0?null:c}},TAG:function(a,b){return b.getElementsByTagName(a[1])}},preFilter:{CLASS:function(a,b,c,d,e,f){a=" "+a[1].replace(/\\/g,"")+" ";if(f){return a}for(var i=0,elem;(elem=b[i])!=null;i++){if(elem){if(e^(elem.className&&(" "+elem.className+" ").replace(/[\t\n]/g," ").indexOf(a)>=0)){if(!c){d.push(elem)}}else if(c){b[i]=false}}}return false},ID:function(a){return a[1].replace(/\\/g,"")},TAG:function(a,b){return a[1].toLowerCase()},CHILD:function(a){if(a[1]==="nth"){var b=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=(b[1]+(b[2]||1))-0;a[3]=b[3]-0}a[0]=done++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1].replace(/\\/g,"");if(!f&&n.attrMap[g]){a[1]=n.attrMap[g]}if(a[2]==="~="){a[4]=" "+a[4]+" "}return a},PSEUDO:function(a,b,c,d,e){if(a[1]==="not"){if((j.exec(a[3])||"").length>1||/^\w/.test(a[3])){a[3]=k(a[3],null,null,b)}else{var f=k.filter(a[3],b,c,true^e);if(!c){d.push.apply(d,f)}return false}}else if(n.match.POS.test(a[0])||n.match.CHILD.test(a[0])){return true}return a},POS:function(a){a.unshift(true);return a}},filters:{enabled:function(a){return a.disabled===false&&a.type!=="hidden"},disabled:function(a){return a.disabled===true},checked:function(a){return a.checked===true},selected:function(a){a.parentNode.selectedIndex;return a.selected===true},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,i,b){return!!k(b[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){return"text"===a.type},radio:function(a){return"radio"===a.type},checkbox:function(a){return"checkbox"===a.type},file:function(a){return"file"===a.type},password:function(a){return"password"===a.type},submit:function(a){return"submit"===a.type},image:function(a){return"image"===a.type},reset:function(a){return"reset"===a.type},button:function(a){return"button"===a.type||a.nodeName.toLowerCase()==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)}},setFilters:{first:function(a,i){return i===0},last:function(a,i,b,c){return i===c.length-1},even:function(a,i){return i%2===0},odd:function(a,i){return i%2===1},lt:function(a,i,b){return i<b[3]-0},gt:function(a,i,b){return i>b[3]-0},nth:function(a,i,b){return b[3]-0===i},eq:function(a,i,b){return b[3]-0===i}},filter:{PSEUDO:function(a,b,i,c){var d=b[1],filter=n.filters[d];if(filter){return filter(a,i,b,c)}else if(d==="contains"){return(a.textContent||a.innerText||getText([a])||"").indexOf(b[3])>=0}else if(d==="not"){var e=b[3];for(var i=0,l=e.length;i<l;i++){if(e[i]===a){return false}}return true}else{throw"Syntax error, unrecognized expression: "+d;}},CHILD:function(a,b){var c=b[1],node=a;switch(c){case'only':case'first':while((node=node.previousSibling)){if(node.nodeType===1){return false}}if(c==="first"){return true}node=a;case'last':while((node=node.nextSibling)){if(node.nodeType===1){return false}}return true;case'nth':var d=b[2],last=b[3];if(d===1&&last===0){return true}var e=b[0],parent=a.parentNode;if(parent&&(parent.sizcache!==e||!a.nodeIndex)){var f=0;for(node=parent.firstChild;node;node=node.nextSibling){if(node.nodeType===1){node.nodeIndex=++f}}parent.sizcache=e}var g=a.nodeIndex-last;if(d===0){return g===0}else{return(g%d===0&&g/d>=0)}}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return(b==="*"&&a.nodeType===1)||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],result=n.attrHandle[c]?n.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),value=result+"",p=b[2],check=b[4];return result==null?p==="!=":p==="="?value===check:p==="*="?value.indexOf(check)>=0:p==="~="?(" "+value+" ").indexOf(check)>=0:!check?value&&result!==false:p==="!="?value!==check:p==="^="?value.indexOf(check)===0:p==="$="?value.substr(value.length-check.length)===check:p==="|="?value===check||value.substr(0,check.length+1)===check+"-":false},POS:function(a,b,i,c){var d=b[2],filter=n.setFilters[d];if(filter){return filter(a,i,b,c)}}}};var o=n.match.POS;for(var p in n.match){n.match[p]=new RegExp(n.match[p].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[p]=new RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[p].source)}var q=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(document.documentElement.childNodes,0)}catch(e){q=function(a,b){var c=b||[];if(toString.call(a)==="[object Array]"){Array.prototype.push.apply(c,a)}else{if(typeof a.length==="number"){for(var i=0,l=a.length;i<l;i++){c.push(a[i])}}else{for(var i=0;a[i];i++){c.push(a[i])}}}return c}}var r;if(document.documentElement.compareDocumentPosition){r=function(a,b){if(!a.compareDocumentPosition||!b.compareDocumentPosition){if(a==b){hasDuplicate=true}return a.compareDocumentPosition?-1:1}var c=a.compareDocumentPosition(b)&4?-1:a===b?0:1;if(c===0){hasDuplicate=true}return c}}else if("sourceIndex"in document.documentElement){r=function(a,b){if(!a.sourceIndex||!b.sourceIndex){if(a==b){hasDuplicate=true}return a.sourceIndex?-1:1}var c=a.sourceIndex-b.sourceIndex;if(c===0){hasDuplicate=true}return c}}else if(document.createRange){r=function(a,b){if(!a.ownerDocument||!b.ownerDocument){if(a==b){hasDuplicate=true}return a.ownerDocument?-1:1}var c=a.ownerDocument.createRange(),bRange=b.ownerDocument.createRange();c.setStart(a,0);c.setEnd(a,0);bRange.setStart(b,0);bRange.setEnd(b,0);var d=c.compareBoundaryPoints(Range.START_TO_END,bRange);if(d===0){hasDuplicate=true}return d}}function getText(a){var b="",elem;for(var i=0;a[i];i++){elem=a[i];if(elem.nodeType===3||elem.nodeType===4){b+=elem.nodeValue}else if(elem.nodeType!==8){b+=getText(elem.childNodes)}}return b}(function(){var d=document.createElement("div"),id="script"+(new Date).getTime();d.innerHTML="<a name='"+id+"'/>";var e=document.documentElement;e.insertBefore(d,e.firstChild);if(document.getElementById(id)){n.find.ID=function(a,b,c){if(typeof b.getElementById!=="undefined"&&!c){var m=b.getElementById(a[1]);return m?m.id===a[1]||typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id").nodeValue===a[1]?[m]:undefined:[]}};n.filter.ID=function(a,b){var c=typeof a.getAttributeNode!=="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}}e.removeChild(d);e=d=null})();(function(){var e=document.createElement("div");e.appendChild(document.createComment(""));if(e.getElementsByTagName("*").length>0){n.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var i=0;c[i];i++){if(c[i].nodeType===1){d.push(c[i])}}c=d}return c}}e.innerHTML="<a href='#'></a>";if(e.firstChild&&typeof e.firstChild.getAttribute!=="undefined"&&e.firstChild.getAttribute("href")!=="#"){n.attrHandle.href=function(a){return a.getAttribute("href",2)}}e=null})();if(document.querySelectorAll){(function(){var f=k,div=document.createElement("div");div.innerHTML="<p class='TEST'></p>";if(div.querySelectorAll&&div.querySelectorAll(".TEST").length===0){return}k=function(a,b,c,d){b=b||document;if(!d&&b.nodeType===9&&!t(b)){try{return q(b.querySelectorAll(a),c)}catch(e){}}return f(a,b,c,d)};for(var g in f){k[g]=f[g]}div=null})()}(function(){var d=document.createElement("div");d.innerHTML="<div class='test e'></div><div class='test'></div>";if(!d.getElementsByClassName||d.getElementsByClassName("e").length===0){return}d.lastChild.className="e";if(d.getElementsByClassName("e").length===1){return}n.order.splice(1,0,"CLASS");n.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!=="undefined"&&!c){return b.getElementsByClassName(a[1])}};d=null})();function dirNodeCheck(a,b,c,d,e,f){for(var i=0,l=d.length;i<l;i++){var g=d[i];if(g){g=g[a];var h=false;while(g){if(g.sizcache===c){h=d[g.sizset];break}if(g.nodeType===1&&!f){g.sizcache=c;g.sizset=i}if(g.nodeName.toLowerCase()===b){h=g;break}g=g[a]}d[i]=h}}}function dirCheck(a,b,c,d,e,f){for(var i=0,l=d.length;i<l;i++){var g=d[i];if(g){g=g[a];var h=false;while(g){if(g.sizcache===c){h=d[g.sizset];break}if(g.nodeType===1){if(!f){g.sizcache=c;g.sizset=i}if(typeof b!=="string"){if(g===b){h=true;break}}else if(k.filter(b,[g]).length>0){h=g;break}}g=g[a]}d[i]=h}}}var s=document.compareDocumentPosition?function(a,b){return a.compareDocumentPosition(b)&16}:function(a,b){return a!==b&&(a.contains?a.contains(b):true)};var t=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":false};var u=function(a,b){var c=[],later="",match,root=b.nodeType?[b]:b;while((match=n.match.PSEUDO.exec(a))){later+=match[0];a=a.replace(n.match.PSEUDO,"")}a=n.relative[a]?a+"*":a;for(var i=0,l=root.length;i<l;i++){k(a,root[i],c)}return k.filter(later,c)};window.Sizzle=k})();