PageRenderTime 53ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/libs/jquery/1.11.0-beta3/jquery.js

https://gitlab.com/Mirros/libs
JavaScript | 1840 lines | 1144 code | 303 blank | 393 comment | 340 complexity | 2f94441d9cdb9e7c5c31f88d83a4033d MD5 | raw file
  1. /*!
  2. * jQuery JavaScript Library v1.11.0-beta3
  3. * http://jquery.com/
  4. *
  5. * Includes Sizzle.js
  6. * http://sizzlejs.com/
  7. *
  8. * Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors
  9. * Released under the MIT license
  10. * http://jquery.org/license
  11. *
  12. * Date: 2013-12-20T22:44Z
  13. */
  14. (function( global, factory ) {
  15. if ( typeof module === "object" && typeof module.exports === "object" ) {
  16. // For CommonJS and CommonJS-like environments where a proper window is present,
  17. // execute the factory and get jQuery
  18. // For environments that do not inherently posses a window with a document
  19. // (such as Node.js), expose a jQuery-making factory as module.exports
  20. // This accentuates the need for the creation of a real window
  21. // e.g. var jQuery = require("jquery")(window);
  22. // See ticket #14549 for more info
  23. module.exports = global.document ?
  24. factory( global ) :
  25. function( w ) {
  26. if ( !w.document ) {
  27. throw new Error( "jQuery requires a window with a document" );
  28. }
  29. return factory( w );
  30. };
  31. } else {
  32. factory( global );
  33. }
  34. // Pass this, window may not be defined yet
  35. }(this, function( window ) {
  36. // Can't do this because several apps including ASP.NET trace
  37. // the stack via arguments.caller.callee and Firefox dies if
  38. // you try to trace through "use strict" call chains. (#13335)
  39. // Support: Firefox 18+
  40. //
  41. var deletedIds = [];
  42. var slice = deletedIds.slice;
  43. var concat = deletedIds.concat;
  44. var push = deletedIds.push;
  45. var indexOf = deletedIds.indexOf;
  46. var class2type = {};
  47. var toString = class2type.toString;
  48. var hasOwn = class2type.hasOwnProperty;
  49. var trim = "".trim;
  50. var support = {};
  51. var
  52. version = "1.11.0-beta3",
  53. // Define a local copy of jQuery
  54. jQuery = function( selector, context ) {
  55. // The jQuery object is actually just the init constructor 'enhanced'
  56. // Need init if jQuery is called (just allow error to be thrown if not included)
  57. return new jQuery.fn.init( selector, context );
  58. },
  59. // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
  60. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
  61. // Matches dashed string for camelizing
  62. rmsPrefix = /^-ms-/,
  63. rdashAlpha = /-([\da-z])/gi,
  64. // Used by jQuery.camelCase as callback to replace()
  65. fcamelCase = function( all, letter ) {
  66. return letter.toUpperCase();
  67. };
  68. jQuery.fn = jQuery.prototype = {
  69. // The current version of jQuery being used
  70. jquery: version,
  71. constructor: jQuery,
  72. // Start with an empty selector
  73. selector: "",
  74. // The default length of a jQuery object is 0
  75. length: 0,
  76. toArray: function() {
  77. return slice.call( this );
  78. },
  79. // Get the Nth element in the matched element set OR
  80. // Get the whole matched element set as a clean array
  81. get: function( num ) {
  82. return num != null ?
  83. // Return a 'clean' array
  84. ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
  85. // Return just the object
  86. slice.call( this );
  87. },
  88. // Take an array of elements and push it onto the stack
  89. // (returning the new matched element set)
  90. pushStack: function( elems ) {
  91. // Build a new jQuery matched element set
  92. var ret = jQuery.merge( this.constructor(), elems );
  93. // Add the old object onto the stack (as a reference)
  94. ret.prevObject = this;
  95. ret.context = this.context;
  96. // Return the newly-formed element set
  97. return ret;
  98. },
  99. // Execute a callback for every element in the matched set.
  100. // (You can seed the arguments with an array of args, but this is
  101. // only used internally.)
  102. each: function( callback, args ) {
  103. return jQuery.each( this, callback, args );
  104. },
  105. map: function( callback ) {
  106. return this.pushStack( jQuery.map(this, function( elem, i ) {
  107. return callback.call( elem, i, elem );
  108. }));
  109. },
  110. slice: function() {
  111. return this.pushStack( slice.apply( this, arguments ) );
  112. },
  113. first: function() {
  114. return this.eq( 0 );
  115. },
  116. last: function() {
  117. return this.eq( -1 );
  118. },
  119. eq: function( i ) {
  120. var len = this.length,
  121. j = +i + ( i < 0 ? len : 0 );
  122. return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
  123. },
  124. end: function() {
  125. return this.prevObject || this.constructor(null);
  126. },
  127. // For internal use only.
  128. // Behaves like an Array's method, not like a jQuery method.
  129. push: push,
  130. sort: deletedIds.sort,
  131. splice: deletedIds.splice
  132. };
  133. jQuery.extend = jQuery.fn.extend = function() {
  134. var src, copyIsArray, copy, name, options, clone,
  135. target = arguments[0] || {},
  136. i = 1,
  137. length = arguments.length,
  138. deep = false;
  139. // Handle a deep copy situation
  140. if ( typeof target === "boolean" ) {
  141. deep = target;
  142. // skip the boolean and the target
  143. target = arguments[ i ] || {};
  144. i++;
  145. }
  146. // Handle case when target is a string or something (possible in deep copy)
  147. if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
  148. target = {};
  149. }
  150. // extend jQuery itself if only one argument is passed
  151. if ( i === length ) {
  152. target = this;
  153. i--;
  154. }
  155. for ( ; i < length; i++ ) {
  156. // Only deal with non-null/undefined values
  157. if ( (options = arguments[ i ]) != null ) {
  158. // Extend the base object
  159. for ( name in options ) {
  160. src = target[ name ];
  161. copy = options[ name ];
  162. // Prevent never-ending loop
  163. if ( target === copy ) {
  164. continue;
  165. }
  166. // Recurse if we're merging plain objects or arrays
  167. if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
  168. if ( copyIsArray ) {
  169. copyIsArray = false;
  170. clone = src && jQuery.isArray(src) ? src : [];
  171. } else {
  172. clone = src && jQuery.isPlainObject(src) ? src : {};
  173. }
  174. // Never move original objects, clone them
  175. target[ name ] = jQuery.extend( deep, clone, copy );
  176. // Don't bring in undefined values
  177. } else if ( copy !== undefined ) {
  178. target[ name ] = copy;
  179. }
  180. }
  181. }
  182. }
  183. // Return the modified object
  184. return target;
  185. };
  186. jQuery.extend({
  187. // Unique for each copy of jQuery on the page
  188. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  189. // Assume jQuery is ready without the ready module
  190. isReady: true,
  191. error: function( msg ) {
  192. throw new Error( msg );
  193. },
  194. noop: function() {},
  195. // See test/unit/core.js for details concerning isFunction.
  196. // Since version 1.3, DOM methods and functions like alert
  197. // aren't supported. They return false on IE (#2968).
  198. isFunction: function( obj ) {
  199. return jQuery.type(obj) === "function";
  200. },
  201. isArray: Array.isArray || function( obj ) {
  202. return jQuery.type(obj) === "array";
  203. },
  204. isWindow: function( obj ) {
  205. /* jshint eqeqeq: false */
  206. return obj != null && obj == obj.window;
  207. },
  208. isNumeric: function( obj ) {
  209. // parseFloat NaNs numeric-cast false positives (null|true|false|"")
  210. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  211. // subtraction forces infinities to NaN
  212. return obj - parseFloat( obj ) >= 0;
  213. },
  214. isEmptyObject: function( obj ) {
  215. var name;
  216. for ( name in obj ) {
  217. return false;
  218. }
  219. return true;
  220. },
  221. isPlainObject: function( obj ) {
  222. var key;
  223. // Must be an Object.
  224. // Because of IE, we also have to check the presence of the constructor property.
  225. // Make sure that DOM nodes and window objects don't pass through, as well
  226. if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
  227. return false;
  228. }
  229. try {
  230. // Not own constructor property must be Object
  231. if ( obj.constructor &&
  232. !hasOwn.call(obj, "constructor") &&
  233. !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
  234. return false;
  235. }
  236. } catch ( e ) {
  237. // IE8,9 Will throw exceptions on certain host objects #9897
  238. return false;
  239. }
  240. // Support: IE<9
  241. // Handle iteration over inherited properties before own properties.
  242. if ( support.ownLast ) {
  243. for ( key in obj ) {
  244. return hasOwn.call( obj, key );
  245. }
  246. }
  247. // Own properties are enumerated firstly, so to speed up,
  248. // if last one is own, then all properties are own.
  249. for ( key in obj ) {}
  250. return key === undefined || hasOwn.call( obj, key );
  251. },
  252. type: function( obj ) {
  253. if ( obj == null ) {
  254. return obj + "";
  255. }
  256. return typeof obj === "object" || typeof obj === "function" ?
  257. class2type[ toString.call(obj) ] || "object" :
  258. typeof obj;
  259. },
  260. // Evaluates a script in a global context
  261. // Workarounds based on findings by Jim Driscoll
  262. // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
  263. globalEval: function( data ) {
  264. if ( data && jQuery.trim( data ) ) {
  265. // We use execScript on Internet Explorer
  266. // We use an anonymous function so that context is window
  267. // rather than jQuery in Firefox
  268. ( window.execScript || function( data ) {
  269. window[ "eval" ].call( window, data );
  270. } )( data );
  271. }
  272. },
  273. // Convert dashed to camelCase; used by the css and data modules
  274. // Microsoft forgot to hump their vendor prefix (#9572)
  275. camelCase: function( string ) {
  276. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  277. },
  278. nodeName: function( elem, name ) {
  279. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  280. },
  281. // args is for internal usage only
  282. each: function( obj, callback, args ) {
  283. var value,
  284. i = 0,
  285. length = obj.length,
  286. isArray = isArraylike( obj );
  287. if ( args ) {
  288. if ( isArray ) {
  289. for ( ; i < length; i++ ) {
  290. value = callback.apply( obj[ i ], args );
  291. if ( value === false ) {
  292. break;
  293. }
  294. }
  295. } else {
  296. for ( i in obj ) {
  297. value = callback.apply( obj[ i ], args );
  298. if ( value === false ) {
  299. break;
  300. }
  301. }
  302. }
  303. // A special, fast, case for the most common use of each
  304. } else {
  305. if ( isArray ) {
  306. for ( ; i < length; i++ ) {
  307. value = callback.call( obj[ i ], i, obj[ i ] );
  308. if ( value === false ) {
  309. break;
  310. }
  311. }
  312. } else {
  313. for ( i in obj ) {
  314. value = callback.call( obj[ i ], i, obj[ i ] );
  315. if ( value === false ) {
  316. break;
  317. }
  318. }
  319. }
  320. }
  321. return obj;
  322. },
  323. // Use native String.trim function wherever possible
  324. trim: trim && !trim.call("\uFEFF\xA0") ?
  325. function( text ) {
  326. return text == null ?
  327. "" :
  328. trim.call( text );
  329. } :
  330. // Otherwise use our own trimming functionality
  331. function( text ) {
  332. return text == null ?
  333. "" :
  334. ( text + "" ).replace( rtrim, "" );
  335. },
  336. // results is for internal usage only
  337. makeArray: function( arr, results ) {
  338. var ret = results || [];
  339. if ( arr != null ) {
  340. if ( isArraylike( Object(arr) ) ) {
  341. jQuery.merge( ret,
  342. typeof arr === "string" ?
  343. [ arr ] : arr
  344. );
  345. } else {
  346. push.call( ret, arr );
  347. }
  348. }
  349. return ret;
  350. },
  351. inArray: function( elem, arr, i ) {
  352. var len;
  353. if ( arr ) {
  354. if ( indexOf ) {
  355. return indexOf.call( arr, elem, i );
  356. }
  357. len = arr.length;
  358. i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
  359. for ( ; i < len; i++ ) {
  360. // Skip accessing in sparse arrays
  361. if ( i in arr && arr[ i ] === elem ) {
  362. return i;
  363. }
  364. }
  365. }
  366. return -1;
  367. },
  368. merge: function( first, second ) {
  369. var len = +second.length,
  370. j = 0,
  371. i = first.length;
  372. while ( j < len ) {
  373. first[ i++ ] = second[ j++ ];
  374. }
  375. // Support: IE<9
  376. // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
  377. if ( len !== len ) {
  378. while ( second[j] !== undefined ) {
  379. first[ i++ ] = second[ j++ ];
  380. }
  381. }
  382. first.length = i;
  383. return first;
  384. },
  385. grep: function( elems, callback, invert ) {
  386. var callbackInverse,
  387. matches = [],
  388. i = 0,
  389. length = elems.length,
  390. callbackExpect = !invert;
  391. // Go through the array, only saving the items
  392. // that pass the validator function
  393. for ( ; i < length; i++ ) {
  394. callbackInverse = !callback( elems[ i ], i );
  395. if ( callbackInverse !== callbackExpect ) {
  396. matches.push( elems[ i ] );
  397. }
  398. }
  399. return matches;
  400. },
  401. // arg is for internal usage only
  402. map: function( elems, callback, arg ) {
  403. var value,
  404. i = 0,
  405. length = elems.length,
  406. isArray = isArraylike( elems ),
  407. ret = [];
  408. // Go through the array, translating each of the items to their new values
  409. if ( isArray ) {
  410. for ( ; i < length; i++ ) {
  411. value = callback( elems[ i ], i, arg );
  412. if ( value != null ) {
  413. ret.push( value );
  414. }
  415. }
  416. // Go through every key on the object,
  417. } else {
  418. for ( i in elems ) {
  419. value = callback( elems[ i ], i, arg );
  420. if ( value != null ) {
  421. ret.push( value );
  422. }
  423. }
  424. }
  425. // Flatten any nested arrays
  426. return concat.apply( [], ret );
  427. },
  428. // A global GUID counter for objects
  429. guid: 1,
  430. // Bind a function to a context, optionally partially applying any
  431. // arguments.
  432. proxy: function( fn, context ) {
  433. var args, proxy, tmp;
  434. if ( typeof context === "string" ) {
  435. tmp = fn[ context ];
  436. context = fn;
  437. fn = tmp;
  438. }
  439. // Quick check to determine if target is callable, in the spec
  440. // this throws a TypeError, but we will just return undefined.
  441. if ( !jQuery.isFunction( fn ) ) {
  442. return undefined;
  443. }
  444. // Simulated bind
  445. args = slice.call( arguments, 2 );
  446. proxy = function() {
  447. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  448. };
  449. // Set the guid of unique handler to the same of original handler, so it can be removed
  450. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  451. return proxy;
  452. },
  453. now: function() {
  454. return +( new Date() );
  455. },
  456. // jQuery.support is not used in Core but other projects attach their
  457. // properties to it so it needs to exist.
  458. support: support
  459. });
  460. // Populate the class2type map
  461. jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
  462. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  463. });
  464. function isArraylike( obj ) {
  465. var length = obj.length,
  466. type = jQuery.type( obj );
  467. if ( type === "function" || jQuery.isWindow( obj ) ) {
  468. return false;
  469. }
  470. if ( obj.nodeType === 1 && length ) {
  471. return true;
  472. }
  473. return type === "array" || length === 0 ||
  474. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  475. }
  476. var Sizzle =
  477. /*!
  478. * Sizzle CSS Selector Engine v1.10.15
  479. * http://sizzlejs.com/
  480. *
  481. * Copyright 2013 jQuery Foundation, Inc. and other contributors
  482. * Released under the MIT license
  483. * http://jquery.org/license
  484. *
  485. * Date: 2013-12-20
  486. */
  487. (function( window ) {
  488. var i,
  489. support,
  490. cachedruns,
  491. Expr,
  492. getText,
  493. isXML,
  494. compile,
  495. outermostContext,
  496. sortInput,
  497. hasDuplicate,
  498. // Local document vars
  499. setDocument,
  500. document,
  501. docElem,
  502. documentIsHTML,
  503. rbuggyQSA,
  504. rbuggyMatches,
  505. matches,
  506. contains,
  507. // Instance-specific data
  508. expando = "sizzle" + -(new Date()),
  509. preferredDoc = window.document,
  510. dirruns = 0,
  511. done = 0,
  512. classCache = createCache(),
  513. tokenCache = createCache(),
  514. compilerCache = createCache(),
  515. sortOrder = function( a, b ) {
  516. if ( a === b ) {
  517. hasDuplicate = true;
  518. }
  519. return 0;
  520. },
  521. // General-purpose constants
  522. strundefined = typeof undefined,
  523. MAX_NEGATIVE = 1 << 31,
  524. // Instance methods
  525. hasOwn = ({}).hasOwnProperty,
  526. arr = [],
  527. pop = arr.pop,
  528. push_native = arr.push,
  529. push = arr.push,
  530. slice = arr.slice,
  531. // Use a stripped-down indexOf if we can't use a native one
  532. indexOf = arr.indexOf || function( elem ) {
  533. var i = 0,
  534. len = this.length;
  535. for ( ; i < len; i++ ) {
  536. if ( this[i] === elem ) {
  537. return i;
  538. }
  539. }
  540. return -1;
  541. },
  542. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  543. // Regular expressions
  544. // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
  545. whitespace = "[\\x20\\t\\r\\n\\f]",
  546. // http://www.w3.org/TR/css3-syntax/#characters
  547. characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
  548. // Loosely modeled on CSS identifier characters
  549. // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
  550. // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  551. identifier = characterEncoding.replace( "w", "w#" ),
  552. // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
  553. attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
  554. "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
  555. // Prefer arguments quoted,
  556. // then not containing pseudos/brackets,
  557. // then attribute selectors/non-parenthetical expressions,
  558. // then anything else
  559. // These preferences are here to reduce the number of selectors
  560. // needing tokenize in the PSEUDO preFilter
  561. pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)",
  562. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  563. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  564. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  565. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  566. rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
  567. rpseudo = new RegExp( pseudos ),
  568. ridentifier = new RegExp( "^" + identifier + "$" ),
  569. matchExpr = {
  570. "ID": new RegExp( "^#(" + characterEncoding + ")" ),
  571. "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
  572. "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
  573. "ATTR": new RegExp( "^" + attributes ),
  574. "PSEUDO": new RegExp( "^" + pseudos ),
  575. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  576. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  577. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  578. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  579. // For use in libraries implementing .is()
  580. // We use this for POS matching in `select`
  581. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  582. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  583. },
  584. rinputs = /^(?:input|select|textarea|button)$/i,
  585. rheader = /^h\d$/i,
  586. rnative = /^[^{]+\{\s*\[native \w/,
  587. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  588. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  589. rsibling = /[+~]/,
  590. rescape = /'|\\/g,
  591. // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  592. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  593. funescape = function( _, escaped, escapedWhitespace ) {
  594. var high = "0x" + escaped - 0x10000;
  595. // NaN means non-codepoint
  596. // Support: Firefox
  597. // Workaround erroneous numeric interpretation of +"0x"
  598. return high !== high || escapedWhitespace ?
  599. escaped :
  600. high < 0 ?
  601. // BMP codepoint
  602. String.fromCharCode( high + 0x10000 ) :
  603. // Supplemental Plane codepoint (surrogate pair)
  604. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  605. };
  606. // Optimize for push.apply( _, NodeList )
  607. try {
  608. push.apply(
  609. (arr = slice.call( preferredDoc.childNodes )),
  610. preferredDoc.childNodes
  611. );
  612. // Support: Android<4.0
  613. // Detect silently failing push.apply
  614. arr[ preferredDoc.childNodes.length ].nodeType;
  615. } catch ( e ) {
  616. push = { apply: arr.length ?
  617. // Leverage slice if possible
  618. function( target, els ) {
  619. push_native.apply( target, slice.call(els) );
  620. } :
  621. // Support: IE<9
  622. // Otherwise append directly
  623. function( target, els ) {
  624. var j = target.length,
  625. i = 0;
  626. // Can't trust NodeList.length
  627. while ( (target[j++] = els[i++]) ) {}
  628. target.length = j - 1;
  629. }
  630. };
  631. }
  632. function Sizzle( selector, context, results, seed ) {
  633. var match, elem, m, nodeType,
  634. // QSA vars
  635. i, groups, old, nid, newContext, newSelector;
  636. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  637. setDocument( context );
  638. }
  639. context = context || document;
  640. results = results || [];
  641. if ( !selector || typeof selector !== "string" ) {
  642. return results;
  643. }
  644. if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
  645. return [];
  646. }
  647. if ( documentIsHTML && !seed ) {
  648. // Shortcuts
  649. if ( (match = rquickExpr.exec( selector )) ) {
  650. // Speed-up: Sizzle("#ID")
  651. if ( (m = match[1]) ) {
  652. if ( nodeType === 9 ) {
  653. elem = context.getElementById( m );
  654. // Check parentNode to catch when Blackberry 4.6 returns
  655. // nodes that are no longer in the document (jQuery #6963)
  656. if ( elem && elem.parentNode ) {
  657. // Handle the case where IE, Opera, and Webkit return items
  658. // by name instead of ID
  659. if ( elem.id === m ) {
  660. results.push( elem );
  661. return results;
  662. }
  663. } else {
  664. return results;
  665. }
  666. } else {
  667. // Context is not a document
  668. if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
  669. contains( context, elem ) && elem.id === m ) {
  670. results.push( elem );
  671. return results;
  672. }
  673. }
  674. // Speed-up: Sizzle("TAG")
  675. } else if ( match[2] ) {
  676. push.apply( results, context.getElementsByTagName( selector ) );
  677. return results;
  678. // Speed-up: Sizzle(".CLASS")
  679. } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
  680. push.apply( results, context.getElementsByClassName( m ) );
  681. return results;
  682. }
  683. }
  684. // QSA path
  685. if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
  686. nid = old = expando;
  687. newContext = context;
  688. newSelector = nodeType === 9 && selector;
  689. // qSA works strangely on Element-rooted queries
  690. // We can work around this by specifying an extra ID on the root
  691. // and working up from there (Thanks to Andrew Dupont for the technique)
  692. // IE 8 doesn't work on object elements
  693. if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
  694. groups = tokenize( selector );
  695. if ( (old = context.getAttribute("id")) ) {
  696. nid = old.replace( rescape, "\\$&" );
  697. } else {
  698. context.setAttribute( "id", nid );
  699. }
  700. nid = "[id='" + nid + "'] ";
  701. i = groups.length;
  702. while ( i-- ) {
  703. groups[i] = nid + toSelector( groups[i] );
  704. }
  705. newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
  706. newSelector = groups.join(",");
  707. }
  708. if ( newSelector ) {
  709. try {
  710. push.apply( results,
  711. newContext.querySelectorAll( newSelector )
  712. );
  713. return results;
  714. } catch(qsaError) {
  715. } finally {
  716. if ( !old ) {
  717. context.removeAttribute("id");
  718. }
  719. }
  720. }
  721. }
  722. }
  723. // All others
  724. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  725. }
  726. /**
  727. * Create key-value caches of limited size
  728. * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
  729. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  730. * deleting the oldest entry
  731. */
  732. function createCache() {
  733. var keys = [];
  734. function cache( key, value ) {
  735. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  736. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  737. // Only keep the most recent entries
  738. delete cache[ keys.shift() ];
  739. }
  740. return (cache[ key + " " ] = value);
  741. }
  742. return cache;
  743. }
  744. /**
  745. * Mark a function for special use by Sizzle
  746. * @param {Function} fn The function to mark
  747. */
  748. function markFunction( fn ) {
  749. fn[ expando ] = true;
  750. return fn;
  751. }
  752. /**
  753. * Support testing using an element
  754. * @param {Function} fn Passed the created div and expects a boolean result
  755. */
  756. function assert( fn ) {
  757. var div = document.createElement("div");
  758. try {
  759. return !!fn( div );
  760. } catch (e) {
  761. return false;
  762. } finally {
  763. // Remove from its parent by default
  764. if ( div.parentNode ) {
  765. div.parentNode.removeChild( div );
  766. }
  767. // release memory in IE
  768. div = null;
  769. }
  770. }
  771. /**
  772. * Adds the same handler for all of the specified attrs
  773. * @param {String} attrs Pipe-separated list of attributes
  774. * @param {Function} handler The method that will be applied
  775. */
  776. function addHandle( attrs, handler ) {
  777. var arr = attrs.split("|"),
  778. i = attrs.length;
  779. while ( i-- ) {
  780. Expr.attrHandle[ arr[i] ] = handler;
  781. }
  782. }
  783. /**
  784. * Checks document order of two siblings
  785. * @param {Element} a
  786. * @param {Element} b
  787. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  788. */
  789. function siblingCheck( a, b ) {
  790. var cur = b && a,
  791. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  792. ( ~b.sourceIndex || MAX_NEGATIVE ) -
  793. ( ~a.sourceIndex || MAX_NEGATIVE );
  794. // Use IE sourceIndex if available on both nodes
  795. if ( diff ) {
  796. return diff;
  797. }
  798. // Check if b follows a
  799. if ( cur ) {
  800. while ( (cur = cur.nextSibling) ) {
  801. if ( cur === b ) {
  802. return -1;
  803. }
  804. }
  805. }
  806. return a ? 1 : -1;
  807. }
  808. /**
  809. * Returns a function to use in pseudos for input types
  810. * @param {String} type
  811. */
  812. function createInputPseudo( type ) {
  813. return function( elem ) {
  814. var name = elem.nodeName.toLowerCase();
  815. return name === "input" && elem.type === type;
  816. };
  817. }
  818. /**
  819. * Returns a function to use in pseudos for buttons
  820. * @param {String} type
  821. */
  822. function createButtonPseudo( type ) {
  823. return function( elem ) {
  824. var name = elem.nodeName.toLowerCase();
  825. return (name === "input" || name === "button") && elem.type === type;
  826. };
  827. }
  828. /**
  829. * Returns a function to use in pseudos for positionals
  830. * @param {Function} fn
  831. */
  832. function createPositionalPseudo( fn ) {
  833. return markFunction(function( argument ) {
  834. argument = +argument;
  835. return markFunction(function( seed, matches ) {
  836. var j,
  837. matchIndexes = fn( [], seed.length, argument ),
  838. i = matchIndexes.length;
  839. // Match elements found at the specified indexes
  840. while ( i-- ) {
  841. if ( seed[ (j = matchIndexes[i]) ] ) {
  842. seed[j] = !(matches[j] = seed[j]);
  843. }
  844. }
  845. });
  846. });
  847. }
  848. /**
  849. * Checks a node for validity as a Sizzle context
  850. * @param {Element|Object=} context
  851. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  852. */
  853. function testContext( context ) {
  854. return context && typeof context.getElementsByTagName !== strundefined && context;
  855. }
  856. // Expose support vars for convenience
  857. support = Sizzle.support = {};
  858. /**
  859. * Detects XML nodes
  860. * @param {Element|Object} elem An element or a document
  861. * @returns {Boolean} True iff elem is a non-HTML XML node
  862. */
  863. isXML = Sizzle.isXML = function( elem ) {
  864. // documentElement is verified for cases where it doesn't yet exist
  865. // (such as loading iframes in IE - #4833)
  866. var documentElement = elem && (elem.ownerDocument || elem).documentElement;
  867. return documentElement ? documentElement.nodeName !== "HTML" : false;
  868. };
  869. /**
  870. * Sets document-related variables once based on the current document
  871. * @param {Element|Object} [doc] An element or document object to use to set the document
  872. * @returns {Object} Returns the current document
  873. */
  874. setDocument = Sizzle.setDocument = function( node ) {
  875. var hasCompare,
  876. doc = node ? node.ownerDocument || node : preferredDoc,
  877. parent = doc.defaultView;
  878. // If no document and documentElement is available, return
  879. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  880. return document;
  881. }
  882. // Set our document
  883. document = doc;
  884. docElem = doc.documentElement;
  885. // Support tests
  886. documentIsHTML = !isXML( doc );
  887. // Support: IE>8
  888. // If iframe document is assigned to "document" variable and if iframe has been reloaded,
  889. // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
  890. // IE6-8 do not support the defaultView property so parent will be undefined
  891. if ( parent && parent !== parent.top ) {
  892. // IE11 does not have attachEvent, so all must suffer
  893. if ( parent.addEventListener ) {
  894. parent.addEventListener( "unload", function() {
  895. setDocument();
  896. }, false );
  897. } else if ( parent.attachEvent ) {
  898. parent.attachEvent( "onunload", function() {
  899. setDocument();
  900. });
  901. }
  902. }
  903. /* Attributes
  904. ---------------------------------------------------------------------- */
  905. // Support: IE<8
  906. // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
  907. support.attributes = assert(function( div ) {
  908. div.className = "i";
  909. return !div.getAttribute("className");
  910. });
  911. /* getElement(s)By*
  912. ---------------------------------------------------------------------- */
  913. // Check if getElementsByTagName("*") returns only elements
  914. support.getElementsByTagName = assert(function( div ) {
  915. div.appendChild( doc.createComment("") );
  916. return !div.getElementsByTagName("*").length;
  917. });
  918. // Check if getElementsByClassName can be trusted
  919. support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
  920. div.innerHTML = "<div class='a'></div><div class='a i'></div>";
  921. // Support: Safari<4
  922. // Catch class over-caching
  923. div.firstChild.className = "i";
  924. // Support: Opera<10
  925. // Catch gEBCN failure to find non-leading classes
  926. return div.getElementsByClassName("i").length === 2;
  927. });
  928. // Support: IE<10
  929. // Check if getElementById returns elements by name
  930. // The broken getElementById methods don't pick up programatically-set names,
  931. // so use a roundabout getElementsByName test
  932. support.getById = assert(function( div ) {
  933. docElem.appendChild( div ).id = expando;
  934. return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
  935. });
  936. // ID find and filter
  937. if ( support.getById ) {
  938. Expr.find["ID"] = function( id, context ) {
  939. if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
  940. var m = context.getElementById( id );
  941. // Check parentNode to catch when Blackberry 4.6 returns
  942. // nodes that are no longer in the document #6963
  943. return m && m.parentNode ? [m] : [];
  944. }
  945. };
  946. Expr.filter["ID"] = function( id ) {
  947. var attrId = id.replace( runescape, funescape );
  948. return function( elem ) {
  949. return elem.getAttribute("id") === attrId;
  950. };
  951. };
  952. } else {
  953. // Support: IE6/7
  954. // getElementById is not reliable as a find shortcut
  955. delete Expr.find["ID"];
  956. Expr.filter["ID"] = function( id ) {
  957. var attrId = id.replace( runescape, funescape );
  958. return function( elem ) {
  959. var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
  960. return node && node.value === attrId;
  961. };
  962. };
  963. }
  964. // Tag
  965. Expr.find["TAG"] = support.getElementsByTagName ?
  966. function( tag, context ) {
  967. if ( typeof context.getElementsByTagName !== strundefined ) {
  968. return context.getElementsByTagName( tag );
  969. }
  970. } :
  971. function( tag, context ) {
  972. var elem,
  973. tmp = [],
  974. i = 0,
  975. results = context.getElementsByTagName( tag );
  976. // Filter out possible comments
  977. if ( tag === "*" ) {
  978. while ( (elem = results[i++]) ) {
  979. if ( elem.nodeType === 1 ) {
  980. tmp.push( elem );
  981. }
  982. }
  983. return tmp;
  984. }
  985. return results;
  986. };
  987. // Class
  988. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  989. if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
  990. return context.getElementsByClassName( className );
  991. }
  992. };
  993. /* QSA/matchesSelector
  994. ---------------------------------------------------------------------- */
  995. // QSA and matchesSelector support
  996. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  997. rbuggyMatches = [];
  998. // qSa(:focus) reports false when true (Chrome 21)
  999. // We allow this because of a bug in IE8/9 that throws an error
  1000. // whenever `document.activeElement` is accessed on an iframe
  1001. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  1002. // See http://bugs.jquery.com/ticket/13378
  1003. rbuggyQSA = [];
  1004. if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
  1005. // Build QSA regex
  1006. // Regex strategy adopted from Diego Perini
  1007. assert(function( div ) {
  1008. // Select is set to empty string on purpose
  1009. // This is to test IE's treatment of not explicitly
  1010. // setting a boolean content attribute,
  1011. // since its presence should be enough
  1012. // http://bugs.jquery.com/ticket/12359
  1013. div.innerHTML = "<select t=''><option selected=''></option></select>";
  1014. // Support: IE8, Opera 10-12
  1015. // Nothing should be selected when empty strings follow ^= or $= or *=
  1016. if ( div.querySelectorAll("[t^='']").length ) {
  1017. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  1018. }
  1019. // Support: IE8
  1020. // Boolean attributes and "value" are not treated correctly
  1021. if ( !div.querySelectorAll("[selected]").length ) {
  1022. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  1023. }
  1024. // Webkit/Opera - :checked should return selected option elements
  1025. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1026. // IE8 throws error here and will not see later tests
  1027. if ( !div.querySelectorAll(":checked").length ) {
  1028. rbuggyQSA.push(":checked");
  1029. }
  1030. });
  1031. assert(function( div ) {
  1032. // Support: Windows 8 Native Apps
  1033. // The type and name attributes are restricted during .innerHTML assignment
  1034. var input = doc.createElement("input");
  1035. input.setAttribute( "type", "hidden" );
  1036. div.appendChild( input ).setAttribute( "name", "D" );
  1037. // Support: IE8
  1038. // Enforce case-sensitivity of name attribute
  1039. if ( div.querySelectorAll("[name=d]").length ) {
  1040. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  1041. }
  1042. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  1043. // IE8 throws error here and will not see later tests
  1044. if ( !div.querySelectorAll(":enabled").length ) {
  1045. rbuggyQSA.push( ":enabled", ":disabled" );
  1046. }
  1047. // Opera 10-11 does not throw on post-comma invalid pseudos
  1048. div.querySelectorAll("*,:x");
  1049. rbuggyQSA.push(",.*:");
  1050. });
  1051. }
  1052. if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector ||
  1053. docElem.mozMatchesSelector ||
  1054. docElem.oMatchesSelector ||
  1055. docElem.msMatchesSelector) )) ) {
  1056. assert(function( div ) {
  1057. // Check to see if it's possible to do matchesSelector
  1058. // on a disconnected node (IE 9)
  1059. support.disconnectedMatch = matches.call( div, "div" );
  1060. // This should fail with an exception
  1061. // Gecko does not error, returns false instead
  1062. matches.call( div, "[s!='']:x" );
  1063. rbuggyMatches.push( "!=", pseudos );
  1064. });
  1065. }
  1066. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  1067. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  1068. /* Contains
  1069. ---------------------------------------------------------------------- */
  1070. hasCompare = rnative.test( docElem.compareDocumentPosition );
  1071. // Element contains another
  1072. // Purposefully does not implement inclusive descendent
  1073. // As in, an element does not contain itself
  1074. contains = hasCompare || rnative.test( docElem.contains ) ?
  1075. function( a, b ) {
  1076. var adown = a.nodeType === 9 ? a.documentElement : a,
  1077. bup = b && b.parentNode;
  1078. return a === bup || !!( bup && bup.nodeType === 1 && (
  1079. adown.contains ?
  1080. adown.contains( bup ) :
  1081. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  1082. ));
  1083. } :
  1084. function( a, b ) {
  1085. if ( b ) {
  1086. while ( (b = b.parentNode) ) {
  1087. if ( b === a ) {
  1088. return true;
  1089. }
  1090. }
  1091. }
  1092. return false;
  1093. };
  1094. /* Sorting
  1095. ---------------------------------------------------------------------- */
  1096. // Document order sorting
  1097. sortOrder = hasCompare ?
  1098. function( a, b ) {
  1099. // Flag for duplicate removal
  1100. if ( a === b ) {
  1101. hasDuplicate = true;
  1102. return 0;
  1103. }
  1104. // Sort on method existence if only one input has compareDocumentPosition
  1105. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  1106. if ( compare ) {
  1107. return compare;
  1108. }
  1109. // Calculate position if both inputs belong to the same document
  1110. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  1111. a.compareDocumentPosition( b ) :
  1112. // Otherwise we know they are disconnected
  1113. 1;
  1114. // Disconnected nodes
  1115. if ( compare & 1 ||
  1116. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  1117. // Choose the first element that is related to our preferred document
  1118. if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  1119. return -1;
  1120. }
  1121. if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  1122. return 1;
  1123. }
  1124. // Maintain original order
  1125. return sortInput ?
  1126. ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
  1127. 0;
  1128. }
  1129. return compare & 4 ? -1 : 1;
  1130. } :
  1131. function( a, b ) {
  1132. // Exit early if the nodes are identical
  1133. if ( a === b ) {
  1134. hasDuplicate = true;
  1135. return 0;
  1136. }
  1137. var cur,
  1138. i = 0,
  1139. aup = a.parentNode,
  1140. bup = b.parentNode,
  1141. ap = [ a ],
  1142. bp = [ b ];
  1143. // Parentless nodes are either documents or disconnected
  1144. if ( !aup || !bup ) {
  1145. return a === doc ? -1 :
  1146. b === doc ? 1 :
  1147. aup ? -1 :
  1148. bup ? 1 :
  1149. sortInput ?
  1150. ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
  1151. 0;
  1152. // If the nodes are siblings, we can do a quick check
  1153. } else if ( aup === bup ) {
  1154. return siblingCheck( a, b );
  1155. }
  1156. // Otherwise we need full lists of their ancestors for comparison
  1157. cur = a;
  1158. while ( (cur = cur.parentNode) ) {
  1159. ap.unshift( cur );
  1160. }
  1161. cur = b;
  1162. while ( (cur = cur.parentNode) ) {
  1163. bp.unshift( cur );
  1164. }
  1165. // Walk down the tree looking for a discrepancy
  1166. while ( ap[i] === bp[i] ) {
  1167. i++;
  1168. }
  1169. return i ?
  1170. // Do a sibling check if the nodes have a common ancestor
  1171. siblingCheck( ap[i], bp[i] ) :
  1172. // Otherwise nodes in our document sort first
  1173. ap[i] === preferredDoc ? -1 :
  1174. bp[i] === preferredDoc ? 1 :
  1175. 0;
  1176. };
  1177. return doc;
  1178. };
  1179. Sizzle.matches = function( expr, elements ) {
  1180. return Sizzle( expr, null, null, elements );
  1181. };
  1182. Sizzle.matchesSelector = function( elem, expr ) {
  1183. // Set document vars if needed
  1184. if ( ( elem.ownerDocument || elem ) !== document ) {
  1185. setDocument( elem );
  1186. }
  1187. // Make sure that attribute selectors are quoted
  1188. expr = expr.replace( rattributeQuotes, "='$1']" );
  1189. if ( support.matchesSelector && documentIsHTML &&
  1190. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  1191. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  1192. try {
  1193. var ret = matches.call( elem, expr );
  1194. // IE 9's matchesSelector returns false on disconnected nodes
  1195. if ( ret || support.disconnectedMatch ||
  1196. // As well, disconnected nodes are said to be in a document
  1197. // fragment in IE 9
  1198. elem.document && elem.document.nodeType !== 11 ) {
  1199. return ret;
  1200. }
  1201. } catch(e) {}
  1202. }
  1203. return Sizzle( expr, document, null, [elem] ).length > 0;
  1204. };
  1205. Sizzle.contains = function( context, elem ) {
  1206. // Set document vars if needed
  1207. if ( ( context.ownerDocument || context ) !== document ) {
  1208. setDocument( context );
  1209. }
  1210. return contains( context, elem );
  1211. };
  1212. Sizzle.attr = function( elem, name ) {
  1213. // Set document vars if needed
  1214. if ( ( elem.ownerDocument || elem ) !== document ) {
  1215. setDocument( elem );
  1216. }
  1217. var fn = Expr.attrHandle[ name.toLowerCase() ],
  1218. // Don't get fooled by Object.prototype properties (jQuery #13807)
  1219. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  1220. fn( elem, name, !documentIsHTML ) :
  1221. undefined;
  1222. return val !== undefined ?
  1223. val :
  1224. support.attributes || !documentIsHTML ?
  1225. elem.getAttribute( name ) :
  1226. (val = elem.getAttributeNode(name)) && val.specified ?
  1227. val.value :
  1228. null;
  1229. };
  1230. Sizzle.error = function( msg ) {
  1231. throw new Error( "Syntax error, unrecognized expression: " + msg );
  1232. };
  1233. /**
  1234. * Document sorting and removing duplicates
  1235. * @param {ArrayLike} results
  1236. */
  1237. Sizzle.uniqueSort = function( results ) {
  1238. var elem,
  1239. duplicates = [],
  1240. j = 0,
  1241. i = 0;
  1242. // Unless we *know* we can detect duplicates, assume their presence
  1243. hasDuplicate = !support.detectDuplicates;
  1244. sortInput = !support.sortStable && results.slice( 0 );
  1245. results.sort( sortOrder );
  1246. if ( hasDuplicate ) {
  1247. while ( (elem = results[i++]) ) {
  1248. if ( elem === results[ i ] ) {
  1249. j = duplicates.push( i );
  1250. }
  1251. }
  1252. while ( j-- ) {
  1253. results.splice( duplicates[ j ], 1 );
  1254. }
  1255. }
  1256. // Clear input after sorting to release objects
  1257. // See https://github.com/jquery/sizzle/pull/225
  1258. sortInput = null;
  1259. return results;
  1260. };
  1261. /**
  1262. * Utility function for retrieving the text value of an array of DOM nodes
  1263. * @param {Array|Element} elem
  1264. */
  1265. getText = Sizzle.getText = function( elem ) {
  1266. var node,
  1267. ret = "",
  1268. i = 0,
  1269. nodeType = elem.nodeType;
  1270. if ( !nodeType ) {
  1271. // If no nodeType, this is expected to be an array
  1272. while ( (node = elem[i++]) ) {
  1273. // Do not traverse comment nodes
  1274. ret += getText( node );
  1275. }
  1276. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  1277. // Use textContent for elements
  1278. // innerText usage removed for consistency of new lines (jQuery #11153)
  1279. if ( typeof elem.textContent === "string" ) {
  1280. return elem.textContent;
  1281. } else {
  1282. // Traverse its children
  1283. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  1284. ret += getText( elem );
  1285. }
  1286. }
  1287. } else if ( nodeType === 3 || nodeType === 4 ) {
  1288. return elem.nodeValue;
  1289. }
  1290. // Do not include comment or processing instruction nodes
  1291. return ret;
  1292. };
  1293. Expr = Sizzle.selectors = {
  1294. // Can be adjusted by the user
  1295. cacheLength: 50,
  1296. createPseudo: markFunction,
  1297. match: matchExpr,
  1298. attrHandle: {},
  1299. find: {},
  1300. relative: {
  1301. ">": { dir: "parentNode", first: true },
  1302. " ": { dir: "parentNode" },
  1303. "+": { dir: "previousSibling", first: true },
  1304. "~": { dir: "previousSibling" }
  1305. },
  1306. preFilter: {
  1307. "ATTR": function( match ) {
  1308. match[1] = match[1].replace( runescape, funescape );
  1309. // Move the given value to match[3] whether quoted or unquoted
  1310. match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape );
  1311. if ( match[2] === "~=" ) {
  1312. match[3] = " " + match[3] + " ";
  1313. }
  1314. return match.slice( 0, 4 );
  1315. },
  1316. "CHILD": function( match ) {
  1317. /* matches from matchExpr["CHILD"]
  1318. 1 type (only|nth|...)
  1319. 2 what (child|of-type)
  1320. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  1321. 4 xn-component of xn+y argument ([+-]?\d*n|)
  1322. 5 sign of xn-component
  1323. 6 x of xn-component
  1324. 7 sign of y-component
  1325. 8 y of y-component
  1326. */
  1327. match[1] = match[1].toLowerCase();
  1328. if ( match[1].slice( 0, 3 ) === "nth" ) {
  1329. // nth-* requires argument
  1330. if ( !match[3] ) {
  1331. Sizzle.error( match[0] );
  1332. }
  1333. // numeric x and y parameters for Expr.filter.CHILD
  1334. // remember that false/true cast respectively to 0/1
  1335. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  1336. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  1337. // other types prohibit arguments
  1338. } else if ( match[3] ) {
  1339. Sizzle.error( match[0] );
  1340. }
  1341. return match;
  1342. },
  1343. "PSEUDO": function( match ) {
  1344. var excess,
  1345. unquoted = !match[5] && match[2];
  1346. if ( matchExpr["CHILD"].test( match[0] ) ) {
  1347. return null;
  1348. }
  1349. // Accept quoted arguments as-is
  1350. if ( match[3] && match[4] !== undefined ) {
  1351. match[2] = match[4];
  1352. // Strip excess characters from unquoted arguments
  1353. } else if ( unquoted && rpseudo.test( unquoted ) &&
  1354. // Get excess from tokenize (recursively)
  1355. (excess = tokenize( unquoted, true )) &&
  1356. // advance to the next closing parenthesis
  1357. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  1358. // excess is a negative index
  1359. match[0] = match[0].slice( 0, excess );
  1360. match[2] = unquoted.slice( 0, excess );
  1361. }
  1362. // Return only captures needed by the pseudo filter method (type and argument)
  1363. return match.slice( 0, 3 );
  1364. }
  1365. },
  1366. filter: {
  1367. "TAG": function( nodeNameSelector ) {
  1368. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  1369. return nodeNameSelector === "*" ?
  1370. function() { return true; } :
  1371. function( elem ) {
  1372. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  1373. };
  1374. },
  1375. "CLASS": function( className ) {
  1376. var pattern = classCache[ className + " " ];
  1377. return pattern ||
  1378. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  1379. classCache( className, function( elem ) {
  1380. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
  1381. });
  1382. },
  1383. "ATTR": function( name, operator, check ) {
  1384. return function( elem ) {
  1385. var result = Sizzle.attr( elem, name );
  1386. if ( result == null ) {
  1387. return operator === "!=";
  1388. }
  1389. if ( !operator ) {
  1390. return true;
  1391. }
  1392. result += "";
  1393. return operator === "=" ? result === check :
  1394. operator === "!=" ? result !== check :
  1395. operator === "^=" ? check && result.indexOf( check ) === 0 :
  1396. operator === "*=" ? check && result.indexOf( check ) > -1 :
  1397. operator === "$=" ? check && result.slice( -check.length ) === check :
  1398. operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
  1399. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  1400. false;
  1401. };
  1402. },
  1403. "CHILD": function( type, what, argument, first, last ) {
  1404. var simple = type.slice( 0, 3 ) !== "nth",
  1405. forward = type.slice( -4 ) !== "last",
  1406. ofType = what === "of-type";
  1407. return first === 1 && last === 0 ?
  1408. // Shortcut for :nth-*(n)
  1409. function( elem ) {
  1410. return !!elem.parentNode;
  1411. } :
  1412. function( elem, context, xml ) {
  1413. var cache, outerCache, node, diff, nodeIndex, start,
  1414. dir = simple !== forward ? "nextSibling" : "previousSibling",
  1415. parent = elem.parentNode,
  1416. name = ofType && elem.nodeName.toLowerCase(),
  1417. useCache = !xml && !ofType;
  1418. if ( parent ) {
  1419. // :(first|last|only)-(child|of-type)
  1420. if ( simple ) {
  1421. while ( dir ) {
  1422. node = elem;
  1423. while ( (node = node[ dir ]) ) {
  1424. if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
  1425. return false;
  1426. }
  1427. }
  1428. // Reverse direction for :only-* (if we haven't yet done so)
  1429. start = dir = type === "only" && !start && "nextSibling";
  1430. }
  1431. return true;
  1432. }
  1433. start = [ forward ? parent.firstChild : parent.lastChild ];
  1434. // non-xml :nth-child(...) stores cache data on `parent`
  1435. if ( forward && useCache ) {
  1436. // Seek `elem` from a previously-cached index
  1437. outerCache = parent[ expando ] || (parent[ expando ] = {});
  1438. cache = outerCache[ type ] || [];
  1439. nodeIndex = cache[0] === dirruns && cache[1];
  1440. diff = cache[0] === dirruns && cache[2];
  1441. node = nodeIndex && parent.childNodes[ nodeIndex ];
  1442. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1443. // Fallback to seeking `elem` from the start
  1444. (diff = nodeIndex = 0) || start.pop()) ) {
  1445. // When found, cache indexes on `parent` and break
  1446. if ( node.nodeType === 1 && ++diff && node === elem ) {
  1447. outerCache[ type ] = [ dirruns, nodeIndex, diff ];
  1448. break;
  1449. }
  1450. }
  1451. // Use previously-cached element index if available
  1452. } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
  1453. diff = cache[1];
  1454. // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
  1455. } else {
  1456. // Use the same loop as above to seek `elem` from the start
  1457. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1458. (diff = nodeIndex = 0) || start.pop()) ) {
  1459. if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
  1460. // Cache the index of each encountered element
  1461. if ( useCache ) {
  1462. (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
  1463. }
  1464. if ( node === elem ) {
  1465. break;
  1466. }
  1467. }
  1468. }
  1469. }
  1470. // Incorporate the offset, then check against cycle size
  1471. diff -= last;
  1472. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  1473. }
  1474. };
  1475. },
  1476. "PSEUDO": function( pseudo, argument ) {
  1477. // pseudo-class names are case-insensitive
  1478. // http://www.w3.org/TR/selectors/#pseudo-classes
  1479. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  1480. // Remember that setFilters inherits from pseudos
  1481. var args,
  1482. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  1483. Sizzle.error( "unsupported pseudo: " + pseudo );
  1484. // The user may use createPseudo to indicate that
  1485. // arguments are needed to create the filter function
  1486. // just as Sizzle does
  1487. if ( fn[ expando ] ) {
  1488. return fn( argument );
  1489. }
  1490. // But maintain support for old signatures
  1491. if ( fn.length > 1 ) {
  1492. args = [ pseudo, pseudo, "", argument ];
  1493. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  1494. markFunction(function( seed, matches ) {
  1495. var idx,
  1496. matched = fn( seed, argument ),
  1497. i = matched.length;
  1498. while ( i-- ) {
  1499. idx = indexOf.call( seed, matched[i] );
  1500. seed[ idx ] = !( matches[ idx ] = matched[i] );
  1501. }
  1502. }) :
  1503. function( elem ) {
  1504. return fn( elem, 0, args );
  1505. };
  1506. }
  1507. return fn;
  1508. }
  1509. },
  1510. pseudos: {
  1511. // Potentially complex pseudos
  1512. "not": markFunction(function( selector ) {
  1513. // Trim the selector passed to compile
  1514. // to avoid treating leading and trailing
  1515. // spaces as combinators
  1516. var input = [],
  1517. results = [],
  1518. matcher = compile( selector.replace( rtrim, "$1" ) );
  1519. return matcher[ expando ] ?
  1520. markFunction(function( seed, matches, context, xml ) {
  1521. var elem,
  1522. unmatched = matcher( seed, null, xml, [] ),
  1523. i = seed.length;
  1524. // Match elements unmatched by `matcher`
  1525. while ( i-- ) {
  1526. if ( (elem = unmatched[i]) ) {
  1527. seed[i] = !(matches[i] = elem);
  1528. }
  1529. }
  1530. }) :
  1531. function( elem, context, xml ) {
  1532. input[0] = elem;
  1533. matcher( input, null, xml, results );
  1534. return !results.pop();
  1535. };
  1536. }),
  1537. "has": ma