Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sizzle.js 69KB

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