-
Notifications
You must be signed in to change notification settings - Fork 19
/
satisfy.min.js
17 lines (17 loc) · 2.33 KB
/
satisfy.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
Satisfy - made to satisfy CSS selectors
Copyright (c) 2009 James Padolsey
-------------------------------------------------------
Dual licensed under the MIT and GPL licenses.
- http://www.opensource.org/licenses/mit-license.php
- http://www.gnu.org/copyleft/gpl.html
-------------------------------------------------------
Version: 0.3
-------------------------------------------------------
(most) Regular Expressions are Copyright (c) John Resig,
from the Sizzle Selector Engine.
*/
(function(f){var l=f();"object"===typeof exports?module.exports=l:"function"===typeof define&&define.amd?define(f):window.satisfy=l;void 0!==window.jQuery&&jQuery.fn&&(jQuery.satisfy=function(k){return jQuery(l(k))})})(function(){function f(b){if(b in p)return p[b].cloneNode(!0).childNodes;for(var d=[],e=q.createDocumentFragment(),c,f,a,h=1,t=0,u=!1,n;null!==(m=l.exec(b));)++t,d.push(m[1]);for(;t--;)if(a=d[t],k.COMBINATOR.test(a))u="~"===a||"+"===a;else{h=(n=a.match(k.CLONE))?~~n[1]:1;f=c;c=a;a=k.TAG.exec(c);
a=q.createElement(a&&"*"!==a[1]?a[1]:"div");for(var g=q.createDocumentFragment(),w=v.length,r=void 0,s=void 0,x=void 0;w--;)if(s=k[v[w]],x=y[v[w]],s.global)for(;null!==(r=s.exec(c));)x(r,a);else(r=s.exec(c))&&x(r,a);for(;h--;)g.appendChild(a.cloneNode(!0));c=g;if(f)if(u)c.appendChild(f),u=!1;else{h=c;h=h.childNodes;a=h.length;for(g=void 0;a--;)g=h[a],"table"===g.nodeName.toLowerCase()&&g.appendChild(g=q.createElement("tbody")),g.appendChild(f.cloneNode(!0))}}e.appendChild(c);p[b]=e.cloneNode(!0);
return e.childNodes}var l=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,k={ID:/#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?![^[\]]+])/g,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/g,TAG:/^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,CLONE:/\:(\d+)(?=$|[:[])/,COMBINATOR:/^[>~+]$/},q=document,p={},n={"for":"htmlFor","class":"className",
html:"innerHTML"},v=["ID","CLASS","NAME","ATTR"],y={ID:function(b,d){d.id=b[1]},CLASS:function(b,d){var e=d.className.replace(/^\s+$/,"");d.className=e?e+" "+b[1]:b[1]},NAME:function(b,d){d.name=b[1]},ATTR:function(b,d){var e=b[1],c=b[4]||!0;!0===c||"innerHTML"===e||n.hasOwnProperty(e)?d[n[e]||e]=c:d.setAttribute(e,c)}};f.cache=p;return f});