sizzle.js 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272
  1. /*!
  2. * Sizzle CSS Selector Engine v2.3.3
  3. * https://sizzlejs.com/
  4. *
  5. * Copyright jQuery Foundation and other contributors
  6. * Released under the MIT license
  7. * http://jquery.org/license
  8. *
  9. * Date: 2016-08-08
  10. */
  11. (function( window ) {
  12. var i,
  13. support,
  14. Expr,
  15. getText,
  16. isXML,
  17. tokenize,
  18. compile,
  19. select,
  20. outermostContext,
  21. sortInput,
  22. hasDuplicate,
  23. // Local document vars
  24. setDocument,
  25. document,
  26. docElem,
  27. documentIsHTML,
  28. rbuggyQSA,
  29. rbuggyMatches,
  30. matches,
  31. contains,
  32. // Instance-specific data
  33. expando = "sizzle" + 1 * new Date(),
  34. preferredDoc = window.document,
  35. dirruns = 0,
  36. done = 0,
  37. classCache = createCache(),
  38. tokenCache = createCache(),
  39. compilerCache = createCache(),
  40. sortOrder = function( a, b ) {
  41. if ( a === b ) {
  42. hasDuplicate = true;
  43. }
  44. return 0;
  45. },
  46. // Instance methods
  47. hasOwn = ({}).hasOwnProperty,
  48. arr = [],
  49. pop = arr.pop,
  50. push_native = arr.push,
  51. push = arr.push,
  52. slice = arr.slice,
  53. // Use a stripped-down indexOf as it's faster than native
  54. // https://jsperf.com/thor-indexof-vs-for/5
  55. indexOf = function( list, elem ) {
  56. var i = 0,
  57. len = list.length;
  58. for ( ; i < len; i++ ) {
  59. if ( list[i] === elem ) {
  60. return i;
  61. }
  62. }
  63. return -1;
  64. },
  65. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  66. // Regular expressions
  67. // http://www.w3.org/TR/css3-selectors/#whitespace
  68. whitespace = "[\\x20\\t\\r\\n\\f]",
  69. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  70. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  71. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  72. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  73. // Operator (capture 2)
  74. "*([*^$|!~]?=)" + whitespace +
  75. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  76. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  77. "*\\]",
  78. pseudos = ":(" + identifier + ")(?:\\((" +
  79. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  80. // 1. quoted (capture 3; capture 4 or capture 5)
  81. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  82. // 2. simple (capture 6)
  83. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  84. // 3. anything else (capture 2)
  85. ".*" +
  86. ")\\)|)",
  87. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  88. rwhitespace = new RegExp( whitespace + "+", "g" ),
  89. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  90. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  91. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  92. rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
  93. rpseudo = new RegExp( pseudos ),
  94. ridentifier = new RegExp( "^" + identifier + "$" ),
  95. matchExpr = {
  96. "ID": new RegExp( "^#(" + identifier + ")" ),
  97. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  98. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  99. "ATTR": new RegExp( "^" + attributes ),
  100. "PSEUDO": new RegExp( "^" + pseudos ),
  101. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  102. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  103. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  104. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  105. // For use in libraries implementing .is()
  106. // We use this for POS matching in `select`
  107. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  108. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  109. },
  110. rinputs = /^(?:input|select|textarea|button)$/i,
  111. rheader = /^h\d$/i,
  112. rnative = /^[^{]+\{\s*\[native \w/,
  113. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  114. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  115. rsibling = /[+~]/,
  116. // CSS escapes
  117. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  118. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  119. funescape = function( _, escaped, escapedWhitespace ) {
  120. var high = "0x" + escaped - 0x10000;
  121. // NaN means non-codepoint
  122. // Support: Firefox<24
  123. // Workaround erroneous numeric interpretation of +"0x"
  124. return high !== high || escapedWhitespace ?
  125. escaped :
  126. high < 0 ?
  127. // BMP codepoint
  128. String.fromCharCode( high + 0x10000 ) :
  129. // Supplemental Plane codepoint (surrogate pair)
  130. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  131. },
  132. // CSS string/identifier serialization
  133. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  134. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  135. fcssescape = function( ch, asCodePoint ) {
  136. if ( asCodePoint ) {
  137. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  138. if ( ch === "\0" ) {
  139. return "\uFFFD";
  140. }
  141. // Control characters and (dependent upon position) numbers get escaped as code points
  142. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  143. }
  144. // Other potentially-special ASCII characters get backslash-escaped
  145. return "\\" + ch;
  146. },
  147. // Used for iframes
  148. // See setDocument()
  149. // Removing the function wrapper causes a "Permission Denied"
  150. // error in IE
  151. unloadHandler = function() {
  152. setDocument();
  153. },
  154. disabledAncestor = addCombinator(
  155. function( elem ) {
  156. return elem.disabled === true && ("form" in elem || "label" in elem);
  157. },
  158. { dir: "parentNode", next: "legend" }
  159. );
  160. // Optimize for push.apply( _, NodeList )
  161. try {
  162. push.apply(
  163. (arr = slice.call( preferredDoc.childNodes )),
  164. preferredDoc.childNodes
  165. );
  166. // Support: Android<4.0
  167. // Detect silently failing push.apply
  168. arr[ preferredDoc.childNodes.length ].nodeType;
  169. } catch ( e ) {
  170. push = { apply: arr.length ?
  171. // Leverage slice if possible
  172. function( target, els ) {
  173. push_native.apply( target, slice.call(els) );
  174. } :
  175. // Support: IE<9
  176. // Otherwise append directly
  177. function( target, els ) {
  178. var j = target.length,
  179. i = 0;
  180. // Can't trust NodeList.length
  181. while ( (target[j++] = els[i++]) ) {}
  182. target.length = j - 1;
  183. }
  184. };
  185. }
  186. function Sizzle( selector, context, results, seed ) {
  187. var m, i, elem, nid, match, groups, newSelector,
  188. newContext = context && context.ownerDocument,
  189. // nodeType defaults to 9, since context defaults to document
  190. nodeType = context ? context.nodeType : 9;
  191. results = results || [];
  192. // Return early from calls with invalid selector or context
  193. if ( typeof selector !== "string" || !selector ||
  194. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  195. return results;
  196. }
  197. // Try to shortcut find operations (as opposed to filters) in HTML documents
  198. if ( !seed ) {
  199. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  200. setDocument( context );
  201. }
  202. context = context || document;
  203. if ( documentIsHTML ) {
  204. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  205. // (excepting DocumentFragment context, where the methods don't exist)
  206. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  207. // ID selector
  208. if ( (m = match[1]) ) {
  209. // Document context
  210. if ( nodeType === 9 ) {
  211. if ( (elem = context.getElementById( m )) ) {
  212. // Support: IE, Opera, Webkit
  213. // TODO: identify versions
  214. // getElementById can match elements by name instead of ID
  215. if ( elem.id === m ) {
  216. results.push( elem );
  217. return results;
  218. }
  219. } else {
  220. return results;
  221. }
  222. // Element context
  223. } else {
  224. // Support: IE, Opera, Webkit
  225. // TODO: identify versions
  226. // getElementById can match elements by name instead of ID
  227. if ( newContext && (elem = newContext.getElementById( m )) &&
  228. contains( context, elem ) &&
  229. elem.id === m ) {
  230. results.push( elem );
  231. return results;
  232. }
  233. }
  234. // Type selector
  235. } else if ( match[2] ) {
  236. push.apply( results, context.getElementsByTagName( selector ) );
  237. return results;
  238. // Class selector
  239. } else if ( (m = match[3]) && support.getElementsByClassName &&
  240. context.getElementsByClassName ) {
  241. push.apply( results, context.getElementsByClassName( m ) );
  242. return results;
  243. }
  244. }
  245. // Take advantage of querySelectorAll
  246. if ( support.qsa &&
  247. !compilerCache[ selector + " " ] &&
  248. (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
  249. if ( nodeType !== 1 ) {
  250. newContext = context;
  251. newSelector = selector;
  252. // qSA looks outside Element context, which is not what we want
  253. // Thanks to Andrew Dupont for this workaround technique
  254. // Support: IE <=8
  255. // Exclude object elements
  256. } else if ( context.nodeName.toLowerCase() !== "object" ) {
  257. // Capture the context ID, setting it first if necessary
  258. if ( (nid = context.getAttribute( "id" )) ) {
  259. nid = nid.replace( rcssescape, fcssescape );
  260. } else {
  261. context.setAttribute( "id", (nid = expando) );
  262. }
  263. // Prefix every selector in the list
  264. groups = tokenize( selector );
  265. i = groups.length;
  266. while ( i-- ) {
  267. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  268. }
  269. newSelector = groups.join( "," );
  270. // Expand context for sibling selectors
  271. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  272. context;
  273. }
  274. if ( newSelector ) {
  275. try {
  276. push.apply( results,
  277. newContext.querySelectorAll( newSelector )
  278. );
  279. return results;
  280. } catch ( qsaError ) {
  281. } finally {
  282. if ( nid === expando ) {
  283. context.removeAttribute( "id" );
  284. }
  285. }
  286. }
  287. }
  288. }
  289. }
  290. // All others
  291. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  292. }
  293. /**
  294. * Create key-value caches of limited size
  295. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  296. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  297. * deleting the oldest entry
  298. */
  299. function createCache() {
  300. var keys = [];
  301. function cache( key, value ) {
  302. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  303. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  304. // Only keep the most recent entries
  305. delete cache[ keys.shift() ];
  306. }
  307. return (cache[ key + " " ] = value);
  308. }
  309. return cache;
  310. }
  311. /**
  312. * Mark a function for special use by Sizzle
  313. * @param {Function} fn The function to mark
  314. */
  315. function markFunction( fn ) {
  316. fn[ expando ] = true;
  317. return fn;
  318. }
  319. /**
  320. * Support testing using an element
  321. * @param {Function} fn Passed the created element and returns a boolean result
  322. */
  323. function assert( fn ) {
  324. var el = document.createElement("fieldset");
  325. try {
  326. return !!fn( el );
  327. } catch (e) {
  328. return false;
  329. } finally {
  330. // Remove from its parent by default
  331. if ( el.parentNode ) {
  332. el.parentNode.removeChild( el );
  333. }
  334. // release memory in IE
  335. el = null;
  336. }
  337. }
  338. /**
  339. * Adds the same handler for all of the specified attrs
  340. * @param {String} attrs Pipe-separated list of attributes
  341. * @param {Function} handler The method that will be applied
  342. */
  343. function addHandle( attrs, handler ) {
  344. var arr = attrs.split("|"),
  345. i = arr.length;
  346. while ( i-- ) {
  347. Expr.attrHandle[ arr[i] ] = handler;
  348. }
  349. }
  350. /**
  351. * Checks document order of two siblings
  352. * @param {Element} a
  353. * @param {Element} b
  354. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  355. */
  356. function siblingCheck( a, b ) {
  357. var cur = b && a,
  358. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  359. a.sourceIndex - b.sourceIndex;
  360. // Use IE sourceIndex if available on both nodes
  361. if ( diff ) {
  362. return diff;
  363. }
  364. // Check if b follows a
  365. if ( cur ) {
  366. while ( (cur = cur.nextSibling) ) {
  367. if ( cur === b ) {
  368. return -1;
  369. }
  370. }
  371. }
  372. return a ? 1 : -1;
  373. }
  374. /**
  375. * Returns a function to use in pseudos for input types
  376. * @param {String} type
  377. */
  378. function createInputPseudo( type ) {
  379. return function( elem ) {
  380. var name = elem.nodeName.toLowerCase();
  381. return name === "input" && elem.type === type;
  382. };
  383. }
  384. /**
  385. * Returns a function to use in pseudos for buttons
  386. * @param {String} type
  387. */
  388. function createButtonPseudo( type ) {
  389. return function( elem ) {
  390. var name = elem.nodeName.toLowerCase();
  391. return (name === "input" || name === "button") && elem.type === type;
  392. };
  393. }
  394. /**
  395. * Returns a function to use in pseudos for :enabled/:disabled
  396. * @param {Boolean} disabled true for :disabled; false for :enabled
  397. */
  398. function createDisabledPseudo( disabled ) {
  399. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  400. return function( elem ) {
  401. // Only certain elements can match :enabled or :disabled
  402. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  403. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  404. if ( "form" in elem ) {
  405. // Check for inherited disabledness on relevant non-disabled elements:
  406. // * listed form-associated elements in a disabled fieldset
  407. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  408. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  409. // * option elements in a disabled optgroup
  410. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  411. // All such elements have a "form" property.
  412. if ( elem.parentNode && elem.disabled === false ) {
  413. // Option elements defer to a parent optgroup if present
  414. if ( "label" in elem ) {
  415. if ( "label" in elem.parentNode ) {
  416. return elem.parentNode.disabled === disabled;
  417. } else {
  418. return elem.disabled === disabled;
  419. }
  420. }
  421. // Support: IE 6 - 11
  422. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  423. return elem.isDisabled === disabled ||
  424. // Where there is no isDisabled, check manually
  425. /* jshint -W018 */
  426. elem.isDisabled !== !disabled &&
  427. disabledAncestor( elem ) === disabled;
  428. }
  429. return elem.disabled === disabled;
  430. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  431. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  432. // even exist on them, let alone have a boolean value.
  433. } else if ( "label" in elem ) {
  434. return elem.disabled === disabled;
  435. }
  436. // Remaining elements are neither :enabled nor :disabled
  437. return false;
  438. };
  439. }
  440. /**
  441. * Returns a function to use in pseudos for positionals
  442. * @param {Function} fn
  443. */
  444. function createPositionalPseudo( fn ) {
  445. return markFunction(function( argument ) {
  446. argument = +argument;
  447. return markFunction(function( seed, matches ) {
  448. var j,
  449. matchIndexes = fn( [], seed.length, argument ),
  450. i = matchIndexes.length;
  451. // Match elements found at the specified indexes
  452. while ( i-- ) {
  453. if ( seed[ (j = matchIndexes[i]) ] ) {
  454. seed[j] = !(matches[j] = seed[j]);
  455. }
  456. }
  457. });
  458. });
  459. }
  460. /**
  461. * Checks a node for validity as a Sizzle context
  462. * @param {Element|Object=} context
  463. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  464. */
  465. function testContext( context ) {
  466. return context && typeof context.getElementsByTagName !== "undefined" && context;
  467. }
  468. // Expose support vars for convenience
  469. support = Sizzle.support = {};
  470. /**
  471. * Detects XML nodes
  472. * @param {Element|Object} elem An element or a document
  473. * @returns {Boolean} True iff elem is a non-HTML XML node
  474. */
  475. isXML = Sizzle.isXML = function( elem ) {
  476. // documentElement is verified for cases where it doesn't yet exist
  477. // (such as loading iframes in IE - #4833)
  478. var documentElement = elem && (elem.ownerDocument || elem).documentElement;
  479. return documentElement ? documentElement.nodeName !== "HTML" : false;
  480. };
  481. /**
  482. * Sets document-related variables once based on the current document
  483. * @param {Element|Object} [doc] An element or document object to use to set the document
  484. * @returns {Object} Returns the current document
  485. */
  486. setDocument = Sizzle.setDocument = function( node ) {
  487. var hasCompare, subWindow,
  488. doc = node ? node.ownerDocument || node : preferredDoc;
  489. // Return early if doc is invalid or already selected
  490. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  491. return document;
  492. }
  493. // Update global variables
  494. document = doc;
  495. docElem = document.documentElement;
  496. documentIsHTML = !isXML( document );
  497. // Support: IE 9-11, Edge
  498. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  499. if ( preferredDoc !== document &&
  500. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  501. // Support: IE 11, Edge
  502. if ( subWindow.addEventListener ) {
  503. subWindow.addEventListener( "unload", unloadHandler, false );
  504. // Support: IE 9 - 10 only
  505. } else if ( subWindow.attachEvent ) {
  506. subWindow.attachEvent( "onunload", unloadHandler );
  507. }
  508. }
  509. /* Attributes
  510. ---------------------------------------------------------------------- */
  511. // Support: IE<8
  512. // Verify that getAttribute really returns attributes and not properties
  513. // (excepting IE8 booleans)
  514. support.attributes = assert(function( el ) {
  515. el.className = "i";
  516. return !el.getAttribute("className");
  517. });
  518. /* getElement(s)By*
  519. ---------------------------------------------------------------------- */
  520. // Check if getElementsByTagName("*") returns only elements
  521. support.getElementsByTagName = assert(function( el ) {
  522. el.appendChild( document.createComment("") );
  523. return !el.getElementsByTagName("*").length;
  524. });
  525. // Support: IE<9
  526. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  527. // Support: IE<10
  528. // Check if getElementById returns elements by name
  529. // The broken getElementById methods don't pick up programmatically-set names,
  530. // so use a roundabout getElementsByName test
  531. support.getById = assert(function( el ) {
  532. docElem.appendChild( el ).id = expando;
  533. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  534. });
  535. // ID filter and find
  536. if ( support.getById ) {
  537. Expr.filter["ID"] = function( id ) {
  538. var attrId = id.replace( runescape, funescape );
  539. return function( elem ) {
  540. return elem.getAttribute("id") === attrId;
  541. };
  542. };
  543. Expr.find["ID"] = function( id, context ) {
  544. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  545. var elem = context.getElementById( id );
  546. return elem ? [ elem ] : [];
  547. }
  548. };
  549. } else {
  550. Expr.filter["ID"] = function( id ) {
  551. var attrId = id.replace( runescape, funescape );
  552. return function( elem ) {
  553. var node = typeof elem.getAttributeNode !== "undefined" &&
  554. elem.getAttributeNode("id");
  555. return node && node.value === attrId;
  556. };
  557. };
  558. // Support: IE 6 - 7 only
  559. // getElementById is not reliable as a find shortcut
  560. Expr.find["ID"] = function( id, context ) {
  561. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  562. var node, i, elems,
  563. elem = context.getElementById( id );
  564. if ( elem ) {
  565. // Verify the id attribute
  566. node = elem.getAttributeNode("id");
  567. if ( node && node.value === id ) {
  568. return [ elem ];
  569. }
  570. // Fall back on getElementsByName
  571. elems = context.getElementsByName( id );
  572. i = 0;
  573. while ( (elem = elems[i++]) ) {
  574. node = elem.getAttributeNode("id");
  575. if ( node && node.value === id ) {
  576. return [ elem ];
  577. }
  578. }
  579. }
  580. return [];
  581. }
  582. };
  583. }
  584. // Tag
  585. Expr.find["TAG"] = support.getElementsByTagName ?
  586. function( tag, context ) {
  587. if ( typeof context.getElementsByTagName !== "undefined" ) {
  588. return context.getElementsByTagName( tag );
  589. // DocumentFragment nodes don't have gEBTN
  590. } else if ( support.qsa ) {
  591. return context.querySelectorAll( tag );
  592. }
  593. } :
  594. function( tag, context ) {
  595. var elem,
  596. tmp = [],
  597. i = 0,
  598. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  599. results = context.getElementsByTagName( tag );
  600. // Filter out possible comments
  601. if ( tag === "*" ) {
  602. while ( (elem = results[i++]) ) {
  603. if ( elem.nodeType === 1 ) {
  604. tmp.push( elem );
  605. }
  606. }
  607. return tmp;
  608. }
  609. return results;
  610. };
  611. // Class
  612. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  613. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  614. return context.getElementsByClassName( className );
  615. }
  616. };
  617. /* QSA/matchesSelector
  618. ---------------------------------------------------------------------- */
  619. // QSA and matchesSelector support
  620. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  621. rbuggyMatches = [];
  622. // qSa(:focus) reports false when true (Chrome 21)
  623. // We allow this because of a bug in IE8/9 that throws an error
  624. // whenever `document.activeElement` is accessed on an iframe
  625. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  626. // See https://bugs.jquery.com/ticket/13378
  627. rbuggyQSA = [];
  628. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  629. // Build QSA regex
  630. // Regex strategy adopted from Diego Perini
  631. assert(function( el ) {
  632. // Select is set to empty string on purpose
  633. // This is to test IE's treatment of not explicitly
  634. // setting a boolean content attribute,
  635. // since its presence should be enough
  636. // https://bugs.jquery.com/ticket/12359
  637. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  638. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  639. "<option selected=''></option></select>";
  640. // Support: IE8, Opera 11-12.16
  641. // Nothing should be selected when empty strings follow ^= or $= or *=
  642. // The test attribute must be unknown in Opera but "safe" for WinRT
  643. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  644. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  645. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  646. }
  647. // Support: IE8
  648. // Boolean attributes and "value" are not treated correctly
  649. if ( !el.querySelectorAll("[selected]").length ) {
  650. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  651. }
  652. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  653. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  654. rbuggyQSA.push("~=");
  655. }
  656. // Webkit/Opera - :checked should return selected option elements
  657. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  658. // IE8 throws error here and will not see later tests
  659. if ( !el.querySelectorAll(":checked").length ) {
  660. rbuggyQSA.push(":checked");
  661. }
  662. // Support: Safari 8+, iOS 8+
  663. // https://bugs.webkit.org/show_bug.cgi?id=136851
  664. // In-page `selector#id sibling-combinator selector` fails
  665. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  666. rbuggyQSA.push(".#.+[+~]");
  667. }
  668. });
  669. assert(function( el ) {
  670. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  671. "<select disabled='disabled'><option/></select>";
  672. // Support: Windows 8 Native Apps
  673. // The type and name attributes are restricted during .innerHTML assignment
  674. var input = document.createElement("input");
  675. input.setAttribute( "type", "hidden" );
  676. el.appendChild( input ).setAttribute( "name", "D" );
  677. // Support: IE8
  678. // Enforce case-sensitivity of name attribute
  679. if ( el.querySelectorAll("[name=d]").length ) {
  680. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  681. }
  682. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  683. // IE8 throws error here and will not see later tests
  684. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  685. rbuggyQSA.push( ":enabled", ":disabled" );
  686. }
  687. // Support: IE9-11+
  688. // IE's :disabled selector does not pick up the children of disabled fieldsets
  689. docElem.appendChild( el ).disabled = true;
  690. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  691. rbuggyQSA.push( ":enabled", ":disabled" );
  692. }
  693. // Opera 10-11 does not throw on post-comma invalid pseudos
  694. el.querySelectorAll("*,:x");
  695. rbuggyQSA.push(",.*:");
  696. });
  697. }
  698. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  699. docElem.webkitMatchesSelector ||
  700. docElem.mozMatchesSelector ||
  701. docElem.oMatchesSelector ||
  702. docElem.msMatchesSelector) )) ) {
  703. assert(function( el ) {
  704. // Check to see if it's possible to do matchesSelector
  705. // on a disconnected node (IE 9)
  706. support.disconnectedMatch = matches.call( el, "*" );
  707. // This should fail with an exception
  708. // Gecko does not error, returns false instead
  709. matches.call( el, "[s!='']:x" );
  710. rbuggyMatches.push( "!=", pseudos );
  711. });
  712. }
  713. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  714. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  715. /* Contains
  716. ---------------------------------------------------------------------- */
  717. hasCompare = rnative.test( docElem.compareDocumentPosition );
  718. // Element contains another
  719. // Purposefully self-exclusive
  720. // As in, an element does not contain itself
  721. contains = hasCompare || rnative.test( docElem.contains ) ?
  722. function( a, b ) {
  723. var adown = a.nodeType === 9 ? a.documentElement : a,
  724. bup = b && b.parentNode;
  725. return a === bup || !!( bup && bup.nodeType === 1 && (
  726. adown.contains ?
  727. adown.contains( bup ) :
  728. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  729. ));
  730. } :
  731. function( a, b ) {
  732. if ( b ) {
  733. while ( (b = b.parentNode) ) {
  734. if ( b === a ) {
  735. return true;
  736. }
  737. }
  738. }
  739. return false;
  740. };
  741. /* Sorting
  742. ---------------------------------------------------------------------- */
  743. // Document order sorting
  744. sortOrder = hasCompare ?
  745. function( a, b ) {
  746. // Flag for duplicate removal
  747. if ( a === b ) {
  748. hasDuplicate = true;
  749. return 0;
  750. }
  751. // Sort on method existence if only one input has compareDocumentPosition
  752. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  753. if ( compare ) {
  754. return compare;
  755. }
  756. // Calculate position if both inputs belong to the same document
  757. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  758. a.compareDocumentPosition( b ) :
  759. // Otherwise we know they are disconnected
  760. 1;
  761. // Disconnected nodes
  762. if ( compare & 1 ||
  763. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  764. // Choose the first element that is related to our preferred document
  765. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  766. return -1;
  767. }
  768. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  769. return 1;
  770. }
  771. // Maintain original order
  772. return sortInput ?
  773. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  774. 0;
  775. }
  776. return compare & 4 ? -1 : 1;
  777. } :
  778. function( a, b ) {
  779. // Exit early if the nodes are identical
  780. if ( a === b ) {
  781. hasDuplicate = true;
  782. return 0;
  783. }
  784. var cur,
  785. i = 0,
  786. aup = a.parentNode,
  787. bup = b.parentNode,
  788. ap = [ a ],
  789. bp = [ b ];
  790. // Parentless nodes are either documents or disconnected
  791. if ( !aup || !bup ) {
  792. return a === document ? -1 :
  793. b === document ? 1 :
  794. aup ? -1 :
  795. bup ? 1 :
  796. sortInput ?
  797. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  798. 0;
  799. // If the nodes are siblings, we can do a quick check
  800. } else if ( aup === bup ) {
  801. return siblingCheck( a, b );
  802. }
  803. // Otherwise we need full lists of their ancestors for comparison
  804. cur = a;
  805. while ( (cur = cur.parentNode) ) {
  806. ap.unshift( cur );
  807. }
  808. cur = b;
  809. while ( (cur = cur.parentNode) ) {
  810. bp.unshift( cur );
  811. }
  812. // Walk down the tree looking for a discrepancy
  813. while ( ap[i] === bp[i] ) {
  814. i++;
  815. }
  816. return i ?
  817. // Do a sibling check if the nodes have a common ancestor
  818. siblingCheck( ap[i], bp[i] ) :
  819. // Otherwise nodes in our document sort first
  820. ap[i] === preferredDoc ? -1 :
  821. bp[i] === preferredDoc ? 1 :
  822. 0;
  823. };
  824. return document;
  825. };
  826. Sizzle.matches = function( expr, elements ) {
  827. return Sizzle( expr, null, null, elements );
  828. };
  829. Sizzle.matchesSelector = function( elem, expr ) {
  830. // Set document vars if needed
  831. if ( ( elem.ownerDocument || elem ) !== document ) {
  832. setDocument( elem );
  833. }
  834. // Make sure that attribute selectors are quoted
  835. expr = expr.replace( rattributeQuotes, "='$1']" );
  836. if ( support.matchesSelector && documentIsHTML &&
  837. !compilerCache[ expr + " " ] &&
  838. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  839. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  840. try {
  841. var ret = matches.call( elem, expr );
  842. // IE 9's matchesSelector returns false on disconnected nodes
  843. if ( ret || support.disconnectedMatch ||
  844. // As well, disconnected nodes are said to be in a document
  845. // fragment in IE 9
  846. elem.document && elem.document.nodeType !== 11 ) {
  847. return ret;
  848. }
  849. } catch (e) {}
  850. }
  851. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  852. };
  853. Sizzle.contains = function( context, elem ) {
  854. // Set document vars if needed
  855. if ( ( context.ownerDocument || context ) !== document ) {
  856. setDocument( context );
  857. }
  858. return contains( context, elem );
  859. };
  860. Sizzle.attr = function( elem, name ) {
  861. // Set document vars if needed
  862. if ( ( elem.ownerDocument || elem ) !== document ) {
  863. setDocument( elem );
  864. }
  865. var fn = Expr.attrHandle[ name.toLowerCase() ],
  866. // Don't get fooled by Object.prototype properties (jQuery #13807)
  867. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  868. fn( elem, name, !documentIsHTML ) :
  869. undefined;
  870. return val !== undefined ?
  871. val :
  872. support.attributes || !documentIsHTML ?
  873. elem.getAttribute( name ) :
  874. (val = elem.getAttributeNode(name)) && val.specified ?
  875. val.value :
  876. null;
  877. };
  878. Sizzle.escape = function( sel ) {
  879. return (sel + "").replace( rcssescape, fcssescape );
  880. };
  881. Sizzle.error = function( msg ) {
  882. throw new Error( "Syntax error, unrecognized expression: " + msg );
  883. };
  884. /**
  885. * Document sorting and removing duplicates
  886. * @param {ArrayLike} results
  887. */
  888. Sizzle.uniqueSort = function( results ) {
  889. var elem,
  890. duplicates = [],
  891. j = 0,
  892. i = 0;
  893. // Unless we *know* we can detect duplicates, assume their presence
  894. hasDuplicate = !support.detectDuplicates;
  895. sortInput = !support.sortStable && results.slice( 0 );
  896. results.sort( sortOrder );
  897. if ( hasDuplicate ) {
  898. while ( (elem = results[i++]) ) {
  899. if ( elem === results[ i ] ) {
  900. j = duplicates.push( i );
  901. }
  902. }
  903. while ( j-- ) {
  904. results.splice( duplicates[ j ], 1 );
  905. }
  906. }
  907. // Clear input after sorting to release objects
  908. // See https://github.com/jquery/sizzle/pull/225
  909. sortInput = null;
  910. return results;
  911. };
  912. /**
  913. * Utility function for retrieving the text value of an array of DOM nodes
  914. * @param {Array|Element} elem
  915. */
  916. getText = Sizzle.getText = function( elem ) {
  917. var node,
  918. ret = "",
  919. i = 0,
  920. nodeType = elem.nodeType;
  921. if ( !nodeType ) {
  922. // If no nodeType, this is expected to be an array
  923. while ( (node = elem[i++]) ) {
  924. // Do not traverse comment nodes
  925. ret += getText( node );
  926. }
  927. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  928. // Use textContent for elements
  929. // innerText usage removed for consistency of new lines (jQuery #11153)
  930. if ( typeof elem.textContent === "string" ) {
  931. return elem.textContent;
  932. } else {
  933. // Traverse its children
  934. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  935. ret += getText( elem );
  936. }
  937. }
  938. } else if ( nodeType === 3 || nodeType === 4 ) {
  939. return elem.nodeValue;
  940. }
  941. // Do not include comment or processing instruction nodes
  942. return ret;
  943. };
  944. Expr = Sizzle.selectors = {
  945. // Can be adjusted by the user
  946. cacheLength: 50,
  947. createPseudo: markFunction,
  948. match: matchExpr,
  949. attrHandle: {},
  950. find: {},
  951. relative: {
  952. ">": { dir: "parentNode", first: true },
  953. " ": { dir: "parentNode" },
  954. "+": { dir: "previousSibling", first: true },
  955. "~": { dir: "previousSibling" }
  956. },
  957. preFilter: {
  958. "ATTR": function( match ) {
  959. match[1] = match[1].replace( runescape, funescape );
  960. // Move the given value to match[3] whether quoted or unquoted
  961. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  962. if ( match[2] === "~=" ) {
  963. match[3] = " " + match[3] + " ";
  964. }
  965. return match.slice( 0, 4 );
  966. },
  967. "CHILD": function( match ) {
  968. /* matches from matchExpr["CHILD"]
  969. 1 type (only|nth|...)
  970. 2 what (child|of-type)
  971. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  972. 4 xn-component of xn+y argument ([+-]?\d*n|)
  973. 5 sign of xn-component
  974. 6 x of xn-component
  975. 7 sign of y-component
  976. 8 y of y-component
  977. */
  978. match[1] = match[1].toLowerCase();
  979. if ( match[1].slice( 0, 3 ) === "nth" ) {
  980. // nth-* requires argument
  981. if ( !match[3] ) {
  982. Sizzle.error( match[0] );
  983. }
  984. // numeric x and y parameters for Expr.filter.CHILD
  985. // remember that false/true cast respectively to 0/1
  986. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  987. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  988. // other types prohibit arguments
  989. } else if ( match[3] ) {
  990. Sizzle.error( match[0] );
  991. }
  992. return match;
  993. },
  994. "PSEUDO": function( match ) {
  995. var excess,
  996. unquoted = !match[6] && match[2];
  997. if ( matchExpr["CHILD"].test( match[0] ) ) {
  998. return null;
  999. }
  1000. // Accept quoted arguments as-is
  1001. if ( match[3] ) {
  1002. match[2] = match[4] || match[5] || "";
  1003. // Strip excess characters from unquoted arguments
  1004. } else if ( unquoted && rpseudo.test( unquoted ) &&
  1005. // Get excess from tokenize (recursively)
  1006. (excess = tokenize( unquoted, true )) &&
  1007. // advance to the next closing parenthesis
  1008. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  1009. // excess is a negative index
  1010. match[0] = match[0].slice( 0, excess );
  1011. match[2] = unquoted.slice( 0, excess );
  1012. }
  1013. // Return only captures needed by the pseudo filter method (type and argument)
  1014. return match.slice( 0, 3 );
  1015. }
  1016. },
  1017. filter: {
  1018. "TAG": function( nodeNameSelector ) {
  1019. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  1020. return nodeNameSelector === "*" ?
  1021. function() { return true; } :
  1022. function( elem ) {
  1023. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  1024. };
  1025. },
  1026. "CLASS": function( className ) {
  1027. var pattern = classCache[ className + " " ];
  1028. return pattern ||
  1029. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  1030. classCache( className, function( elem ) {
  1031. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  1032. });
  1033. },
  1034. "ATTR": function( name, operator, check ) {
  1035. return function( elem ) {
  1036. var result = Sizzle.attr( elem, name );
  1037. if ( result == null ) {
  1038. return operator === "!=";
  1039. }
  1040. if ( !operator ) {
  1041. return true;
  1042. }
  1043. result += "";
  1044. return operator === "=" ? result === check :
  1045. operator === "!=" ? result !== check :
  1046. operator === "^=" ? check && result.indexOf( check ) === 0 :
  1047. operator === "*=" ? check && result.indexOf( check ) > -1 :
  1048. operator === "$=" ? check && result.slice( -check.length ) === check :
  1049. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  1050. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  1051. false;
  1052. };
  1053. },
  1054. "CHILD": function( type, what, argument, first, last ) {
  1055. var simple = type.slice( 0, 3 ) !== "nth",
  1056. forward = type.slice( -4 ) !== "last",
  1057. ofType = what === "of-type";
  1058. return first === 1 && last === 0 ?
  1059. // Shortcut for :nth-*(n)
  1060. function( elem ) {
  1061. return !!elem.parentNode;
  1062. } :
  1063. function( elem, context, xml ) {
  1064. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  1065. dir = simple !== forward ? "nextSibling" : "previousSibling",
  1066. parent = elem.parentNode,
  1067. name = ofType && elem.nodeName.toLowerCase(),
  1068. useCache = !xml && !ofType,
  1069. diff = false;
  1070. if ( parent ) {
  1071. // :(first|last|only)-(child|of-type)
  1072. if ( simple ) {
  1073. while ( dir ) {
  1074. node = elem;
  1075. while ( (node = node[ dir ]) ) {
  1076. if ( ofType ?
  1077. node.nodeName.toLowerCase() === name :
  1078. node.nodeType === 1 ) {
  1079. return false;
  1080. }
  1081. }
  1082. // Reverse direction for :only-* (if we haven't yet done so)
  1083. start = dir = type === "only" && !start && "nextSibling";
  1084. }
  1085. return true;
  1086. }
  1087. start = [ forward ? parent.firstChild : parent.lastChild ];
  1088. // non-xml :nth-child(...) stores cache data on `parent`
  1089. if ( forward && useCache ) {
  1090. // Seek `elem` from a previously-cached index
  1091. // ...in a gzip-friendly way
  1092. node = parent;
  1093. outerCache = node[ expando ] || (node[ expando ] = {});
  1094. // Support: IE <9 only
  1095. // Defend against cloned attroperties (jQuery gh-1709)
  1096. uniqueCache = outerCache[ node.uniqueID ] ||
  1097. (outerCache[ node.uniqueID ] = {});
  1098. cache = uniqueCache[ type ] || [];
  1099. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  1100. diff = nodeIndex && cache[ 2 ];
  1101. node = nodeIndex && parent.childNodes[ nodeIndex ];
  1102. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1103. // Fallback to seeking `elem` from the start
  1104. (diff = nodeIndex = 0) || start.pop()) ) {
  1105. // When found, cache indexes on `parent` and break
  1106. if ( node.nodeType === 1 && ++diff && node === elem ) {
  1107. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  1108. break;
  1109. }
  1110. }
  1111. } else {
  1112. // Use previously-cached element index if available
  1113. if ( useCache ) {
  1114. // ...in a gzip-friendly way
  1115. node = elem;
  1116. outerCache = node[ expando ] || (node[ expando ] = {});
  1117. // Support: IE <9 only
  1118. // Defend against cloned attroperties (jQuery gh-1709)
  1119. uniqueCache = outerCache[ node.uniqueID ] ||
  1120. (outerCache[ node.uniqueID ] = {});
  1121. cache = uniqueCache[ type ] || [];
  1122. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  1123. diff = nodeIndex;
  1124. }
  1125. // xml :nth-child(...)
  1126. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  1127. if ( diff === false ) {
  1128. // Use the same loop as above to seek `elem` from the start
  1129. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1130. (diff = nodeIndex = 0) || start.pop()) ) {
  1131. if ( ( ofType ?
  1132. node.nodeName.toLowerCase() === name :
  1133. node.nodeType === 1 ) &&
  1134. ++diff ) {
  1135. // Cache the index of each encountered element
  1136. if ( useCache ) {
  1137. outerCache = node[ expando ] || (node[ expando ] = {});
  1138. // Support: IE <9 only
  1139. // Defend against cloned attroperties (jQuery gh-1709)
  1140. uniqueCache = outerCache[ node.uniqueID ] ||
  1141. (outerCache[ node.uniqueID ] = {});
  1142. uniqueCache[ type ] = [ dirruns, diff ];
  1143. }
  1144. if ( node === elem ) {
  1145. break;
  1146. }
  1147. }
  1148. }
  1149. }
  1150. }
  1151. // Incorporate the offset, then check against cycle size
  1152. diff -= last;
  1153. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  1154. }
  1155. };
  1156. },
  1157. "PSEUDO": function( pseudo, argument ) {
  1158. // pseudo-class names are case-insensitive
  1159. // http://www.w3.org/TR/selectors/#pseudo-classes
  1160. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  1161. // Remember that setFilters inherits from pseudos
  1162. var args,
  1163. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  1164. Sizzle.error( "unsupported pseudo: " + pseudo );
  1165. // The user may use createPseudo to indicate that
  1166. // arguments are needed to create the filter function
  1167. // just as Sizzle does
  1168. if ( fn[ expando ] ) {
  1169. return fn( argument );
  1170. }
  1171. // But maintain support for old signatures
  1172. if ( fn.length > 1 ) {
  1173. args = [ pseudo, pseudo, "", argument ];
  1174. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  1175. markFunction(function( seed, matches ) {
  1176. var idx,
  1177. matched = fn( seed, argument ),
  1178. i = matched.length;
  1179. while ( i-- ) {
  1180. idx = indexOf( seed, matched[i] );
  1181. seed[ idx ] = !( matches[ idx ] = matched[i] );
  1182. }
  1183. }) :
  1184. function( elem ) {
  1185. return fn( elem, 0, args );
  1186. };
  1187. }
  1188. return fn;
  1189. }
  1190. },
  1191. pseudos: {
  1192. // Potentially complex pseudos
  1193. "not": markFunction(function( selector ) {
  1194. // Trim the selector passed to compile
  1195. // to avoid treating leading and trailing
  1196. // spaces as combinators
  1197. var input = [],
  1198. results = [],
  1199. matcher = compile( selector.replace( rtrim, "$1" ) );
  1200. return matcher[ expando ] ?
  1201. markFunction(function( seed, matches, context, xml ) {
  1202. var elem,
  1203. unmatched = matcher( seed, null, xml, [] ),
  1204. i = seed.length;
  1205. // Match elements unmatched by `matcher`
  1206. while ( i-- ) {
  1207. if ( (elem = unmatched[i]) ) {
  1208. seed[i] = !(matches[i] = elem);
  1209. }
  1210. }
  1211. }) :
  1212. function( elem, context, xml ) {
  1213. input[0] = elem;
  1214. matcher( input, null, xml, results );
  1215. // Don't keep the element (issue #299)
  1216. input[0] = null;
  1217. return !results.pop();
  1218. };
  1219. }),
  1220. "has": markFunction(function( selector ) {
  1221. return function( elem ) {
  1222. return Sizzle( selector, elem ).length > 0;
  1223. };
  1224. }),
  1225. "contains": markFunction(function( text ) {
  1226. text = text.replace( runescape, funescape );
  1227. return function( elem ) {
  1228. return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
  1229. };
  1230. }),
  1231. // "Whether an element is represented by a :lang() selector
  1232. // is based solely on the element's language value
  1233. // being equal to the identifier C,
  1234. // or beginning with the identifier C immediately followed by "-".
  1235. // The matching of C against the element's language value is performed case-insensitively.
  1236. // The identifier C does not have to be a valid language name."
  1237. // http://www.w3.org/TR/selectors/#lang-pseudo
  1238. "lang": markFunction( function( lang ) {
  1239. // lang value must be a valid identifier
  1240. if ( !ridentifier.test(lang || "") ) {
  1241. Sizzle.error( "unsupported lang: " + lang );
  1242. }
  1243. lang = lang.replace( runescape, funescape ).toLowerCase();
  1244. return function( elem ) {
  1245. var elemLang;
  1246. do {
  1247. if ( (elemLang = documentIsHTML ?
  1248. elem.lang :
  1249. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  1250. elemLang = elemLang.toLowerCase();
  1251. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  1252. }
  1253. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  1254. return false;
  1255. };
  1256. }),
  1257. // Miscellaneous
  1258. "target": function( elem ) {
  1259. var hash = window.location && window.location.hash;
  1260. return hash && hash.slice( 1 ) === elem.id;
  1261. },
  1262. "root": function( elem ) {
  1263. return elem === docElem;
  1264. },
  1265. "focus": function( elem ) {
  1266. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  1267. },
  1268. // Boolean properties
  1269. "enabled": createDisabledPseudo( false ),
  1270. "disabled": createDisabledPseudo( true ),
  1271. "checked": function( elem ) {
  1272. // In CSS3, :checked should return both checked and selected elements
  1273. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1274. var nodeName = elem.nodeName.toLowerCase();
  1275. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  1276. },
  1277. "selected": function( elem ) {
  1278. // Accessing this property makes selected-by-default
  1279. // options in Safari work properly
  1280. if ( elem.parentNode ) {
  1281. elem.parentNode.selectedIndex;
  1282. }
  1283. return elem.selected === true;
  1284. },
  1285. // Contents
  1286. "empty": function( elem ) {
  1287. // http://www.w3.org/TR/selectors/#empty-pseudo
  1288. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  1289. // but not by others (comment: 8; processing instruction: 7; etc.)
  1290. // nodeType < 6 works because attributes (2) do not appear as children
  1291. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  1292. if ( elem.nodeType < 6 ) {
  1293. return false;
  1294. }
  1295. }
  1296. return true;
  1297. },
  1298. "parent": function( elem ) {
  1299. return !Expr.pseudos["empty"]( elem );
  1300. },
  1301. // Element/input types
  1302. "header": function( elem ) {
  1303. return rheader.test( elem.nodeName );
  1304. },
  1305. "input": function( elem ) {
  1306. return rinputs.test( elem.nodeName );
  1307. },
  1308. "button": function( elem ) {
  1309. var name = elem.nodeName.toLowerCase();
  1310. return name === "input" && elem.type === "button" || name === "button";
  1311. },
  1312. "text": function( elem ) {
  1313. var attr;
  1314. return elem.nodeName.toLowerCase() === "input" &&
  1315. elem.type === "text" &&
  1316. // Support: IE<8
  1317. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  1318. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  1319. },
  1320. // Position-in-collection
  1321. "first": createPositionalPseudo(function() {
  1322. return [ 0 ];
  1323. }),
  1324. "last": createPositionalPseudo(function( matchIndexes, length ) {
  1325. return [ length - 1 ];
  1326. }),
  1327. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1328. return [ argument < 0 ? argument + length : argument ];
  1329. }),
  1330. "even": createPositionalPseudo(function( matchIndexes, length ) {
  1331. var i = 0;
  1332. for ( ; i < length; i += 2 ) {
  1333. matchIndexes.push( i );
  1334. }
  1335. return matchIndexes;
  1336. }),
  1337. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  1338. var i = 1;
  1339. for ( ; i < length; i += 2 ) {
  1340. matchIndexes.push( i );
  1341. }
  1342. return matchIndexes;
  1343. }),
  1344. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1345. var i = argument < 0 ? argument + length : argument;
  1346. for ( ; --i >= 0; ) {
  1347. matchIndexes.push( i );
  1348. }
  1349. return matchIndexes;
  1350. }),
  1351. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1352. var i = argument < 0 ? argument + length : argument;
  1353. for ( ; ++i < length; ) {
  1354. matchIndexes.push( i );
  1355. }
  1356. return matchIndexes;
  1357. })
  1358. }
  1359. };
  1360. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  1361. // Add button/input type pseudos
  1362. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  1363. Expr.pseudos[ i ] = createInputPseudo( i );
  1364. }
  1365. for ( i in { submit: true, reset: true } ) {
  1366. Expr.pseudos[ i ] = createButtonPseudo( i );
  1367. }
  1368. // Easy API for creating new setFilters
  1369. function setFilters() {}
  1370. setFilters.prototype = Expr.filters = Expr.pseudos;
  1371. Expr.setFilters = new setFilters();
  1372. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  1373. var matched, match, tokens, type,
  1374. soFar, groups, preFilters,
  1375. cached = tokenCache[ selector + " " ];
  1376. if ( cached ) {
  1377. return parseOnly ? 0 : cached.slice( 0 );
  1378. }
  1379. soFar = selector;
  1380. groups = [];
  1381. preFilters = Expr.preFilter;
  1382. while ( soFar ) {
  1383. // Comma and first run
  1384. if ( !matched || (match = rcomma.exec( soFar )) ) {
  1385. if ( match ) {
  1386. // Don't consume trailing commas as valid
  1387. soFar = soFar.slice( match[0].length ) || soFar;
  1388. }
  1389. groups.push( (tokens = []) );
  1390. }
  1391. matched = false;
  1392. // Combinators
  1393. if ( (match = rcombinators.exec( soFar )) ) {
  1394. matched = match.shift();
  1395. tokens.push({
  1396. value: matched,
  1397. // Cast descendant combinators to space
  1398. type: match[0].replace( rtrim, " " )
  1399. });
  1400. soFar = soFar.slice( matched.length );
  1401. }
  1402. // Filters
  1403. for ( type in Expr.filter ) {
  1404. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  1405. (match = preFilters[ type ]( match ))) ) {
  1406. matched = match.shift();
  1407. tokens.push({
  1408. value: matched,
  1409. type: type,
  1410. matches: match
  1411. });
  1412. soFar = soFar.slice( matched.length );
  1413. }
  1414. }
  1415. if ( !matched ) {
  1416. break;
  1417. }
  1418. }
  1419. // Return the length of the invalid excess
  1420. // if we're just parsing
  1421. // Otherwise, throw an error or return tokens
  1422. return parseOnly ?
  1423. soFar.length :
  1424. soFar ?
  1425. Sizzle.error( selector ) :
  1426. // Cache the tokens
  1427. tokenCache( selector, groups ).slice( 0 );
  1428. };
  1429. function toSelector( tokens ) {
  1430. var i = 0,
  1431. len = tokens.length,
  1432. selector = "";
  1433. for ( ; i < len; i++ ) {
  1434. selector += tokens[i].value;
  1435. }
  1436. return selector;
  1437. }
  1438. function addCombinator( matcher, combinator, base ) {
  1439. var dir = combinator.dir,
  1440. skip = combinator.next,
  1441. key = skip || dir,
  1442. checkNonElements = base && key === "parentNode",
  1443. doneName = done++;
  1444. return combinator.first ?
  1445. // Check against closest ancestor/preceding element
  1446. function( elem, context, xml ) {
  1447. while ( (elem = elem[ dir ]) ) {
  1448. if ( elem.nodeType === 1 || checkNonElements ) {
  1449. return matcher( elem, context, xml );
  1450. }
  1451. }
  1452. return false;
  1453. } :
  1454. // Check against all ancestor/preceding elements
  1455. function( elem, context, xml ) {
  1456. var oldCache, uniqueCache, outerCache,
  1457. newCache = [ dirruns, doneName ];
  1458. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  1459. if ( xml ) {
  1460. while ( (elem = elem[ dir ]) ) {
  1461. if ( elem.nodeType === 1 || checkNonElements ) {
  1462. if ( matcher( elem, context, xml ) ) {
  1463. return true;
  1464. }
  1465. }
  1466. }
  1467. } else {
  1468. while ( (elem = elem[ dir ]) ) {
  1469. if ( elem.nodeType === 1 || checkNonElements ) {
  1470. outerCache = elem[ expando ] || (elem[ expando ] = {});
  1471. // Support: IE <9 only
  1472. // Defend against cloned attroperties (jQuery gh-1709)
  1473. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  1474. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  1475. elem = elem[ dir ] || elem;
  1476. } else if ( (oldCache = uniqueCache[ key ]) &&
  1477. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  1478. // Assign to newCache so results back-propagate to previous elements
  1479. return (newCache[ 2 ] = oldCache[ 2 ]);
  1480. } else {
  1481. // Reuse newcache so results back-propagate to previous elements
  1482. uniqueCache[ key ] = newCache;
  1483. // A match means we're done; a fail means we have to keep checking
  1484. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  1485. return true;
  1486. }
  1487. }
  1488. }
  1489. }
  1490. }
  1491. return false;
  1492. };
  1493. }
  1494. function elementMatcher( matchers ) {
  1495. return matchers.length > 1 ?
  1496. function( elem, context, xml ) {
  1497. var i = matchers.length;
  1498. while ( i-- ) {
  1499. if ( !matchers[i]( elem, context, xml ) ) {
  1500. return false;
  1501. }
  1502. }
  1503. return true;
  1504. } :
  1505. matchers[0];
  1506. }
  1507. function multipleContexts( selector, contexts, results ) {
  1508. var i = 0,
  1509. len = contexts.length;
  1510. for ( ; i < len; i++ ) {
  1511. Sizzle( selector, contexts[i], results );
  1512. }
  1513. return results;
  1514. }
  1515. function condense( unmatched, map, filter, context, xml ) {
  1516. var elem,
  1517. newUnmatched = [],
  1518. i = 0,
  1519. len = unmatched.length,
  1520. mapped = map != null;
  1521. for ( ; i < len; i++ ) {
  1522. if ( (elem = unmatched[i]) ) {
  1523. if ( !filter || filter( elem, context, xml ) ) {
  1524. newUnmatched.push( elem );
  1525. if ( mapped ) {
  1526. map.push( i );
  1527. }
  1528. }
  1529. }
  1530. }
  1531. return newUnmatched;
  1532. }
  1533. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  1534. if ( postFilter && !postFilter[ expando ] ) {
  1535. postFilter = setMatcher( postFilter );
  1536. }
  1537. if ( postFinder && !postFinder[ expando ] ) {
  1538. postFinder = setMatcher( postFinder, postSelector );
  1539. }
  1540. return markFunction(function( seed, results, context, xml ) {
  1541. var temp, i, elem,
  1542. preMap = [],
  1543. postMap = [],
  1544. preexisting = results.length,
  1545. // Get initial elements from seed or context
  1546. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  1547. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  1548. matcherIn = preFilter && ( seed || !selector ) ?
  1549. condense( elems, preMap, preFilter, context, xml ) :
  1550. elems,
  1551. matcherOut = matcher ?
  1552. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  1553. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  1554. // ...intermediate processing is necessary
  1555. [] :
  1556. // ...otherwise use results directly
  1557. results :
  1558. matcherIn;
  1559. // Find primary matches
  1560. if ( matcher ) {
  1561. matcher( matcherIn, matcherOut, context, xml );
  1562. }
  1563. // Apply postFilter
  1564. if ( postFilter ) {
  1565. temp = condense( matcherOut, postMap );
  1566. postFilter( temp, [], context, xml );
  1567. // Un-match failing elements by moving them back to matcherIn
  1568. i = temp.length;
  1569. while ( i-- ) {
  1570. if ( (elem = temp[i]) ) {
  1571. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  1572. }
  1573. }
  1574. }
  1575. if ( seed ) {
  1576. if ( postFinder || preFilter ) {
  1577. if ( postFinder ) {
  1578. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  1579. temp = [];
  1580. i = matcherOut.length;
  1581. while ( i-- ) {
  1582. if ( (elem = matcherOut[i]) ) {
  1583. // Restore matcherIn since elem is not yet a final match
  1584. temp.push( (matcherIn[i] = elem) );
  1585. }
  1586. }
  1587. postFinder( null, (matcherOut = []), temp, xml );
  1588. }
  1589. // Move matched elements from seed to results to keep them synchronized
  1590. i = matcherOut.length;
  1591. while ( i-- ) {
  1592. if ( (elem = matcherOut[i]) &&
  1593. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  1594. seed[temp] = !(results[temp] = elem);
  1595. }
  1596. }
  1597. }
  1598. // Add elements to results, through postFinder if defined
  1599. } else {
  1600. matcherOut = condense(
  1601. matcherOut === results ?
  1602. matcherOut.splice( preexisting, matcherOut.length ) :
  1603. matcherOut
  1604. );
  1605. if ( postFinder ) {
  1606. postFinder( null, results, matcherOut, xml );
  1607. } else {
  1608. push.apply( results, matcherOut );
  1609. }
  1610. }
  1611. });
  1612. }
  1613. function matcherFromTokens( tokens ) {
  1614. var checkContext, matcher, j,
  1615. len = tokens.length,
  1616. leadingRelative = Expr.relative[ tokens[0].type ],
  1617. implicitRelative = leadingRelative || Expr.relative[" "],
  1618. i = leadingRelative ? 1 : 0,
  1619. // The foundational matcher ensures that elements are reachable from top-level context(s)
  1620. matchContext = addCombinator( function( elem ) {
  1621. return elem === checkContext;
  1622. }, implicitRelative, true ),
  1623. matchAnyContext = addCombinator( function( elem ) {
  1624. return indexOf( checkContext, elem ) > -1;
  1625. }, implicitRelative, true ),
  1626. matchers = [ function( elem, context, xml ) {
  1627. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  1628. (checkContext = context).nodeType ?
  1629. matchContext( elem, context, xml ) :
  1630. matchAnyContext( elem, context, xml ) );
  1631. // Avoid hanging onto element (issue #299)
  1632. checkContext = null;
  1633. return ret;
  1634. } ];
  1635. for ( ; i < len; i++ ) {
  1636. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  1637. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  1638. } else {
  1639. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  1640. // Return special upon seeing a positional matcher
  1641. if ( matcher[ expando ] ) {
  1642. // Find the next relative operator (if any) for proper handling
  1643. j = ++i;
  1644. for ( ; j < len; j++ ) {
  1645. if ( Expr.relative[ tokens[j].type ] ) {
  1646. break;
  1647. }
  1648. }
  1649. return setMatcher(
  1650. i > 1 && elementMatcher( matchers ),
  1651. i > 1 && toSelector(
  1652. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  1653. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  1654. ).replace( rtrim, "$1" ),
  1655. matcher,
  1656. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  1657. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  1658. j < len && toSelector( tokens )
  1659. );
  1660. }
  1661. matchers.push( matcher );
  1662. }
  1663. }
  1664. return elementMatcher( matchers );
  1665. }
  1666. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  1667. var bySet = setMatchers.length > 0,
  1668. byElement = elementMatchers.length > 0,
  1669. superMatcher = function( seed, context, xml, results, outermost ) {
  1670. var elem, j, matcher,
  1671. matchedCount = 0,
  1672. i = "0",
  1673. unmatched = seed && [],
  1674. setMatched = [],
  1675. contextBackup = outermostContext,
  1676. // We must always have either seed elements or outermost context
  1677. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  1678. // Use integer dirruns iff this is the outermost matcher
  1679. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  1680. len = elems.length;
  1681. if ( outermost ) {
  1682. outermostContext = context === document || context || outermost;
  1683. }
  1684. // Add elements passing elementMatchers directly to results
  1685. // Support: IE<9, Safari
  1686. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  1687. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  1688. if ( byElement && elem ) {
  1689. j = 0;
  1690. if ( !context && elem.ownerDocument !== document ) {
  1691. setDocument( elem );
  1692. xml = !documentIsHTML;
  1693. }
  1694. while ( (matcher = elementMatchers[j++]) ) {
  1695. if ( matcher( elem, context || document, xml) ) {
  1696. results.push( elem );
  1697. break;
  1698. }
  1699. }
  1700. if ( outermost ) {
  1701. dirruns = dirrunsUnique;
  1702. }
  1703. }
  1704. // Track unmatched elements for set filters
  1705. if ( bySet ) {
  1706. // They will have gone through all possible matchers
  1707. if ( (elem = !matcher && elem) ) {
  1708. matchedCount--;
  1709. }
  1710. // Lengthen the array for every element, matched or not
  1711. if ( seed ) {
  1712. unmatched.push( elem );
  1713. }
  1714. }
  1715. }
  1716. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  1717. // makes the latter nonnegative.
  1718. matchedCount += i;
  1719. // Apply set filters to unmatched elements
  1720. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  1721. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  1722. // no element matchers and no seed.
  1723. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  1724. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  1725. // numerically zero.
  1726. if ( bySet && i !== matchedCount ) {
  1727. j = 0;
  1728. while ( (matcher = setMatchers[j++]) ) {
  1729. matcher( unmatched, setMatched, context, xml );
  1730. }
  1731. if ( seed ) {
  1732. // Reintegrate element matches to eliminate the need for sorting
  1733. if ( matchedCount > 0 ) {
  1734. while ( i-- ) {
  1735. if ( !(unmatched[i] || setMatched[i]) ) {
  1736. setMatched[i] = pop.call( results );
  1737. }
  1738. }
  1739. }
  1740. // Discard index placeholder values to get only actual matches
  1741. setMatched = condense( setMatched );
  1742. }
  1743. // Add matches to results
  1744. push.apply( results, setMatched );
  1745. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  1746. if ( outermost && !seed && setMatched.length > 0 &&
  1747. ( matchedCount + setMatchers.length ) > 1 ) {
  1748. Sizzle.uniqueSort( results );
  1749. }
  1750. }
  1751. // Override manipulation of globals by nested matchers
  1752. if ( outermost ) {
  1753. dirruns = dirrunsUnique;
  1754. outermostContext = contextBackup;
  1755. }
  1756. return unmatched;
  1757. };
  1758. return bySet ?
  1759. markFunction( superMatcher ) :
  1760. superMatcher;
  1761. }
  1762. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  1763. var i,
  1764. setMatchers = [],
  1765. elementMatchers = [],
  1766. cached = compilerCache[ selector + " " ];
  1767. if ( !cached ) {
  1768. // Generate a function of recursive functions that can be used to check each element
  1769. if ( !match ) {
  1770. match = tokenize( selector );
  1771. }
  1772. i = match.length;
  1773. while ( i-- ) {
  1774. cached = matcherFromTokens( match[i] );
  1775. if ( cached[ expando ] ) {
  1776. setMatchers.push( cached );
  1777. } else {
  1778. elementMatchers.push( cached );
  1779. }
  1780. }
  1781. // Cache the compiled function
  1782. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  1783. // Save selector and tokenization
  1784. cached.selector = selector;
  1785. }
  1786. return cached;
  1787. };
  1788. /**
  1789. * A low-level selection function that works with Sizzle's compiled
  1790. * selector functions
  1791. * @param {String|Function} selector A selector or a pre-compiled
  1792. * selector function built with Sizzle.compile
  1793. * @param {Element} context
  1794. * @param {Array} [results]
  1795. * @param {Array} [seed] A set of elements to match against
  1796. */
  1797. select = Sizzle.select = function( selector, context, results, seed ) {
  1798. var i, tokens, token, type, find,
  1799. compiled = typeof selector === "function" && selector,
  1800. match = !seed && tokenize( (selector = compiled.selector || selector) );
  1801. results = results || [];
  1802. // Try to minimize operations if there is only one selector in the list and no seed
  1803. // (the latter of which guarantees us context)
  1804. if ( match.length === 1 ) {
  1805. // Reduce context if the leading compound selector is an ID
  1806. tokens = match[0] = match[0].slice( 0 );
  1807. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  1808. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  1809. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  1810. if ( !context ) {
  1811. return results;
  1812. // Precompiled matchers will still verify ancestry, so step up a level
  1813. } else if ( compiled ) {
  1814. context = context.parentNode;
  1815. }
  1816. selector = selector.slice( tokens.shift().value.length );
  1817. }
  1818. // Fetch a seed set for right-to-left matching
  1819. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  1820. while ( i-- ) {
  1821. token = tokens[i];
  1822. // Abort if we hit a combinator
  1823. if ( Expr.relative[ (type = token.type) ] ) {
  1824. break;
  1825. }
  1826. if ( (find = Expr.find[ type ]) ) {
  1827. // Search, expanding context for leading sibling combinators
  1828. if ( (seed = find(
  1829. token.matches[0].replace( runescape, funescape ),
  1830. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  1831. )) ) {
  1832. // If seed is empty or no tokens remain, we can return early
  1833. tokens.splice( i, 1 );
  1834. selector = seed.length && toSelector( tokens );
  1835. if ( !selector ) {
  1836. push.apply( results, seed );
  1837. return results;
  1838. }
  1839. break;
  1840. }
  1841. }
  1842. }
  1843. }
  1844. // Compile and execute a filtering function if one is not provided
  1845. // Provide `match` to avoid retokenization if we modified the selector above
  1846. ( compiled || compile( selector, match ) )(
  1847. seed,
  1848. context,
  1849. !documentIsHTML,
  1850. results,
  1851. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  1852. );
  1853. return results;
  1854. };
  1855. // One-time assignments
  1856. // Sort stability
  1857. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  1858. // Support: Chrome 14-35+
  1859. // Always assume duplicates if they aren't passed to the comparison function
  1860. support.detectDuplicates = !!hasDuplicate;
  1861. // Initialize against the default document
  1862. setDocument();
  1863. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  1864. // Detached nodes confoundingly follow *each other*
  1865. support.sortDetached = assert(function( el ) {
  1866. // Should return 1, but returns 4 (following)
  1867. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  1868. });
  1869. // Support: IE<8
  1870. // Prevent attribute/property "interpolation"
  1871. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  1872. if ( !assert(function( el ) {
  1873. el.innerHTML = "<a href='#'></a>";
  1874. return el.firstChild.getAttribute("href") === "#" ;
  1875. }) ) {
  1876. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  1877. if ( !isXML ) {
  1878. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  1879. }
  1880. });
  1881. }
  1882. // Support: IE<9
  1883. // Use defaultValue in place of getAttribute("value")
  1884. if ( !support.attributes || !assert(function( el ) {
  1885. el.innerHTML = "<input/>";
  1886. el.firstChild.setAttribute( "value", "" );
  1887. return el.firstChild.getAttribute( "value" ) === "";
  1888. }) ) {
  1889. addHandle( "value", function( elem, name, isXML ) {
  1890. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  1891. return elem.defaultValue;
  1892. }
  1893. });
  1894. }
  1895. // Support: IE<9
  1896. // Use getAttributeNode to fetch booleans when getAttribute lies
  1897. if ( !assert(function( el ) {
  1898. return el.getAttribute("disabled") == null;
  1899. }) ) {
  1900. addHandle( booleans, function( elem, name, isXML ) {
  1901. var val;
  1902. if ( !isXML ) {
  1903. return elem[ name ] === true ? name.toLowerCase() :
  1904. (val = elem.getAttributeNode( name )) && val.specified ?
  1905. val.value :
  1906. null;
  1907. }
  1908. });
  1909. }
  1910. // EXPOSE
  1911. var _sizzle = window.Sizzle;
  1912. Sizzle.noConflict = function() {
  1913. if ( window.Sizzle === Sizzle ) {
  1914. window.Sizzle = _sizzle;
  1915. }
  1916. return Sizzle;
  1917. };
  1918. if ( typeof define === "function" && define.amd ) {
  1919. define(function() { return Sizzle; });
  1920. // Sizzle requires that there be a global window in Common-JS like environments
  1921. } else if ( typeof module !== "undefined" && module.exports ) {
  1922. module.exports = Sizzle;
  1923. } else {
  1924. window.Sizzle = Sizzle;
  1925. }
  1926. // EXPOSE
  1927. })( window );