PageRenderTime 54ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/actionview/test/ujs/public/vendor/jquery-2.2.0.js

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