Skip to content

Instantly share code, notes, and snippets.

@tobsn
Created April 8, 2011 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobsn/910241 to your computer and use it in GitHub Desktop.
Save tobsn/910241 to your computer and use it in GitHub Desktop.
Sizzle Closure Compiled - Sizzle() becomes A()
var l=null;
(function(){function z(a,b){for(var c,d=[],f="",e=b.nodeType?[b]:b;c=j.match.c.exec(a);)f+=c[0],a=a.replace(j.match.c,"");a=j.b[a]?a+"*":a;c=0;for(var h=e.length;c<h;c++)i(a,e[c],d);return i.filter(f,d)}function n(a,b){a=Array.prototype.slice.call(a,0);if(b)return b.push.apply(b,a),b;return a}function F(a,b){return"\\"+(b-0+1)}function i(a,b,c,d){var c=c||[],f=b=b||document;if(b.nodeType!==1&&b.nodeType!==9)return[];if(!a||typeof a!=="string")return c;var e,h,g,m,t,o=!0,p=i.i(b),k=[],q=a;do if(x.exec(""),
e=x.exec(q))if(q=e[3],k.push(e[1]),e[2]){m=e[3];break}while(e);if(k.length>1&&G.exec(a))if(k.length===2&&j.b[k[0]])h=z(k[0]+k[1],b);else for(h=j.b[k[0]]?[b]:i(k.shift(),b);k.length;)a=k.shift(),j.b[a]&&(a+=k.shift()),h=z(a,h);else if(!d&&k.length>1&&b.nodeType===9&&!p&&j.match.a.test(k[0])&&!j.match.a.test(k[k.length-1])&&(e=i.find(k.shift(),b,p),b=e.d?i.filter(e.d,e.set)[0]:e.set[0]),b){e=d?{d:k.pop(),set:n(d)}:i.find(k.pop(),k.length===1&&(k[0]==="~"||k[0]==="+")&&b.parentNode?b.parentNode:b,p);
h=e.d?i.filter(e.d,e.set):e.set;for(k.length>0?g=n(h):o=!1;k.length;)e=t=k.pop(),j.b[t]?e=k.pop():t="",e==l&&(e=b),j.b[t](g,e,p)}else g=[];g||(g=h);g||i.error(t||a);if(B.call(g)==="[object Array]")if(o)if(b&&b.nodeType===1)for(a=0;g[a]!=l;a++)g[a]&&(g[a]===!0||g[a].nodeType===1&&i.contains(b,g[a]))&&c.push(h[a]);else for(a=0;g[a]!=l;a++)g[a]&&g[a].nodeType===1&&c.push(h[a]);else c.push.apply(c,g);else n(g,c);m&&(i(m,f,c,d),i.z(c));return c}function C(a,b,c,d,f,e){for(var f=0,h=d.length;f<h;f++){var g=
d[f];if(g){for(var i=!1,g=g[a];g;){if(g.e===c){i=d[g.n];break}if(g.nodeType===1&&!e)g.e=c,g.n=f;if(g.nodeName.toLowerCase()===b){i=g;break}g=g[a]}d[f]=i}}}function D(a,b,c,d,f,e){for(var f=0,h=d.length;f<h;f++){var g=d[f];if(g){for(var j=!1,g=g[a];g;){if(g.e===c){j=d[g.n];break}if(g.nodeType===1){if(!e)g.e=c,g.n=f;if(typeof b!=="string"){if(g===b){j=!0;break}}else if(i.filter(b,[g]).length>0){j=g;break}}g=g[a]}d[f]=j}}}var x=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
y=0,B=Object.prototype.toString,u=!1,E=!0,q=/\\/g,v=/\W/;[0,0].sort(function(){E=!1;return 0});i.z=function(a){if(w&&(u=E,a.sort(w),u))for(var b=1;b<a.length;b++)a[b]===a[b-1]&&a.splice(b--,1)};i.M=function(a,b){return i(a,l,l,b)};i.r=function(a,b){return i(b,l,l,[a]).length>0};i.find=function(a,b,c){var d;if(!a)return[];for(var f=0,e=j.m.length;f<e;f++){var h,g=j.m[f];if(h=j.l[g].exec(a)){var i=h[1];h.splice(1,1);if(i.substr(i.length-1)!=="\\"&&(h[1]=(h[1]||"").replace(q,""),d=j.find[g](h,b,c),d!=
l)){a=a.replace(j.match[g],"");break}}}d||(d=typeof b.getElementsByTagName!=="undefined"?b.getElementsByTagName("*"):[]);return{set:d,d:a}};i.filter=function(a,b,c,d){for(var f,e,h=a,g=[],m=b,n=b&&b[0]&&i.i(b[0]);a&&b.length;){for(var o in j.filter)if((f=j.l[o].exec(a))!=l&&f[2]){var p,k,q=j.filter[o];k=f[1];e=!1;f.splice(1,1);if(k.substr(k.length-1)!=="\\"){m===g&&(g=[]);if(j.t[o])if(f=j.t[o](f,m,c,g,d,n)){if(f===!0)continue}else e=p=!0;if(f)for(var r=0;(k=m[r])!=l;r++)if(k){p=q(k,f,r,m);var s=d^
!!p;c&&p!=l?s?e=!0:m[r]=!1:s&&(g.push(k),e=!0)}if(p!==void 0){c||(m=g);a=a.replace(j.match[o],"");if(!e)return[];break}}}if(a===h)if(e==l)i.error(a);else break;h=a}return m};i.error=function(a){throw"Syntax error, unrecognized expression: "+a;};var j=i.T={m:["ID","NAME","TAG"],match:{a:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,f:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,u:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,o:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
h:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,j:/:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,g:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,c:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},l:{},p:{"class":"className","for":"htmlFor"},k:{href:function(a){return a.getAttribute("href")},type:function(a){return a.getAttribute("type")}},b:{"+":function(a,b){var c=typeof b==="string",d=c&&!v.test(b),c=
c&&!d;d&&(b=b.toLowerCase());for(var d=0,f=a.length,e;d<f;d++)if(e=a[d]){for(;(e=e.previousSibling)&&e.nodeType!==1;);a[d]=c||e&&e.nodeName.toLowerCase()===b?e||!1:e===b}c&&i.filter(b,a,!0)},">":function(a,b){var c,d=typeof b==="string",f=0,e=a.length;if(d&&!v.test(b))for(b=b.toLowerCase();f<e;f++){if(c=a[f])c=c.parentNode,a[f]=c.nodeName.toLowerCase()===b?c:!1}else{for(;f<e;f++)(c=a[f])&&(a[f]=d?c.parentNode:c.parentNode===b);d&&i.filter(b,a,!0)}},"":function(a,b,c){var d,f=y++,e=D;typeof b==="string"&&
!v.test(b)&&(d=b=b.toLowerCase(),e=C);e("parentNode",b,f,a,d,c)},"~":function(a,b,c){var d,f=y++,e=D;typeof b==="string"&&!v.test(b)&&(d=b=b.toLowerCase(),e=C);e("previousSibling",b,f,a,d,c)}},find:{a:function(a,b,c){if(typeof b.getElementById!=="undefined"&&!c)return(a=b.getElementById(a[1]))&&a.parentNode?[a]:[]},u:function(a,b){if(typeof b.getElementsByName!=="undefined"){for(var c=[],d=b.getElementsByName(a[1]),f=0,e=d.length;f<e;f++)d[f].getAttribute("name")===a[1]&&c.push(d[f]);return c.length===
0?l:c}},h:function(a,b){if(typeof b.getElementsByTagName!=="undefined")return b.getElementsByTagName(a[1])}},t:{f:function(a,b,c,d,f,e){a=" "+a[1].replace(q,"")+" ";if(e)return a;for(var e=0,h;(h=b[e])!=l;e++)h&&(f^(h.className&&(" "+h.className+" ").replace(/[\t\n\r]/g," ").indexOf(a)>=0)?c||d.push(h):c&&(b[e]=!1));return!1},a:function(a){return a[1].replace(q,"")},h:function(a){return a[1].replace(q,"").toLowerCase()},j:function(a){if(a[1]==="nth"){a[2]||i.error(a[0]);a[2]=a[2].replace(/^\+|\s*/g,
"");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}else a[2]&&i.error(a[0]);a[0]=y++;return a},o:function(a,b,c,d,f,e){b=a[1]=a[1].replace(q,"");!e&&j.p[b]&&(a[1]=j.p[b]);a[4]=(a[4]||a[5]||"").replace(q,"");a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},c:function(a,b,c,d,f){if(a[1]==="not")if((x.exec(a[3])||"").length>1||/^\w/.test(a[3]))a[3]=i(a[3],l,l,b);else return a=i.filter(a[3],b,c,1^f),c||
d.push.apply(d,a),!1;else if(j.match.g.test(a[0])||j.match.j.test(a[0]))return!0;return a},g:function(a){a.unshift(!0);return a}},v:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},H:function(a,b,c){return!!i(c[3],a).length},I:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=
a.getAttribute("type"),a=a.type;return"text"===a&&(b===a||b===l)},S:function(a){return"radio"===a.type},B:function(a){return"checkbox"===a.type},file:function(a){return"file"===a.type},R:function(a){return"password"===a.type},submit:function(a){return"submit"===a.type},J: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)}},
w:{F:function(a,b){return b===0},K:function(a,b,c,d){return b===d.length-1},D:function(a,b){return b%2===0},Q:function(a,b){return b%2===1},L:function(a,b,c){return b<c[3]-0},G:function(a,b,c){return b>c[3]-0},P:function(a,b,c){return c[3]-0===b},C:function(a,b,c){return c[3]-0===b}},filter:{c:function(a,b,c,d){var f=b[1],e=j.v[f];if(e)return e(a,c,b,d);else if(f==="contains")return(a.textContent||a.innerText||i.q([a])||"").indexOf(b[3])>=0;else if(f==="not"){b=b[3];c=0;for(d=b.length;c<d;c++)if(b[c]===
a)return!1;return!0}else i.error(f)},j:function(a,b){var c=b[1],d=a;switch(c){case "only":case "first":for(;d=d.previousSibling;)if(d.nodeType===1)return!1;if(c==="first")return!0;d=a;case "last":for(;d=d.nextSibling;)if(d.nodeType===1)return!1;return!0;case "nth":var c=b[2],f=b[3];if(c===1&&f===0)return!0;var e=b[0],h=a.parentNode;if(h&&(h.e!==e||!a.s)){for(var g=0,d=h.firstChild;d;d=d.nextSibling)if(d.nodeType===1)d.s=++g;h.e=e}d=a.s-f;return c===0?d===0:d%c===0&&d/c>=0}},a:function(a,b){return a.nodeType===
1&&a.getAttribute("id")===b},h:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},f:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},o:function(a,b){var c=b[1],c=j.k[c]?j.k[c](a):a[c]!=l?a[c]:a.getAttribute(c),d=c+"",f=b[2],e=b[4];return c==l?f==="!=":f==="="?d===e:f==="*="?d.indexOf(e)>=0:f==="~="?(" "+d+" ").indexOf(e)>=0:!e?d&&c!==!1:f==="!="?d!==e:f==="^="?d.indexOf(e)===0:f==="$="?d.substr(d.length-e.length)===e:f==="|="?d===e||d.substr(0,
e.length+1)===e+"-":!1},g:function(a,b,c,d){var f=j.w[b[2]];if(f)return f(a,c,b,d)}}},G=j.match.g,r;for(r in j.match)j.match[r]=RegExp(j.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),j.l[r]=RegExp(/(^(?:.|\r|\n)*?)/.source+j.match[r].source.replace(/\\(\d+)/g,F));try{Array.prototype.slice.call(document.documentElement.childNodes,0)}catch(H){n=function(a,b){var c=0,d=b||[];if(B.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length==="number")for(var f=a.length;c<f;c++)d.push(a[c]);
else for(;a[c];c++)d.push(a[c]);return d}}var w,s;document.documentElement.compareDocumentPosition?w=function(a,b){if(a===b)return u=!0,0;if(!a.compareDocumentPosition||!b.compareDocumentPosition)return a.compareDocumentPosition?-1:1;return a.compareDocumentPosition(b)&4?-1:1}:(w=function(a,b){var c,d,f=[],e=[];c=a.parentNode;d=b.parentNode;var h=c;if(a===b)return u=!0,0;else if(c===d)return s(a,b);else if(c){if(!d)return 1}else return-1;for(;h;)f.unshift(h),h=h.parentNode;for(h=d;h;)e.unshift(h),
h=h.parentNode;c=f.length;d=e.length;for(h=0;h<c&&h<d;h++)if(f[h]!==e[h])return s(f[h],e[h]);return h===c?s(a,e[h],-1):s(f[h],b,1)},s=function(a,b,c){if(a===b)return c;for(a=a.nextSibling;a;){if(a===b)return-1;a=a.nextSibling}return 1});i.q=function(a){for(var b="",c,d=0;a[d];d++)c=a[d],c.nodeType===3||c.nodeType===4?b+=c.nodeValue:c.nodeType!==8&&(b+=i.q(c.childNodes));return b};(function(){var a=document.createElement("div"),b="script"+(new Date).getTime(),c=document.documentElement;a.innerHTML=
"<a name='"+b+"'/>";c.insertBefore(a,c.firstChild);if(document.getElementById(b))j.find.a=function(a,b,c){if(typeof b.getElementById!=="undefined"&&!c)return(b=b.getElementById(a[1]))?b.id===a[1]||typeof b.getAttributeNode!=="undefined"&&b.getAttributeNode("id").nodeValue===a[1]?[b]:void 0:[]},j.filter.a=function(a,b){var c=typeof a.getAttributeNode!=="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b};c.removeChild(a);c=a=l})();(function(){var a=document.createElement("div");
a.appendChild(document.createComment(""));if(a.getElementsByTagName("*").length>0)j.find.h=function(a,c){var d=c.getElementsByTagName(a[1]);if(a[1]==="*"){for(var f=[],e=0;d[e];e++)d[e].nodeType===1&&f.push(d[e]);d=f}return d};a.innerHTML="<a href='#'></a>";if(a.firstChild&&typeof a.firstChild.getAttribute!=="undefined"&&a.firstChild.getAttribute("href")!=="#")j.k.href=function(a){return a.getAttribute("href",2)};a=l})();document.querySelectorAll&&function(){var a=i,b=document.createElement("div");
b.innerHTML="<p class='TEST'></p>";if(!(b.querySelectorAll&&b.querySelectorAll(".TEST").length===0)){i=function(b,c,e,h){c=c||document;if(!h&&!i.i(c)){var g=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(g&&(c.nodeType===1||c.nodeType===9))if(g[1])return n(c.getElementsByTagName(b),e);else if(g[2]&&j.find.f&&c.getElementsByClassName)return n(c.getElementsByClassName(g[2]),e);if(c.nodeType===9){if(b==="body"&&c.body)return n([c.body],e);else if(g&&g[3]){var m=c.getElementById(g[3]);if(m&&m.parentNode){if(m.id===
g[3])return n([m],e)}else return n([],e)}try{return n(c.querySelectorAll(b),e)}catch(q){}}else if(c.nodeType===1&&c.nodeName.toLowerCase()!=="object"){var g=c,o=(m=c.getAttribute("id"))||"__sizzle__",p=c.parentNode,k=/^\s*[+~]/.test(b);m?o=o.replace(/'/g,"\\$&"):c.setAttribute("id",o);if(k&&p)c=c.parentNode;try{if(!k||p)return n(c.querySelectorAll("[id='"+o+"'] "+b),e)}catch(r){}finally{m||g.removeAttribute("id")}}}return a(b,c,e,h)};for(var c in a)i[c]=a[c];b=l}}();(function(){var a=document.documentElement,
b=a.r||a.N||a.U||a.O;if(b){var c=!b.call(document.createElement("div"),"div"),d=!1;try{b.call(document.documentElement,"[test!='']:sizzle")}catch(f){d=!0}i.r=function(a,f){f=f.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!i.i(a))try{if(d||!j.match.c.test(f)&&!/!=/.test(f)){var g=b.call(a,f);if(g||!c||a.document&&a.document.nodeType!==11)return g}}catch(m){}return i(f,l,l,[a]).length>0}}})();(function(){var a=document.createElement("div");a.innerHTML="<div class='test e'></div><div class='test'></div>";
if(a.getElementsByClassName&&a.getElementsByClassName("e").length!==0&&(a.lastChild.className="e",a.getElementsByClassName("e").length!==1))j.m.splice(1,0,"CLASS"),j.find.f=function(a,c,d){if(typeof c.getElementsByClassName!=="undefined"&&!d)return c.getElementsByClassName(a[1])},a=l})();i.contains=document.documentElement.contains?function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:document.documentElement.compareDocumentPosition?function(a,b){return!!(a.compareDocumentPosition(b)&16)}:function(){return!1};
i.i=function(a){return(a=(a?a.ownerDocument||a:0).documentElement)?a.nodeName!=="HTML":!1};window.A=i})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment