jquery-rails 3.1.4 → 3.1.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jquery-rails might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: df3039511de025f938c1043703f28e901fac32b5
4
- data.tar.gz: 8cf080440d33860a8368a64293466e029dbdb02e
2
+ SHA256:
3
+ metadata.gz: 1cc4ee935197027be03834032460f10b605fa29e5f370e956323827ff6459bb0
4
+ data.tar.gz: 01e0552ffb9ac7484592c6a600297361b3238295c162a0374669112893ea9c66
5
5
  SHA512:
6
- metadata.gz: e9e5bb5f4a6a4efa97ab5c56675449781a7065a7addedc7cd1273ed4c3409d5fb6cf986af1016766cdc013dc8448f6f30f6a3c72465092fc88499b8c80b61631
7
- data.tar.gz: cfaf7788837edd78f566323abc7ff7b654fada640b78731265b7f84a2cad8ad6c2ee16850e1942db839622c2773369aa4c357d33793c1920d0e4dc9fa3db1ca2
6
+ metadata.gz: e294510d1e0b4e3ced3ec09e16a8fc6882469e663ed4a5437f69664e4902ef40397fc5b56200c6e8f32747b83540f3e517837539dc8eb090cd779aa94d7c56b3
7
+ data.tar.gz: 335edf0e53ccfd6545b0e83a42ecbb49060505816fca7aff2b49477f9cc87923094aea8487580c24cd3c4502cdb3f582d62807d10f48e3325de3dc6d96bfb458
@@ -1,3 +1,7 @@
1
+ ## 3.1.5 (18 Apr 2018)
2
+
3
+ - Updated jQuery 1.12.4
4
+
1
5
  ## 3.1.3 (16 June 2015)
2
6
 
3
7
  - Fix CSP bypass vulnerability. CVE-2015-1840
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ task :guard_version do
9
9
  def check_version(file, pattern, constant)
10
10
  body = File.read("vendor/assets/javascripts/#{file}")
11
11
  match = body.match(pattern) or abort "Version check failed: no pattern matched in #{file}"
12
- file_version = body.match(pattern)[1]
12
+ file_version = match[1]
13
13
  constant_version = Jquery::Rails.const_get(constant)
14
14
 
15
15
  unless constant_version == file_version
@@ -20,29 +20,19 @@ task :guard_version do
20
20
  check_version('jquery.js', /jQuery JavaScript Library v([\S]+)/, 'JQUERY_VERSION')
21
21
  end
22
22
 
23
+ desc "Update jQuery versions"
23
24
  task :update_jquery do
24
- puts "Downloading jquery.js"
25
- puts `curl -o vendor/assets/javascripts/jquery.js http://code.jquery.com/jquery.js`
26
- puts "Downloading jquery.min.js"
27
- puts `curl -o vendor/assets/javascripts/jquery.min.js http://code.jquery.com/jquery.min.js`
28
- puts "Downloading jquery.min.map"
29
- puts `curl -o vendor/assets/javascripts/jquery.min.map http://code.jquery.com/jquery.min.map`
30
-
31
- puts "Updating version.rb"
32
- version = false
33
- File.foreach('vendor/assets/javascripts/jquery.js') do |line|
34
- version = line.match(/jQuery JavaScript Library v([\S]+)/)
35
- version = version && version[1]
36
- break if version
37
- end
38
-
39
- version_path = 'lib/jquery/rails/version.rb'
40
- lines = IO.readlines(version_path).map do |line|
41
- line.gsub(/JQUERY_VERSION = "([\d\.]+)"/, "JQUERY_VERSION = \"#{version}\"")
42
- end
43
- File.open(version_path, 'w') do |file|
44
- file.puts lines
25
+ def download_jquery(filename, version)
26
+ suffix = "-#{version}"
27
+
28
+ puts "Downloading #{filename}.js"
29
+ puts `curl -o vendor/assets/javascripts/#{filename}.js https://code.jquery.com/jquery#{suffix}.js`
30
+ puts "Downloading #{filename}.min.js"
31
+ puts `curl -o vendor/assets/javascripts/#{filename}.min.js https://code.jquery.com/jquery#{suffix}.min.js`
32
+ puts "Downloading #{filename}.min.map"
33
+ puts `curl -o vendor/assets/javascripts/#{filename}.min.map https://code.jquery.com/jquery#{suffix}.min.map`
45
34
  end
46
35
 
36
+ download_jquery('jquery', Jquery::Rails::JQUERY_VERSION)
47
37
  puts "\e[32mDone!\e[0m"
48
38
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  | Gem | jQuery | jQuery UJS | jQuery UI |
4
4
  |--------|--------|------------| ----------|
5
+ | 3.1.5 | 1.12.4 | 1.0.4 | - |
5
6
  | 3.1.4 | 1.11.1 | 1.0.4 | - |
6
7
  | 3.1.3 | 1.11.1 | 1.0.4 | - |
7
8
  | 3.1.2 | 1.11.1 | 1.0.1 | - |
@@ -1,7 +1,7 @@
1
1
  module Jquery
2
2
  module Rails
3
- VERSION = "3.1.4"
4
- JQUERY_VERSION = "1.11.1"
3
+ VERSION = "3.1.5"
4
+ JQUERY_VERSION = "1.12.4"
5
5
  JQUERY_UJS_VERSION = "1.0.4"
6
6
  end
7
7
  end
@@ -1,27 +1,27 @@
1
1
  /*!
2
- * jQuery JavaScript Library v1.11.1
2
+ * jQuery JavaScript Library v1.12.4
3
3
  * http://jquery.com/
4
4
  *
5
5
  * Includes Sizzle.js
6
6
  * http://sizzlejs.com/
7
7
  *
8
- * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
8
+ * Copyright jQuery Foundation and other contributors
9
9
  * Released under the MIT license
10
10
  * http://jquery.org/license
11
11
  *
12
- * Date: 2014-05-01T17:42Z
12
+ * Date: 2016-05-20T17:17Z
13
13
  */
14
14
 
15
15
  (function( global, factory ) {
16
16
 
17
17
  if ( typeof module === "object" && typeof module.exports === "object" ) {
18
- // For CommonJS and CommonJS-like environments where a proper window is present,
19
- // execute the factory and get jQuery
20
- // For environments that do not inherently posses a window with a document
21
- // (such as Node.js), expose a jQuery-making factory as module.exports
22
- // This accentuates the need for the creation of a real window
18
+ // For CommonJS and CommonJS-like environments where a proper `window`
19
+ // is present, execute the factory and get jQuery.
20
+ // For environments that do not have a `window` with a `document`
21
+ // (such as Node.js), expose a factory as module.exports.
22
+ // This accentuates the need for the creation of a real `window`.
23
23
  // e.g. var jQuery = require("jquery")(window);
24
- // See ticket #14549 for more info
24
+ // See ticket #14549 for more info.
25
25
  module.exports = global.document ?
26
26
  factory( global, true ) :
27
27
  function( w ) {
@@ -37,14 +37,15 @@
37
37
  // Pass this if window is not defined yet
38
38
  }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
39
39
 
40
- // Can't do this because several apps including ASP.NET trace
40
+ // Support: Firefox 18+
41
+ // Can't be in strict mode, several libs including ASP.NET trace
41
42
  // the stack via arguments.caller.callee and Firefox dies if
42
43
  // you try to trace through "use strict" call chains. (#13335)
43
- // Support: Firefox 18+
44
- //
45
-
44
+ //"use strict";
46
45
  var deletedIds = [];
47
46
 
47
+ var document = window.document;
48
+
48
49
  var slice = deletedIds.slice;
49
50
 
50
51
  var concat = deletedIds.concat;
@@ -64,10 +65,11 @@ var support = {};
64
65
 
65
66
 
66
67
  var
67
- version = "1.11.1",
68
+ version = "1.12.4",
68
69
 
69
70
  // Define a local copy of jQuery
70
71
  jQuery = function( selector, context ) {
72
+
71
73
  // The jQuery object is actually just the init constructor 'enhanced'
72
74
  // Need init if jQuery is called (just allow error to be thrown if not included)
73
75
  return new jQuery.fn.init( selector, context );
@@ -87,6 +89,7 @@ var
87
89
  };
88
90
 
89
91
  jQuery.fn = jQuery.prototype = {
92
+
90
93
  // The current version of jQuery being used
91
94
  jquery: version,
92
95
 
@@ -130,16 +133,14 @@ jQuery.fn = jQuery.prototype = {
130
133
  },
131
134
 
132
135
  // Execute a callback for every element in the matched set.
133
- // (You can seed the arguments with an array of args, but this is
134
- // only used internally.)
135
- each: function( callback, args ) {
136
- return jQuery.each( this, callback, args );
136
+ each: function( callback ) {
137
+ return jQuery.each( this, callback );
137
138
  },
138
139
 
139
140
  map: function( callback ) {
140
- return this.pushStack( jQuery.map(this, function( elem, i ) {
141
+ return this.pushStack( jQuery.map( this, function( elem, i ) {
141
142
  return callback.call( elem, i, elem );
142
- }));
143
+ } ) );
143
144
  },
144
145
 
145
146
  slice: function() {
@@ -157,11 +158,11 @@ jQuery.fn = jQuery.prototype = {
157
158
  eq: function( i ) {
158
159
  var len = this.length,
159
160
  j = +i + ( i < 0 ? len : 0 );
160
- return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
161
+ return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
161
162
  },
162
163
 
163
164
  end: function() {
164
- return this.prevObject || this.constructor(null);
165
+ return this.prevObject || this.constructor();
165
166
  },
166
167
 
167
168
  // For internal use only.
@@ -173,7 +174,7 @@ jQuery.fn = jQuery.prototype = {
173
174
 
174
175
  jQuery.extend = jQuery.fn.extend = function() {
175
176
  var src, copyIsArray, copy, name, options, clone,
176
- target = arguments[0] || {},
177
+ target = arguments[ 0 ] || {},
177
178
  i = 1,
178
179
  length = arguments.length,
179
180
  deep = false;
@@ -188,7 +189,7 @@ jQuery.extend = jQuery.fn.extend = function() {
188
189
  }
189
190
 
190
191
  // Handle case when target is a string or something (possible in deep copy)
191
- if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
192
+ if ( typeof target !== "object" && !jQuery.isFunction( target ) ) {
192
193
  target = {};
193
194
  }
194
195
 
@@ -199,8 +200,10 @@ jQuery.extend = jQuery.fn.extend = function() {
199
200
  }
200
201
 
201
202
  for ( ; i < length; i++ ) {
203
+
202
204
  // Only deal with non-null/undefined values
203
- if ( (options = arguments[ i ]) != null ) {
205
+ if ( ( options = arguments[ i ] ) != null ) {
206
+
204
207
  // Extend the base object
205
208
  for ( name in options ) {
206
209
  src = target[ name ];
@@ -212,13 +215,15 @@ jQuery.extend = jQuery.fn.extend = function() {
212
215
  }
213
216
 
214
217
  // Recurse if we're merging plain objects or arrays
215
- if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
218
+ if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
219
+ ( copyIsArray = jQuery.isArray( copy ) ) ) ) {
220
+
216
221
  if ( copyIsArray ) {
217
222
  copyIsArray = false;
218
- clone = src && jQuery.isArray(src) ? src : [];
223
+ clone = src && jQuery.isArray( src ) ? src : [];
219
224
 
220
225
  } else {
221
- clone = src && jQuery.isPlainObject(src) ? src : {};
226
+ clone = src && jQuery.isPlainObject( src ) ? src : {};
222
227
  }
223
228
 
224
229
  // Never move original objects, clone them
@@ -236,7 +241,8 @@ jQuery.extend = jQuery.fn.extend = function() {
236
241
  return target;
237
242
  };
238
243
 
239
- jQuery.extend({
244
+ jQuery.extend( {
245
+
240
246
  // Unique for each copy of jQuery on the page
241
247
  expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
242
248
 
@@ -253,11 +259,11 @@ jQuery.extend({
253
259
  // Since version 1.3, DOM methods and functions like alert
254
260
  // aren't supported. They return false on IE (#2968).
255
261
  isFunction: function( obj ) {
256
- return jQuery.type(obj) === "function";
262
+ return jQuery.type( obj ) === "function";
257
263
  },
258
264
 
259
265
  isArray: Array.isArray || function( obj ) {
260
- return jQuery.type(obj) === "array";
266
+ return jQuery.type( obj ) === "array";
261
267
  },
262
268
 
263
269
  isWindow: function( obj ) {
@@ -266,10 +272,13 @@ jQuery.extend({
266
272
  },
267
273
 
268
274
  isNumeric: function( obj ) {
275
+
269
276
  // parseFloat NaNs numeric-cast false positives (null|true|false|"")
270
277
  // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
271
278
  // subtraction forces infinities to NaN
272
- return !jQuery.isArray( obj ) && obj - parseFloat( obj ) >= 0;
279
+ // adding 1 corrects loss of precision from parseFloat (#15100)
280
+ var realStringObj = obj && obj.toString();
281
+ return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0;
273
282
  },
274
283
 
275
284
  isEmptyObject: function( obj ) {
@@ -286,25 +295,27 @@ jQuery.extend({
286
295
  // Must be an Object.
287
296
  // Because of IE, we also have to check the presence of the constructor property.
288
297
  // Make sure that DOM nodes and window objects don't pass through, as well
289
- if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
298
+ if ( !obj || jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
290
299
  return false;
291
300
  }
292
301
 
293
302
  try {
303
+
294
304
  // Not own constructor property must be Object
295
305
  if ( obj.constructor &&
296
- !hasOwn.call(obj, "constructor") &&
297
- !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
306
+ !hasOwn.call( obj, "constructor" ) &&
307
+ !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
298
308
  return false;
299
309
  }
300
310
  } catch ( e ) {
311
+
301
312
  // IE8,9 Will throw exceptions on certain host objects #9897
302
313
  return false;
303
314
  }
304
315
 
305
316
  // Support: IE<9
306
317
  // Handle iteration over inherited properties before own properties.
307
- if ( support.ownLast ) {
318
+ if ( !support.ownFirst ) {
308
319
  for ( key in obj ) {
309
320
  return hasOwn.call( obj, key );
310
321
  }
@@ -322,20 +333,20 @@ jQuery.extend({
322
333
  return obj + "";
323
334
  }
324
335
  return typeof obj === "object" || typeof obj === "function" ?
325
- class2type[ toString.call(obj) ] || "object" :
336
+ class2type[ toString.call( obj ) ] || "object" :
326
337
  typeof obj;
327
338
  },
328
339
 
329
- // Evaluates a script in a global context
330
340
  // Workarounds based on findings by Jim Driscoll
331
341
  // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
332
342
  globalEval: function( data ) {
333
343
  if ( data && jQuery.trim( data ) ) {
344
+
334
345
  // We use execScript on Internet Explorer
335
346
  // We use an anonymous function so that context is window
336
347
  // rather than jQuery in Firefox
337
348
  ( window.execScript || function( data ) {
338
- window[ "eval" ].call( window, data );
349
+ window[ "eval" ].call( window, data ); // jscs:ignore requireDotNotation
339
350
  } )( data );
340
351
  }
341
352
  },
@@ -350,49 +361,20 @@ jQuery.extend({
350
361
  return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
351
362
  },
352
363
 
353
- // args is for internal usage only
354
- each: function( obj, callback, args ) {
355
- var value,
356
- i = 0,
357
- length = obj.length,
358
- isArray = isArraylike( obj );
359
-
360
- if ( args ) {
361
- if ( isArray ) {
362
- for ( ; i < length; i++ ) {
363
- value = callback.apply( obj[ i ], args );
364
-
365
- if ( value === false ) {
366
- break;
367
- }
368
- }
369
- } else {
370
- for ( i in obj ) {
371
- value = callback.apply( obj[ i ], args );
364
+ each: function( obj, callback ) {
365
+ var length, i = 0;
372
366
 
373
- if ( value === false ) {
374
- break;
375
- }
367
+ if ( isArrayLike( obj ) ) {
368
+ length = obj.length;
369
+ for ( ; i < length; i++ ) {
370
+ if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
371
+ break;
376
372
  }
377
373
  }
378
-
379
- // A special, fast, case for the most common use of each
380
374
  } else {
381
- if ( isArray ) {
382
- for ( ; i < length; i++ ) {
383
- value = callback.call( obj[ i ], i, obj[ i ] );
384
-
385
- if ( value === false ) {
386
- break;
387
- }
388
- }
389
- } else {
390
- for ( i in obj ) {
391
- value = callback.call( obj[ i ], i, obj[ i ] );
392
-
393
- if ( value === false ) {
394
- break;
395
- }
375
+ for ( i in obj ) {
376
+ if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
377
+ break;
396
378
  }
397
379
  }
398
380
  }
@@ -412,7 +394,7 @@ jQuery.extend({
412
394
  var ret = results || [];
413
395
 
414
396
  if ( arr != null ) {
415
- if ( isArraylike( Object(arr) ) ) {
397
+ if ( isArrayLike( Object( arr ) ) ) {
416
398
  jQuery.merge( ret,
417
399
  typeof arr === "string" ?
418
400
  [ arr ] : arr
@@ -437,6 +419,7 @@ jQuery.extend({
437
419
  i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
438
420
 
439
421
  for ( ; i < len; i++ ) {
422
+
440
423
  // Skip accessing in sparse arrays
441
424
  if ( i in arr && arr[ i ] === elem ) {
442
425
  return i;
@@ -459,7 +442,7 @@ jQuery.extend({
459
442
  // Support: IE<9
460
443
  // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
461
444
  if ( len !== len ) {
462
- while ( second[j] !== undefined ) {
445
+ while ( second[ j ] !== undefined ) {
463
446
  first[ i++ ] = second[ j++ ];
464
447
  }
465
448
  }
@@ -490,14 +473,13 @@ jQuery.extend({
490
473
 
491
474
  // arg is for internal usage only
492
475
  map: function( elems, callback, arg ) {
493
- var value,
476
+ var length, value,
494
477
  i = 0,
495
- length = elems.length,
496
- isArray = isArraylike( elems ),
497
478
  ret = [];
498
479
 
499
480
  // Go through the array, translating each of the items to their new values
500
- if ( isArray ) {
481
+ if ( isArrayLike( elems ) ) {
482
+ length = elems.length;
501
483
  for ( ; i < length; i++ ) {
502
484
  value = callback( elems[ i ], i, arg );
503
485
 
@@ -560,38 +542,50 @@ jQuery.extend({
560
542
  // jQuery.support is not used in Core but other projects attach their
561
543
  // properties to it so it needs to exist.
562
544
  support: support
563
- });
545
+ } );
546
+
547
+ // JSHint would error on this code due to the Symbol not being defined in ES5.
548
+ // Defining this global in .jshintrc would create a danger of using the global
549
+ // unguarded in another place, it seems safer to just disable JSHint for these
550
+ // three lines.
551
+ /* jshint ignore: start */
552
+ if ( typeof Symbol === "function" ) {
553
+ jQuery.fn[ Symbol.iterator ] = deletedIds[ Symbol.iterator ];
554
+ }
555
+ /* jshint ignore: end */
564
556
 
565
557
  // Populate the class2type map
566
- jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
558
+ jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
559
+ function( i, name ) {
567
560
  class2type[ "[object " + name + "]" ] = name.toLowerCase();
568
- });
561
+ } );
562
+
563
+ function isArrayLike( obj ) {
569
564
 
570
- function isArraylike( obj ) {
571
- var length = obj.length,
565
+ // Support: iOS 8.2 (not reproducible in simulator)
566
+ // `in` check used to prevent JIT error (gh-2145)
567
+ // hasOwn isn't used here due to false negatives
568
+ // regarding Nodelist length in IE
569
+ var length = !!obj && "length" in obj && obj.length,
572
570
  type = jQuery.type( obj );
573
571
 
574
572
  if ( type === "function" || jQuery.isWindow( obj ) ) {
575
573
  return false;
576
574
  }
577
575
 
578
- if ( obj.nodeType === 1 && length ) {
579
- return true;
580
- }
581
-
582
576
  return type === "array" || length === 0 ||
583
577
  typeof length === "number" && length > 0 && ( length - 1 ) in obj;
584
578
  }
585
579
  var Sizzle =
586
580
  /*!
587
- * Sizzle CSS Selector Engine v1.10.19
581
+ * Sizzle CSS Selector Engine v2.2.1
588
582
  * http://sizzlejs.com/
589
583
  *
590
- * Copyright 2013 jQuery Foundation, Inc. and other contributors
584
+ * Copyright jQuery Foundation and other contributors
591
585
  * Released under the MIT license
592
586
  * http://jquery.org/license
593
587
  *
594
- * Date: 2014-04-18
588
+ * Date: 2015-10-17
595
589
  */
596
590
  (function( window ) {
597
591
 
@@ -618,7 +612,7 @@ var i,
618
612
  contains,
619
613
 
620
614
  // Instance-specific data
621
- expando = "sizzle" + -(new Date()),
615
+ expando = "sizzle" + 1 * new Date(),
622
616
  preferredDoc = window.document,
623
617
  dirruns = 0,
624
618
  done = 0,
@@ -633,7 +627,6 @@ var i,
633
627
  },
634
628
 
635
629
  // General-purpose constants
636
- strundefined = typeof undefined,
637
630
  MAX_NEGATIVE = 1 << 31,
638
631
 
639
632
  // Instance methods
@@ -643,12 +636,13 @@ var i,
643
636
  push_native = arr.push,
644
637
  push = arr.push,
645
638
  slice = arr.slice,
646
- // Use a stripped-down indexOf if we can't use a native one
647
- indexOf = arr.indexOf || function( elem ) {
639
+ // Use a stripped-down indexOf as it's faster than native
640
+ // http://jsperf.com/thor-indexof-vs-for/5
641
+ indexOf = function( list, elem ) {
648
642
  var i = 0,
649
- len = this.length;
643
+ len = list.length;
650
644
  for ( ; i < len; i++ ) {
651
- if ( this[i] === elem ) {
645
+ if ( list[i] === elem ) {
652
646
  return i;
653
647
  }
654
648
  }
@@ -659,25 +653,21 @@ var i,
659
653
 
660
654
  // Regular expressions
661
655
 
662
- // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
656
+ // http://www.w3.org/TR/css3-selectors/#whitespace
663
657
  whitespace = "[\\x20\\t\\r\\n\\f]",
664
- // http://www.w3.org/TR/css3-syntax/#characters
665
- characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
666
658
 
667
- // Loosely modeled on CSS identifier characters
668
- // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
669
- // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
670
- identifier = characterEncoding.replace( "w", "w#" ),
659
+ // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
660
+ identifier = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
671
661
 
672
662
  // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
673
- attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace +
663
+ attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
674
664
  // Operator (capture 2)
675
665
  "*([*^$|!~]?=)" + whitespace +
676
666
  // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
677
667
  "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
678
668
  "*\\]",
679
669
 
680
- pseudos = ":(" + characterEncoding + ")(?:\\((" +
670
+ pseudos = ":(" + identifier + ")(?:\\((" +
681
671
  // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
682
672
  // 1. quoted (capture 3; capture 4 or capture 5)
683
673
  "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
@@ -688,6 +678,7 @@ var i,
688
678
  ")\\)|)",
689
679
 
690
680
  // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
681
+ rwhitespace = new RegExp( whitespace + "+", "g" ),
691
682
  rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
692
683
 
693
684
  rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
@@ -699,9 +690,9 @@ var i,
699
690
  ridentifier = new RegExp( "^" + identifier + "$" ),
700
691
 
701
692
  matchExpr = {
702
- "ID": new RegExp( "^#(" + characterEncoding + ")" ),
703
- "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
704
- "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
693
+ "ID": new RegExp( "^#(" + identifier + ")" ),
694
+ "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
695
+ "TAG": new RegExp( "^(" + identifier + "|[*])" ),
705
696
  "ATTR": new RegExp( "^" + attributes ),
706
697
  "PSEUDO": new RegExp( "^" + pseudos ),
707
698
  "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
@@ -739,6 +730,14 @@ var i,
739
730
  String.fromCharCode( high + 0x10000 ) :
740
731
  // Supplemental Plane codepoint (surrogate pair)
741
732
  String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
733
+ },
734
+
735
+ // Used for iframes
736
+ // See setDocument()
737
+ // Removing the function wrapper causes a "Permission Denied"
738
+ // error in IE
739
+ unloadHandler = function() {
740
+ setDocument();
742
741
  };
743
742
 
744
743
  // Optimize for push.apply( _, NodeList )
@@ -771,104 +770,129 @@ try {
771
770
  }
772
771
 
773
772
  function Sizzle( selector, context, results, seed ) {
774
- var match, elem, m, nodeType,
775
- // QSA vars
776
- i, groups, old, nid, newContext, newSelector;
773
+ var m, i, elem, nid, nidselect, match, groups, newSelector,
774
+ newContext = context && context.ownerDocument,
777
775
 
778
- if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
779
- setDocument( context );
780
- }
776
+ // nodeType defaults to 9, since context defaults to document
777
+ nodeType = context ? context.nodeType : 9;
781
778
 
782
- context = context || document;
783
779
  results = results || [];
784
780
 
785
- if ( !selector || typeof selector !== "string" ) {
781
+ // Return early from calls with invalid selector or context
782
+ if ( typeof selector !== "string" || !selector ||
783
+ nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
784
+
786
785
  return results;
787
786
  }
788
787
 
789
- if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
790
- return [];
791
- }
788
+ // Try to shortcut find operations (as opposed to filters) in HTML documents
789
+ if ( !seed ) {
792
790
 
793
- if ( documentIsHTML && !seed ) {
791
+ if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
792
+ setDocument( context );
793
+ }
794
+ context = context || document;
794
795
 
795
- // Shortcuts
796
- if ( (match = rquickExpr.exec( selector )) ) {
797
- // Speed-up: Sizzle("#ID")
798
- if ( (m = match[1]) ) {
799
- if ( nodeType === 9 ) {
800
- elem = context.getElementById( m );
801
- // Check parentNode to catch when Blackberry 4.6 returns
802
- // nodes that are no longer in the document (jQuery #6963)
803
- if ( elem && elem.parentNode ) {
804
- // Handle the case where IE, Opera, and Webkit return items
805
- // by name instead of ID
806
- if ( elem.id === m ) {
807
- results.push( elem );
796
+ if ( documentIsHTML ) {
797
+
798
+ // If the selector is sufficiently simple, try using a "get*By*" DOM method
799
+ // (excepting DocumentFragment context, where the methods don't exist)
800
+ if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
801
+
802
+ // ID selector
803
+ if ( (m = match[1]) ) {
804
+
805
+ // Document context
806
+ if ( nodeType === 9 ) {
807
+ if ( (elem = context.getElementById( m )) ) {
808
+
809
+ // Support: IE, Opera, Webkit
810
+ // TODO: identify versions
811
+ // getElementById can match elements by name instead of ID
812
+ if ( elem.id === m ) {
813
+ results.push( elem );
814
+ return results;
815
+ }
816
+ } else {
808
817
  return results;
809
818
  }
819
+
820
+ // Element context
810
821
  } else {
811
- return results;
812
- }
813
- } else {
814
- // Context is not a document
815
- if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
816
- contains( context, elem ) && elem.id === m ) {
817
- results.push( elem );
818
- return results;
822
+
823
+ // Support: IE, Opera, Webkit
824
+ // TODO: identify versions
825
+ // getElementById can match elements by name instead of ID
826
+ if ( newContext && (elem = newContext.getElementById( m )) &&
827
+ contains( context, elem ) &&
828
+ elem.id === m ) {
829
+
830
+ results.push( elem );
831
+ return results;
832
+ }
819
833
  }
820
- }
821
834
 
822
- // Speed-up: Sizzle("TAG")
823
- } else if ( match[2] ) {
824
- push.apply( results, context.getElementsByTagName( selector ) );
825
- return results;
835
+ // Type selector
836
+ } else if ( match[2] ) {
837
+ push.apply( results, context.getElementsByTagName( selector ) );
838
+ return results;
826
839
 
827
- // Speed-up: Sizzle(".CLASS")
828
- } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
829
- push.apply( results, context.getElementsByClassName( m ) );
830
- return results;
840
+ // Class selector
841
+ } else if ( (m = match[3]) && support.getElementsByClassName &&
842
+ context.getElementsByClassName ) {
843
+
844
+ push.apply( results, context.getElementsByClassName( m ) );
845
+ return results;
846
+ }
831
847
  }
832
- }
833
848
 
834
- // QSA path
835
- if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
836
- nid = old = expando;
837
- newContext = context;
838
- newSelector = nodeType === 9 && selector;
849
+ // Take advantage of querySelectorAll
850
+ if ( support.qsa &&
851
+ !compilerCache[ selector + " " ] &&
852
+ (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
839
853
 
840
- // qSA works strangely on Element-rooted queries
841
- // We can work around this by specifying an extra ID on the root
842
- // and working up from there (Thanks to Andrew Dupont for the technique)
843
- // IE 8 doesn't work on object elements
844
- if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
845
- groups = tokenize( selector );
854
+ if ( nodeType !== 1 ) {
855
+ newContext = context;
856
+ newSelector = selector;
846
857
 
847
- if ( (old = context.getAttribute("id")) ) {
848
- nid = old.replace( rescape, "\\$&" );
849
- } else {
850
- context.setAttribute( "id", nid );
851
- }
852
- nid = "[id='" + nid + "'] ";
858
+ // qSA looks outside Element context, which is not what we want
859
+ // Thanks to Andrew Dupont for this workaround technique
860
+ // Support: IE <=8
861
+ // Exclude object elements
862
+ } else if ( context.nodeName.toLowerCase() !== "object" ) {
853
863
 
854
- i = groups.length;
855
- while ( i-- ) {
856
- groups[i] = nid + toSelector( groups[i] );
864
+ // Capture the context ID, setting it first if necessary
865
+ if ( (nid = context.getAttribute( "id" )) ) {
866
+ nid = nid.replace( rescape, "\\$&" );
867
+ } else {
868
+ context.setAttribute( "id", (nid = expando) );
869
+ }
870
+
871
+ // Prefix every selector in the list
872
+ groups = tokenize( selector );
873
+ i = groups.length;
874
+ nidselect = ridentifier.test( nid ) ? "#" + nid : "[id='" + nid + "']";
875
+ while ( i-- ) {
876
+ groups[i] = nidselect + " " + toSelector( groups[i] );
877
+ }
878
+ newSelector = groups.join( "," );
879
+
880
+ // Expand context for sibling selectors
881
+ newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
882
+ context;
857
883
  }
858
- newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
859
- newSelector = groups.join(",");
860
- }
861
884
 
862
- if ( newSelector ) {
863
- try {
864
- push.apply( results,
865
- newContext.querySelectorAll( newSelector )
866
- );
867
- return results;
868
- } catch(qsaError) {
869
- } finally {
870
- if ( !old ) {
871
- context.removeAttribute("id");
885
+ if ( newSelector ) {
886
+ try {
887
+ push.apply( results,
888
+ newContext.querySelectorAll( newSelector )
889
+ );
890
+ return results;
891
+ } catch ( qsaError ) {
892
+ } finally {
893
+ if ( nid === expando ) {
894
+ context.removeAttribute( "id" );
895
+ }
872
896
  }
873
897
  }
874
898
  }
@@ -881,7 +905,7 @@ function Sizzle( selector, context, results, seed ) {
881
905
 
882
906
  /**
883
907
  * Create key-value caches of limited size
884
- * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
908
+ * @returns {function(string, object)} Returns the Object data after storing it on itself with
885
909
  * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
886
910
  * deleting the oldest entry
887
911
  */
@@ -936,7 +960,7 @@ function assert( fn ) {
936
960
  */
937
961
  function addHandle( attrs, handler ) {
938
962
  var arr = attrs.split("|"),
939
- i = attrs.length;
963
+ i = arr.length;
940
964
 
941
965
  while ( i-- ) {
942
966
  Expr.attrHandle[ arr[i] ] = handler;
@@ -1022,7 +1046,7 @@ function createPositionalPseudo( fn ) {
1022
1046
  * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1023
1047
  */
1024
1048
  function testContext( context ) {
1025
- return context && typeof context.getElementsByTagName !== strundefined && context;
1049
+ return context && typeof context.getElementsByTagName !== "undefined" && context;
1026
1050
  }
1027
1051
 
1028
1052
  // Expose support vars for convenience
@@ -1046,36 +1070,29 @@ isXML = Sizzle.isXML = function( elem ) {
1046
1070
  * @returns {Object} Returns the current document
1047
1071
  */
1048
1072
  setDocument = Sizzle.setDocument = function( node ) {
1049
- var hasCompare,
1050
- doc = node ? node.ownerDocument || node : preferredDoc,
1051
- parent = doc.defaultView;
1073
+ var hasCompare, parent,
1074
+ doc = node ? node.ownerDocument || node : preferredDoc;
1052
1075
 
1053
- // If no document and documentElement is available, return
1076
+ // Return early if doc is invalid or already selected
1054
1077
  if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
1055
1078
  return document;
1056
1079
  }
1057
1080
 
1058
- // Set our document
1081
+ // Update global variables
1059
1082
  document = doc;
1060
- docElem = doc.documentElement;
1061
-
1062
- // Support tests
1063
- documentIsHTML = !isXML( doc );
1083
+ docElem = document.documentElement;
1084
+ documentIsHTML = !isXML( document );
1064
1085
 
1065
- // Support: IE>8
1066
- // If iframe document is assigned to "document" variable and if iframe has been reloaded,
1067
- // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
1068
- // IE6-8 do not support the defaultView property so parent will be undefined
1069
- if ( parent && parent !== parent.top ) {
1070
- // IE11 does not have attachEvent, so all must suffer
1086
+ // Support: IE 9-11, Edge
1087
+ // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
1088
+ if ( (parent = document.defaultView) && parent.top !== parent ) {
1089
+ // Support: IE 11
1071
1090
  if ( parent.addEventListener ) {
1072
- parent.addEventListener( "unload", function() {
1073
- setDocument();
1074
- }, false );
1091
+ parent.addEventListener( "unload", unloadHandler, false );
1092
+
1093
+ // Support: IE 9 - 10 only
1075
1094
  } else if ( parent.attachEvent ) {
1076
- parent.attachEvent( "onunload", function() {
1077
- setDocument();
1078
- });
1095
+ parent.attachEvent( "onunload", unloadHandler );
1079
1096
  }
1080
1097
  }
1081
1098
 
@@ -1083,7 +1100,8 @@ setDocument = Sizzle.setDocument = function( node ) {
1083
1100
  ---------------------------------------------------------------------- */
1084
1101
 
1085
1102
  // Support: IE<8
1086
- // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
1103
+ // Verify that getAttribute really returns attributes and not properties
1104
+ // (excepting IE8 booleans)
1087
1105
  support.attributes = assert(function( div ) {
1088
1106
  div.className = "i";
1089
1107
  return !div.getAttribute("className");
@@ -1094,21 +1112,12 @@ setDocument = Sizzle.setDocument = function( node ) {
1094
1112
 
1095
1113
  // Check if getElementsByTagName("*") returns only elements
1096
1114
  support.getElementsByTagName = assert(function( div ) {
1097
- div.appendChild( doc.createComment("") );
1115
+ div.appendChild( document.createComment("") );
1098
1116
  return !div.getElementsByTagName("*").length;
1099
1117
  });
1100
1118
 
1101
- // Check if getElementsByClassName can be trusted
1102
- support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
1103
- div.innerHTML = "<div class='a'></div><div class='a i'></div>";
1104
-
1105
- // Support: Safari<4
1106
- // Catch class over-caching
1107
- div.firstChild.className = "i";
1108
- // Support: Opera<10
1109
- // Catch gEBCN failure to find non-leading classes
1110
- return div.getElementsByClassName("i").length === 2;
1111
- });
1119
+ // Support: IE<9
1120
+ support.getElementsByClassName = rnative.test( document.getElementsByClassName );
1112
1121
 
1113
1122
  // Support: IE<10
1114
1123
  // Check if getElementById returns elements by name
@@ -1116,17 +1125,15 @@ setDocument = Sizzle.setDocument = function( node ) {
1116
1125
  // so use a roundabout getElementsByName test
1117
1126
  support.getById = assert(function( div ) {
1118
1127
  docElem.appendChild( div ).id = expando;
1119
- return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
1128
+ return !document.getElementsByName || !document.getElementsByName( expando ).length;
1120
1129
  });
1121
1130
 
1122
1131
  // ID find and filter
1123
1132
  if ( support.getById ) {
1124
1133
  Expr.find["ID"] = function( id, context ) {
1125
- if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
1134
+ if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
1126
1135
  var m = context.getElementById( id );
1127
- // Check parentNode to catch when Blackberry 4.6 returns
1128
- // nodes that are no longer in the document #6963
1129
- return m && m.parentNode ? [ m ] : [];
1136
+ return m ? [ m ] : [];
1130
1137
  }
1131
1138
  };
1132
1139
  Expr.filter["ID"] = function( id ) {
@@ -1143,7 +1150,8 @@ setDocument = Sizzle.setDocument = function( node ) {
1143
1150
  Expr.filter["ID"] = function( id ) {
1144
1151
  var attrId = id.replace( runescape, funescape );
1145
1152
  return function( elem ) {
1146
- var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
1153
+ var node = typeof elem.getAttributeNode !== "undefined" &&
1154
+ elem.getAttributeNode("id");
1147
1155
  return node && node.value === attrId;
1148
1156
  };
1149
1157
  };
@@ -1152,14 +1160,20 @@ setDocument = Sizzle.setDocument = function( node ) {
1152
1160
  // Tag
1153
1161
  Expr.find["TAG"] = support.getElementsByTagName ?
1154
1162
  function( tag, context ) {
1155
- if ( typeof context.getElementsByTagName !== strundefined ) {
1163
+ if ( typeof context.getElementsByTagName !== "undefined" ) {
1156
1164
  return context.getElementsByTagName( tag );
1165
+
1166
+ // DocumentFragment nodes don't have gEBTN
1167
+ } else if ( support.qsa ) {
1168
+ return context.querySelectorAll( tag );
1157
1169
  }
1158
1170
  } :
1171
+
1159
1172
  function( tag, context ) {
1160
1173
  var elem,
1161
1174
  tmp = [],
1162
1175
  i = 0,
1176
+ // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
1163
1177
  results = context.getElementsByTagName( tag );
1164
1178
 
1165
1179
  // Filter out possible comments
@@ -1177,7 +1191,7 @@ setDocument = Sizzle.setDocument = function( node ) {
1177
1191
 
1178
1192
  // Class
1179
1193
  Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
1180
- if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
1194
+ if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
1181
1195
  return context.getElementsByClassName( className );
1182
1196
  }
1183
1197
  };
@@ -1197,7 +1211,7 @@ setDocument = Sizzle.setDocument = function( node ) {
1197
1211
  // See http://bugs.jquery.com/ticket/13378
1198
1212
  rbuggyQSA = [];
1199
1213
 
1200
- if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
1214
+ if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
1201
1215
  // Build QSA regex
1202
1216
  // Regex strategy adopted from Diego Perini
1203
1217
  assert(function( div ) {
@@ -1206,13 +1220,15 @@ setDocument = Sizzle.setDocument = function( node ) {
1206
1220
  // setting a boolean content attribute,
1207
1221
  // since its presence should be enough
1208
1222
  // http://bugs.jquery.com/ticket/12359
1209
- div.innerHTML = "<select msallowclip=''><option selected=''></option></select>";
1223
+ docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" +
1224
+ "<select id='" + expando + "-\r\\' msallowcapture=''>" +
1225
+ "<option selected=''></option></select>";
1210
1226
 
1211
1227
  // Support: IE8, Opera 11-12.16
1212
1228
  // Nothing should be selected when empty strings follow ^= or $= or *=
1213
1229
  // The test attribute must be unknown in Opera but "safe" for WinRT
1214
1230
  // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
1215
- if ( div.querySelectorAll("[msallowclip^='']").length ) {
1231
+ if ( div.querySelectorAll("[msallowcapture^='']").length ) {
1216
1232
  rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
1217
1233
  }
1218
1234
 
@@ -1222,18 +1238,30 @@ setDocument = Sizzle.setDocument = function( node ) {
1222
1238
  rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
1223
1239
  }
1224
1240
 
1241
+ // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
1242
+ if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
1243
+ rbuggyQSA.push("~=");
1244
+ }
1245
+
1225
1246
  // Webkit/Opera - :checked should return selected option elements
1226
1247
  // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1227
1248
  // IE8 throws error here and will not see later tests
1228
1249
  if ( !div.querySelectorAll(":checked").length ) {
1229
1250
  rbuggyQSA.push(":checked");
1230
1251
  }
1252
+
1253
+ // Support: Safari 8+, iOS 8+
1254
+ // https://bugs.webkit.org/show_bug.cgi?id=136851
1255
+ // In-page `selector#id sibing-combinator selector` fails
1256
+ if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) {
1257
+ rbuggyQSA.push(".#.+[+~]");
1258
+ }
1231
1259
  });
1232
1260
 
1233
1261
  assert(function( div ) {
1234
1262
  // Support: Windows 8 Native Apps
1235
1263
  // The type and name attributes are restricted during .innerHTML assignment
1236
- var input = doc.createElement("input");
1264
+ var input = document.createElement("input");
1237
1265
  input.setAttribute( "type", "hidden" );
1238
1266
  div.appendChild( input ).setAttribute( "name", "D" );
1239
1267
 
@@ -1281,7 +1309,7 @@ setDocument = Sizzle.setDocument = function( node ) {
1281
1309
  hasCompare = rnative.test( docElem.compareDocumentPosition );
1282
1310
 
1283
1311
  // Element contains another
1284
- // Purposefully does not implement inclusive descendent
1312
+ // Purposefully self-exclusive
1285
1313
  // As in, an element does not contain itself
1286
1314
  contains = hasCompare || rnative.test( docElem.contains ) ?
1287
1315
  function( a, b ) {
@@ -1335,16 +1363,16 @@ setDocument = Sizzle.setDocument = function( node ) {
1335
1363
  (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
1336
1364
 
1337
1365
  // Choose the first element that is related to our preferred document
1338
- if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
1366
+ if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
1339
1367
  return -1;
1340
1368
  }
1341
- if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
1369
+ if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
1342
1370
  return 1;
1343
1371
  }
1344
1372
 
1345
1373
  // Maintain original order
1346
1374
  return sortInput ?
1347
- ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
1375
+ ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1348
1376
  0;
1349
1377
  }
1350
1378
 
@@ -1366,12 +1394,12 @@ setDocument = Sizzle.setDocument = function( node ) {
1366
1394
 
1367
1395
  // Parentless nodes are either documents or disconnected
1368
1396
  if ( !aup || !bup ) {
1369
- return a === doc ? -1 :
1370
- b === doc ? 1 :
1397
+ return a === document ? -1 :
1398
+ b === document ? 1 :
1371
1399
  aup ? -1 :
1372
1400
  bup ? 1 :
1373
1401
  sortInput ?
1374
- ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
1402
+ ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1375
1403
  0;
1376
1404
 
1377
1405
  // If the nodes are siblings, we can do a quick check
@@ -1404,7 +1432,7 @@ setDocument = Sizzle.setDocument = function( node ) {
1404
1432
  0;
1405
1433
  };
1406
1434
 
1407
- return doc;
1435
+ return document;
1408
1436
  };
1409
1437
 
1410
1438
  Sizzle.matches = function( expr, elements ) {
@@ -1421,6 +1449,7 @@ Sizzle.matchesSelector = function( elem, expr ) {
1421
1449
  expr = expr.replace( rattributeQuotes, "='$1']" );
1422
1450
 
1423
1451
  if ( support.matchesSelector && documentIsHTML &&
1452
+ !compilerCache[ expr + " " ] &&
1424
1453
  ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
1425
1454
  ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
1426
1455
 
@@ -1434,7 +1463,7 @@ Sizzle.matchesSelector = function( elem, expr ) {
1434
1463
  elem.document && elem.document.nodeType !== 11 ) {
1435
1464
  return ret;
1436
1465
  }
1437
- } catch(e) {}
1466
+ } catch (e) {}
1438
1467
  }
1439
1468
 
1440
1469
  return Sizzle( expr, document, null, [ elem ] ).length > 0;
@@ -1653,7 +1682,7 @@ Expr = Sizzle.selectors = {
1653
1682
  return pattern ||
1654
1683
  (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
1655
1684
  classCache( className, function( elem ) {
1656
- return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
1685
+ return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
1657
1686
  });
1658
1687
  },
1659
1688
 
@@ -1675,7 +1704,7 @@ Expr = Sizzle.selectors = {
1675
1704
  operator === "^=" ? check && result.indexOf( check ) === 0 :
1676
1705
  operator === "*=" ? check && result.indexOf( check ) > -1 :
1677
1706
  operator === "$=" ? check && result.slice( -check.length ) === check :
1678
- operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
1707
+ operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
1679
1708
  operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
1680
1709
  false;
1681
1710
  };
@@ -1694,11 +1723,12 @@ Expr = Sizzle.selectors = {
1694
1723
  } :
1695
1724
 
1696
1725
  function( elem, context, xml ) {
1697
- var cache, outerCache, node, diff, nodeIndex, start,
1726
+ var cache, uniqueCache, outerCache, node, nodeIndex, start,
1698
1727
  dir = simple !== forward ? "nextSibling" : "previousSibling",
1699
1728
  parent = elem.parentNode,
1700
1729
  name = ofType && elem.nodeName.toLowerCase(),
1701
- useCache = !xml && !ofType;
1730
+ useCache = !xml && !ofType,
1731
+ diff = false;
1702
1732
 
1703
1733
  if ( parent ) {
1704
1734
 
@@ -1707,7 +1737,10 @@ Expr = Sizzle.selectors = {
1707
1737
  while ( dir ) {
1708
1738
  node = elem;
1709
1739
  while ( (node = node[ dir ]) ) {
1710
- if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
1740
+ if ( ofType ?
1741
+ node.nodeName.toLowerCase() === name :
1742
+ node.nodeType === 1 ) {
1743
+
1711
1744
  return false;
1712
1745
  }
1713
1746
  }
@@ -1721,11 +1754,21 @@ Expr = Sizzle.selectors = {
1721
1754
 
1722
1755
  // non-xml :nth-child(...) stores cache data on `parent`
1723
1756
  if ( forward && useCache ) {
1757
+
1724
1758
  // Seek `elem` from a previously-cached index
1725
- outerCache = parent[ expando ] || (parent[ expando ] = {});
1726
- cache = outerCache[ type ] || [];
1727
- nodeIndex = cache[0] === dirruns && cache[1];
1728
- diff = cache[0] === dirruns && cache[2];
1759
+
1760
+ // ...in a gzip-friendly way
1761
+ node = parent;
1762
+ outerCache = node[ expando ] || (node[ expando ] = {});
1763
+
1764
+ // Support: IE <9 only
1765
+ // Defend against cloned attroperties (jQuery gh-1709)
1766
+ uniqueCache = outerCache[ node.uniqueID ] ||
1767
+ (outerCache[ node.uniqueID ] = {});
1768
+
1769
+ cache = uniqueCache[ type ] || [];
1770
+ nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1771
+ diff = nodeIndex && cache[ 2 ];
1729
1772
  node = nodeIndex && parent.childNodes[ nodeIndex ];
1730
1773
 
1731
1774
  while ( (node = ++nodeIndex && node && node[ dir ] ||
@@ -1735,29 +1778,55 @@ Expr = Sizzle.selectors = {
1735
1778
 
1736
1779
  // When found, cache indexes on `parent` and break
1737
1780
  if ( node.nodeType === 1 && ++diff && node === elem ) {
1738
- outerCache[ type ] = [ dirruns, nodeIndex, diff ];
1781
+ uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
1739
1782
  break;
1740
1783
  }
1741
1784
  }
1742
1785
 
1743
- // Use previously-cached element index if available
1744
- } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
1745
- diff = cache[1];
1746
-
1747
- // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
1748
1786
  } else {
1749
- // Use the same loop as above to seek `elem` from the start
1750
- while ( (node = ++nodeIndex && node && node[ dir ] ||
1751
- (diff = nodeIndex = 0) || start.pop()) ) {
1787
+ // Use previously-cached element index if available
1788
+ if ( useCache ) {
1789
+ // ...in a gzip-friendly way
1790
+ node = elem;
1791
+ outerCache = node[ expando ] || (node[ expando ] = {});
1752
1792
 
1753
- if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
1754
- // Cache the index of each encountered element
1755
- if ( useCache ) {
1756
- (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
1757
- }
1793
+ // Support: IE <9 only
1794
+ // Defend against cloned attroperties (jQuery gh-1709)
1795
+ uniqueCache = outerCache[ node.uniqueID ] ||
1796
+ (outerCache[ node.uniqueID ] = {});
1797
+
1798
+ cache = uniqueCache[ type ] || [];
1799
+ nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1800
+ diff = nodeIndex;
1801
+ }
1758
1802
 
1759
- if ( node === elem ) {
1760
- break;
1803
+ // xml :nth-child(...)
1804
+ // or :nth-last-child(...) or :nth(-last)?-of-type(...)
1805
+ if ( diff === false ) {
1806
+ // Use the same loop as above to seek `elem` from the start
1807
+ while ( (node = ++nodeIndex && node && node[ dir ] ||
1808
+ (diff = nodeIndex = 0) || start.pop()) ) {
1809
+
1810
+ if ( ( ofType ?
1811
+ node.nodeName.toLowerCase() === name :
1812
+ node.nodeType === 1 ) &&
1813
+ ++diff ) {
1814
+
1815
+ // Cache the index of each encountered element
1816
+ if ( useCache ) {
1817
+ outerCache = node[ expando ] || (node[ expando ] = {});
1818
+
1819
+ // Support: IE <9 only
1820
+ // Defend against cloned attroperties (jQuery gh-1709)
1821
+ uniqueCache = outerCache[ node.uniqueID ] ||
1822
+ (outerCache[ node.uniqueID ] = {});
1823
+
1824
+ uniqueCache[ type ] = [ dirruns, diff ];
1825
+ }
1826
+
1827
+ if ( node === elem ) {
1828
+ break;
1829
+ }
1761
1830
  }
1762
1831
  }
1763
1832
  }
@@ -1795,7 +1864,7 @@ Expr = Sizzle.selectors = {
1795
1864
  matched = fn( seed, argument ),
1796
1865
  i = matched.length;
1797
1866
  while ( i-- ) {
1798
- idx = indexOf.call( seed, matched[i] );
1867
+ idx = indexOf( seed, matched[i] );
1799
1868
  seed[ idx ] = !( matches[ idx ] = matched[i] );
1800
1869
  }
1801
1870
  }) :
@@ -1834,6 +1903,8 @@ Expr = Sizzle.selectors = {
1834
1903
  function( elem, context, xml ) {
1835
1904
  input[0] = elem;
1836
1905
  matcher( input, null, xml, results );
1906
+ // Don't keep the element (issue #299)
1907
+ input[0] = null;
1837
1908
  return !results.pop();
1838
1909
  };
1839
1910
  }),
@@ -1845,6 +1916,7 @@ Expr = Sizzle.selectors = {
1845
1916
  }),
1846
1917
 
1847
1918
  "contains": markFunction(function( text ) {
1919
+ text = text.replace( runescape, funescape );
1848
1920
  return function( elem ) {
1849
1921
  return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
1850
1922
  };
@@ -2116,10 +2188,10 @@ function addCombinator( matcher, combinator, base ) {
2116
2188
 
2117
2189
  // Check against all ancestor/preceding elements
2118
2190
  function( elem, context, xml ) {
2119
- var oldCache, outerCache,
2191
+ var oldCache, uniqueCache, outerCache,
2120
2192
  newCache = [ dirruns, doneName ];
2121
2193
 
2122
- // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
2194
+ // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
2123
2195
  if ( xml ) {
2124
2196
  while ( (elem = elem[ dir ]) ) {
2125
2197
  if ( elem.nodeType === 1 || checkNonElements ) {
@@ -2132,14 +2204,19 @@ function addCombinator( matcher, combinator, base ) {
2132
2204
  while ( (elem = elem[ dir ]) ) {
2133
2205
  if ( elem.nodeType === 1 || checkNonElements ) {
2134
2206
  outerCache = elem[ expando ] || (elem[ expando ] = {});
2135
- if ( (oldCache = outerCache[ dir ]) &&
2207
+
2208
+ // Support: IE <9 only
2209
+ // Defend against cloned attroperties (jQuery gh-1709)
2210
+ uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
2211
+
2212
+ if ( (oldCache = uniqueCache[ dir ]) &&
2136
2213
  oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
2137
2214
 
2138
2215
  // Assign to newCache so results back-propagate to previous elements
2139
2216
  return (newCache[ 2 ] = oldCache[ 2 ]);
2140
2217
  } else {
2141
2218
  // Reuse newcache so results back-propagate to previous elements
2142
- outerCache[ dir ] = newCache;
2219
+ uniqueCache[ dir ] = newCache;
2143
2220
 
2144
2221
  // A match means we're done; a fail means we have to keep checking
2145
2222
  if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
@@ -2266,7 +2343,7 @@ function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postS
2266
2343
  i = matcherOut.length;
2267
2344
  while ( i-- ) {
2268
2345
  if ( (elem = matcherOut[i]) &&
2269
- (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
2346
+ (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
2270
2347
 
2271
2348
  seed[temp] = !(results[temp] = elem);
2272
2349
  }
@@ -2301,13 +2378,16 @@ function matcherFromTokens( tokens ) {
2301
2378
  return elem === checkContext;
2302
2379
  }, implicitRelative, true ),
2303
2380
  matchAnyContext = addCombinator( function( elem ) {
2304
- return indexOf.call( checkContext, elem ) > -1;
2381
+ return indexOf( checkContext, elem ) > -1;
2305
2382
  }, implicitRelative, true ),
2306
2383
  matchers = [ function( elem, context, xml ) {
2307
- return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2384
+ var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2308
2385
  (checkContext = context).nodeType ?
2309
2386
  matchContext( elem, context, xml ) :
2310
2387
  matchAnyContext( elem, context, xml ) );
2388
+ // Avoid hanging onto element (issue #299)
2389
+ checkContext = null;
2390
+ return ret;
2311
2391
  } ];
2312
2392
 
2313
2393
  for ( ; i < len; i++ ) {
@@ -2361,18 +2441,21 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2361
2441
  len = elems.length;
2362
2442
 
2363
2443
  if ( outermost ) {
2364
- outermostContext = context !== document && context;
2444
+ outermostContext = context === document || context || outermost;
2365
2445
  }
2366
2446
 
2367
2447
  // Add elements passing elementMatchers directly to results
2368
- // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
2369
2448
  // Support: IE<9, Safari
2370
2449
  // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2371
2450
  for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
2372
2451
  if ( byElement && elem ) {
2373
2452
  j = 0;
2453
+ if ( !context && elem.ownerDocument !== document ) {
2454
+ setDocument( elem );
2455
+ xml = !documentIsHTML;
2456
+ }
2374
2457
  while ( (matcher = elementMatchers[j++]) ) {
2375
- if ( matcher( elem, context, xml ) ) {
2458
+ if ( matcher( elem, context || document, xml) ) {
2376
2459
  results.push( elem );
2377
2460
  break;
2378
2461
  }
@@ -2396,8 +2479,17 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2396
2479
  }
2397
2480
  }
2398
2481
 
2399
- // Apply set filters to unmatched elements
2482
+ // `i` is now the count of elements visited above, and adding it to `matchedCount`
2483
+ // makes the latter nonnegative.
2400
2484
  matchedCount += i;
2485
+
2486
+ // Apply set filters to unmatched elements
2487
+ // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
2488
+ // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
2489
+ // no element matchers and no seed.
2490
+ // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
2491
+ // case, which will result in a "00" `matchedCount` that differs from `i` but is also
2492
+ // numerically zero.
2401
2493
  if ( bySet && i !== matchedCount ) {
2402
2494
  j = 0;
2403
2495
  while ( (matcher = setMatchers[j++]) ) {
@@ -2489,10 +2581,11 @@ select = Sizzle.select = function( selector, context, results, seed ) {
2489
2581
 
2490
2582
  results = results || [];
2491
2583
 
2492
- // Try to minimize operations if there is no seed and only one group
2584
+ // Try to minimize operations if there is only one selector in the list and no seed
2585
+ // (the latter of which guarantees us context)
2493
2586
  if ( match.length === 1 ) {
2494
2587
 
2495
- // Take a shortcut and set the context if the root selector is an ID
2588
+ // Reduce context if the leading compound selector is an ID
2496
2589
  tokens = match[0] = match[0].slice( 0 );
2497
2590
  if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
2498
2591
  support.getById && context.nodeType === 9 && documentIsHTML &&
@@ -2547,7 +2640,7 @@ select = Sizzle.select = function( selector, context, results, seed ) {
2547
2640
  context,
2548
2641
  !documentIsHTML,
2549
2642
  results,
2550
- rsibling.test( selector ) && testContext( context.parentNode ) || context
2643
+ !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
2551
2644
  );
2552
2645
  return results;
2553
2646
  };
@@ -2557,7 +2650,7 @@ select = Sizzle.select = function( selector, context, results, seed ) {
2557
2650
  // Sort stability
2558
2651
  support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
2559
2652
 
2560
- // Support: Chrome<14
2653
+ // Support: Chrome 14-35+
2561
2654
  // Always assume duplicates if they aren't passed to the comparison function
2562
2655
  support.detectDuplicates = !!hasDuplicate;
2563
2656
 
@@ -2623,17 +2716,46 @@ return Sizzle;
2623
2716
 
2624
2717
  jQuery.find = Sizzle;
2625
2718
  jQuery.expr = Sizzle.selectors;
2626
- jQuery.expr[":"] = jQuery.expr.pseudos;
2627
- jQuery.unique = Sizzle.uniqueSort;
2719
+ jQuery.expr[ ":" ] = jQuery.expr.pseudos;
2720
+ jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
2628
2721
  jQuery.text = Sizzle.getText;
2629
2722
  jQuery.isXMLDoc = Sizzle.isXML;
2630
2723
  jQuery.contains = Sizzle.contains;
2631
2724
 
2632
2725
 
2633
2726
 
2727
+ var dir = function( elem, dir, until ) {
2728
+ var matched = [],
2729
+ truncate = until !== undefined;
2730
+
2731
+ while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
2732
+ if ( elem.nodeType === 1 ) {
2733
+ if ( truncate && jQuery( elem ).is( until ) ) {
2734
+ break;
2735
+ }
2736
+ matched.push( elem );
2737
+ }
2738
+ }
2739
+ return matched;
2740
+ };
2741
+
2742
+
2743
+ var siblings = function( n, elem ) {
2744
+ var matched = [];
2745
+
2746
+ for ( ; n; n = n.nextSibling ) {
2747
+ if ( n.nodeType === 1 && n !== elem ) {
2748
+ matched.push( n );
2749
+ }
2750
+ }
2751
+
2752
+ return matched;
2753
+ };
2754
+
2755
+
2634
2756
  var rneedsContext = jQuery.expr.match.needsContext;
2635
2757
 
2636
- var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
2758
+ var rsingleTag = ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ );
2637
2759
 
2638
2760
 
2639
2761
 
@@ -2645,14 +2767,14 @@ function winnow( elements, qualifier, not ) {
2645
2767
  return jQuery.grep( elements, function( elem, i ) {
2646
2768
  /* jshint -W018 */
2647
2769
  return !!qualifier.call( elem, i, elem ) !== not;
2648
- });
2770
+ } );
2649
2771
 
2650
2772
  }
2651
2773
 
2652
2774
  if ( qualifier.nodeType ) {
2653
2775
  return jQuery.grep( elements, function( elem ) {
2654
2776
  return ( elem === qualifier ) !== not;
2655
- });
2777
+ } );
2656
2778
 
2657
2779
  }
2658
2780
 
@@ -2665,8 +2787,8 @@ function winnow( elements, qualifier, not ) {
2665
2787
  }
2666
2788
 
2667
2789
  return jQuery.grep( elements, function( elem ) {
2668
- return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
2669
- });
2790
+ return ( jQuery.inArray( elem, qualifier ) > -1 ) !== not;
2791
+ } );
2670
2792
  }
2671
2793
 
2672
2794
  jQuery.filter = function( expr, elems, not ) {
@@ -2680,10 +2802,10 @@ jQuery.filter = function( expr, elems, not ) {
2680
2802
  jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
2681
2803
  jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
2682
2804
  return elem.nodeType === 1;
2683
- }));
2805
+ } ) );
2684
2806
  };
2685
2807
 
2686
- jQuery.fn.extend({
2808
+ jQuery.fn.extend( {
2687
2809
  find: function( selector ) {
2688
2810
  var i,
2689
2811
  ret = [],
@@ -2691,13 +2813,13 @@ jQuery.fn.extend({
2691
2813
  len = self.length;
2692
2814
 
2693
2815
  if ( typeof selector !== "string" ) {
2694
- return this.pushStack( jQuery( selector ).filter(function() {
2816
+ return this.pushStack( jQuery( selector ).filter( function() {
2695
2817
  for ( i = 0; i < len; i++ ) {
2696
2818
  if ( jQuery.contains( self[ i ], this ) ) {
2697
2819
  return true;
2698
2820
  }
2699
2821
  }
2700
- }) );
2822
+ } ) );
2701
2823
  }
2702
2824
 
2703
2825
  for ( i = 0; i < len; i++ ) {
@@ -2710,10 +2832,10 @@ jQuery.fn.extend({
2710
2832
  return ret;
2711
2833
  },
2712
2834
  filter: function( selector ) {
2713
- return this.pushStack( winnow(this, selector || [], false) );
2835
+ return this.pushStack( winnow( this, selector || [], false ) );
2714
2836
  },
2715
2837
  not: function( selector ) {
2716
- return this.pushStack( winnow(this, selector || [], true) );
2838
+ return this.pushStack( winnow( this, selector || [], true ) );
2717
2839
  },
2718
2840
  is: function( selector ) {
2719
2841
  return !!winnow(
@@ -2727,7 +2849,7 @@ jQuery.fn.extend({
2727
2849
  false
2728
2850
  ).length;
2729
2851
  }
2730
- });
2852
+ } );
2731
2853
 
2732
2854
 
2733
2855
  // Initialize a jQuery object
@@ -2736,15 +2858,12 @@ jQuery.fn.extend({
2736
2858
  // A central reference to the root jQuery(document)
2737
2859
  var rootjQuery,
2738
2860
 
2739
- // Use the correct document accordingly with window argument (sandbox)
2740
- document = window.document,
2741
-
2742
2861
  // A simple way to check for HTML strings
2743
2862
  // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2744
2863
  // Strict HTML recognition (#11290: must start with <)
2745
2864
  rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
2746
2865
 
2747
- init = jQuery.fn.init = function( selector, context ) {
2866
+ init = jQuery.fn.init = function( selector, context, root ) {
2748
2867
  var match, elem;
2749
2868
 
2750
2869
  // HANDLE: $(""), $(null), $(undefined), $(false)
@@ -2752,9 +2871,16 @@ var rootjQuery,
2752
2871
  return this;
2753
2872
  }
2754
2873
 
2874
+ // init accepts an alternate rootjQuery
2875
+ // so migrate can support jQuery.sub (gh-2101)
2876
+ root = root || rootjQuery;
2877
+
2755
2878
  // Handle HTML strings
2756
2879
  if ( typeof selector === "string" ) {
2757
- if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
2880
+ if ( selector.charAt( 0 ) === "<" &&
2881
+ selector.charAt( selector.length - 1 ) === ">" &&
2882
+ selector.length >= 3 ) {
2883
+
2758
2884
  // Assume that strings that start and end with <> are HTML and skip the regex check
2759
2885
  match = [ null, selector, null ];
2760
2886
 
@@ -2763,23 +2889,24 @@ var rootjQuery,
2763
2889
  }
2764
2890
 
2765
2891
  // Match html or make sure no context is specified for #id
2766
- if ( match && (match[1] || !context) ) {
2892
+ if ( match && ( match[ 1 ] || !context ) ) {
2767
2893
 
2768
2894
  // HANDLE: $(html) -> $(array)
2769
- if ( match[1] ) {
2770
- context = context instanceof jQuery ? context[0] : context;
2895
+ if ( match[ 1 ] ) {
2896
+ context = context instanceof jQuery ? context[ 0 ] : context;
2771
2897
 
2772
2898
  // scripts is true for back-compat
2773
2899
  // Intentionally let the error be thrown if parseHTML is not present
2774
2900
  jQuery.merge( this, jQuery.parseHTML(
2775
- match[1],
2901
+ match[ 1 ],
2776
2902
  context && context.nodeType ? context.ownerDocument || context : document,
2777
2903
  true
2778
2904
  ) );
2779
2905
 
2780
2906
  // HANDLE: $(html, props)
2781
- if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
2907
+ if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
2782
2908
  for ( match in context ) {
2909
+
2783
2910
  // Properties of context are called as methods if possible
2784
2911
  if ( jQuery.isFunction( this[ match ] ) ) {
2785
2912
  this[ match ]( context[ match ] );
@@ -2795,20 +2922,21 @@ var rootjQuery,
2795
2922
 
2796
2923
  // HANDLE: $(#id)
2797
2924
  } else {
2798
- elem = document.getElementById( match[2] );
2925
+ elem = document.getElementById( match[ 2 ] );
2799
2926
 
2800
2927
  // Check parentNode to catch when Blackberry 4.6 returns
2801
2928
  // nodes that are no longer in the document #6963
2802
2929
  if ( elem && elem.parentNode ) {
2930
+
2803
2931
  // Handle the case where IE and Opera return items
2804
2932
  // by name instead of ID
2805
- if ( elem.id !== match[2] ) {
2933
+ if ( elem.id !== match[ 2 ] ) {
2806
2934
  return rootjQuery.find( selector );
2807
2935
  }
2808
2936
 
2809
2937
  // Otherwise, we inject the element directly into the jQuery object
2810
2938
  this.length = 1;
2811
- this[0] = elem;
2939
+ this[ 0 ] = elem;
2812
2940
  }
2813
2941
 
2814
2942
  this.context = document;
@@ -2818,7 +2946,7 @@ var rootjQuery,
2818
2946
 
2819
2947
  // HANDLE: $(expr, $(...))
2820
2948
  } else if ( !context || context.jquery ) {
2821
- return ( context || rootjQuery ).find( selector );
2949
+ return ( context || root ).find( selector );
2822
2950
 
2823
2951
  // HANDLE: $(expr, context)
2824
2952
  // (which is just equivalent to: $(context).find(expr)
@@ -2828,15 +2956,16 @@ var rootjQuery,
2828
2956
 
2829
2957
  // HANDLE: $(DOMElement)
2830
2958
  } else if ( selector.nodeType ) {
2831
- this.context = this[0] = selector;
2959
+ this.context = this[ 0 ] = selector;
2832
2960
  this.length = 1;
2833
2961
  return this;
2834
2962
 
2835
2963
  // HANDLE: $(function)
2836
2964
  // Shortcut for document ready
2837
2965
  } else if ( jQuery.isFunction( selector ) ) {
2838
- return typeof rootjQuery.ready !== "undefined" ?
2839
- rootjQuery.ready( selector ) :
2966
+ return typeof root.ready !== "undefined" ?
2967
+ root.ready( selector ) :
2968
+
2840
2969
  // Execute immediately if ready is not present
2841
2970
  selector( jQuery );
2842
2971
  }
@@ -2857,6 +2986,7 @@ rootjQuery = jQuery( document );
2857
2986
 
2858
2987
 
2859
2988
  var rparentsprev = /^(?:parents|prev(?:Until|All))/,
2989
+
2860
2990
  // methods guaranteed to produce a unique set when starting from a unique set
2861
2991
  guaranteedUnique = {
2862
2992
  children: true,
@@ -2865,46 +2995,19 @@ var rparentsprev = /^(?:parents|prev(?:Until|All))/,
2865
2995
  prev: true
2866
2996
  };
2867
2997
 
2868
- jQuery.extend({
2869
- dir: function( elem, dir, until ) {
2870
- var matched = [],
2871
- cur = elem[ dir ];
2872
-
2873
- while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
2874
- if ( cur.nodeType === 1 ) {
2875
- matched.push( cur );
2876
- }
2877
- cur = cur[dir];
2878
- }
2879
- return matched;
2880
- },
2881
-
2882
- sibling: function( n, elem ) {
2883
- var r = [];
2884
-
2885
- for ( ; n; n = n.nextSibling ) {
2886
- if ( n.nodeType === 1 && n !== elem ) {
2887
- r.push( n );
2888
- }
2889
- }
2890
-
2891
- return r;
2892
- }
2893
- });
2894
-
2895
- jQuery.fn.extend({
2998
+ jQuery.fn.extend( {
2896
2999
  has: function( target ) {
2897
3000
  var i,
2898
3001
  targets = jQuery( target, this ),
2899
3002
  len = targets.length;
2900
3003
 
2901
- return this.filter(function() {
3004
+ return this.filter( function() {
2902
3005
  for ( i = 0; i < len; i++ ) {
2903
- if ( jQuery.contains( this, targets[i] ) ) {
3006
+ if ( jQuery.contains( this, targets[ i ] ) ) {
2904
3007
  return true;
2905
3008
  }
2906
3009
  }
2907
- });
3010
+ } );
2908
3011
  },
2909
3012
 
2910
3013
  closest: function( selectors, context ) {
@@ -2917,14 +3020,15 @@ jQuery.fn.extend({
2917
3020
  0;
2918
3021
 
2919
3022
  for ( ; i < l; i++ ) {
2920
- for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
3023
+ for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
3024
+
2921
3025
  // Always skip document fragments
2922
- if ( cur.nodeType < 11 && (pos ?
2923
- pos.index(cur) > -1 :
3026
+ if ( cur.nodeType < 11 && ( pos ?
3027
+ pos.index( cur ) > -1 :
2924
3028
 
2925
3029
  // Don't pass non-elements to Sizzle
2926
3030
  cur.nodeType === 1 &&
2927
- jQuery.find.matchesSelector(cur, selectors)) ) {
3031
+ jQuery.find.matchesSelector( cur, selectors ) ) ) {
2928
3032
 
2929
3033
  matched.push( cur );
2930
3034
  break;
@@ -2932,7 +3036,7 @@ jQuery.fn.extend({
2932
3036
  }
2933
3037
  }
2934
3038
 
2935
- return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
3039
+ return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
2936
3040
  },
2937
3041
 
2938
3042
  // Determine the position of an element within
@@ -2941,23 +3045,24 @@ jQuery.fn.extend({
2941
3045
 
2942
3046
  // No argument, return index in parent
2943
3047
  if ( !elem ) {
2944
- return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
3048
+ return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
2945
3049
  }
2946
3050
 
2947
3051
  // index in selector
2948
3052
  if ( typeof elem === "string" ) {
2949
- return jQuery.inArray( this[0], jQuery( elem ) );
3053
+ return jQuery.inArray( this[ 0 ], jQuery( elem ) );
2950
3054
  }
2951
3055
 
2952
3056
  // Locate the position of the desired element
2953
3057
  return jQuery.inArray(
3058
+
2954
3059
  // If it receives a jQuery object, the first element is used
2955
- elem.jquery ? elem[0] : elem, this );
3060
+ elem.jquery ? elem[ 0 ] : elem, this );
2956
3061
  },
2957
3062
 
2958
3063
  add: function( selector, context ) {
2959
3064
  return this.pushStack(
2960
- jQuery.unique(
3065
+ jQuery.uniqueSort(
2961
3066
  jQuery.merge( this.get(), jQuery( selector, context ) )
2962
3067
  )
2963
3068
  );
@@ -2965,10 +3070,10 @@ jQuery.fn.extend({
2965
3070
 
2966
3071
  addBack: function( selector ) {
2967
3072
  return this.add( selector == null ?
2968
- this.prevObject : this.prevObject.filter(selector)
3073
+ this.prevObject : this.prevObject.filter( selector )
2969
3074
  );
2970
3075
  }
2971
- });
3076
+ } );
2972
3077
 
2973
3078
  function sibling( cur, dir ) {
2974
3079
  do {
@@ -2978,16 +3083,16 @@ function sibling( cur, dir ) {
2978
3083
  return cur;
2979
3084
  }
2980
3085
 
2981
- jQuery.each({
3086
+ jQuery.each( {
2982
3087
  parent: function( elem ) {
2983
3088
  var parent = elem.parentNode;
2984
3089
  return parent && parent.nodeType !== 11 ? parent : null;
2985
3090
  },
2986
3091
  parents: function( elem ) {
2987
- return jQuery.dir( elem, "parentNode" );
3092
+ return dir( elem, "parentNode" );
2988
3093
  },
2989
3094
  parentsUntil: function( elem, i, until ) {
2990
- return jQuery.dir( elem, "parentNode", until );
3095
+ return dir( elem, "parentNode", until );
2991
3096
  },
2992
3097
  next: function( elem ) {
2993
3098
  return sibling( elem, "nextSibling" );
@@ -2996,22 +3101,22 @@ jQuery.each({
2996
3101
  return sibling( elem, "previousSibling" );
2997
3102
  },
2998
3103
  nextAll: function( elem ) {
2999
- return jQuery.dir( elem, "nextSibling" );
3104
+ return dir( elem, "nextSibling" );
3000
3105
  },
3001
3106
  prevAll: function( elem ) {
3002
- return jQuery.dir( elem, "previousSibling" );
3107
+ return dir( elem, "previousSibling" );
3003
3108
  },
3004
3109
  nextUntil: function( elem, i, until ) {
3005
- return jQuery.dir( elem, "nextSibling", until );
3110
+ return dir( elem, "nextSibling", until );
3006
3111
  },
3007
3112
  prevUntil: function( elem, i, until ) {
3008
- return jQuery.dir( elem, "previousSibling", until );
3113
+ return dir( elem, "previousSibling", until );
3009
3114
  },
3010
3115
  siblings: function( elem ) {
3011
- return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
3116
+ return siblings( ( elem.parentNode || {} ).firstChild, elem );
3012
3117
  },
3013
3118
  children: function( elem ) {
3014
- return jQuery.sibling( elem.firstChild );
3119
+ return siblings( elem.firstChild );
3015
3120
  },
3016
3121
  contents: function( elem ) {
3017
3122
  return jQuery.nodeName( elem, "iframe" ) ?
@@ -3031,9 +3136,10 @@ jQuery.each({
3031
3136
  }
3032
3137
 
3033
3138
  if ( this.length > 1 ) {
3139
+
3034
3140
  // Remove duplicates
3035
3141
  if ( !guaranteedUnique[ name ] ) {
3036
- ret = jQuery.unique( ret );
3142
+ ret = jQuery.uniqueSort( ret );
3037
3143
  }
3038
3144
 
3039
3145
  // Reverse order for parents* and prev-derivatives
@@ -3044,20 +3150,17 @@ jQuery.each({
3044
3150
 
3045
3151
  return this.pushStack( ret );
3046
3152
  };
3047
- });
3048
- var rnotwhite = (/\S+/g);
3049
-
3153
+ } );
3154
+ var rnotwhite = ( /\S+/g );
3050
3155
 
3051
3156
 
3052
- // String to Object options format cache
3053
- var optionsCache = {};
3054
3157
 
3055
- // Convert String-formatted options into Object-formatted ones and store in cache
3158
+ // Convert String-formatted options into Object-formatted ones
3056
3159
  function createOptions( options ) {
3057
- var object = optionsCache[ options ] = {};
3160
+ var object = {};
3058
3161
  jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
3059
3162
  object[ flag ] = true;
3060
- });
3163
+ } );
3061
3164
  return object;
3062
3165
  }
3063
3166
 
@@ -3088,156 +3191,186 @@ jQuery.Callbacks = function( options ) {
3088
3191
  // Convert options from String-formatted to Object-formatted if needed
3089
3192
  // (we check in cache first)
3090
3193
  options = typeof options === "string" ?
3091
- ( optionsCache[ options ] || createOptions( options ) ) :
3194
+ createOptions( options ) :
3092
3195
  jQuery.extend( {}, options );
3093
3196
 
3094
3197
  var // Flag to know if list is currently firing
3095
3198
  firing,
3096
- // Last fire value (for non-forgettable lists)
3199
+
3200
+ // Last fire value for non-forgettable lists
3097
3201
  memory,
3202
+
3098
3203
  // Flag to know if list was already fired
3099
3204
  fired,
3100
- // End of the loop when firing
3101
- firingLength,
3102
- // Index of currently firing callback (modified by remove if needed)
3103
- firingIndex,
3104
- // First callback to fire (used internally by add and fireWith)
3105
- firingStart,
3205
+
3206
+ // Flag to prevent firing
3207
+ locked,
3208
+
3106
3209
  // Actual callback list
3107
3210
  list = [],
3108
- // Stack of fire calls for repeatable lists
3109
- stack = !options.once && [],
3211
+
3212
+ // Queue of execution data for repeatable lists
3213
+ queue = [],
3214
+
3215
+ // Index of currently firing callback (modified by add/remove as needed)
3216
+ firingIndex = -1,
3217
+
3110
3218
  // Fire callbacks
3111
- fire = function( data ) {
3112
- memory = options.memory && data;
3113
- fired = true;
3114
- firingIndex = firingStart || 0;
3115
- firingStart = 0;
3116
- firingLength = list.length;
3117
- firing = true;
3118
- for ( ; list && firingIndex < firingLength; firingIndex++ ) {
3119
- if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
3120
- memory = false; // To prevent further calls using add
3121
- break;
3219
+ fire = function() {
3220
+
3221
+ // Enforce single-firing
3222
+ locked = options.once;
3223
+
3224
+ // Execute callbacks for all pending executions,
3225
+ // respecting firingIndex overrides and runtime changes
3226
+ fired = firing = true;
3227
+ for ( ; queue.length; firingIndex = -1 ) {
3228
+ memory = queue.shift();
3229
+ while ( ++firingIndex < list.length ) {
3230
+
3231
+ // Run callback and check for early termination
3232
+ if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
3233
+ options.stopOnFalse ) {
3234
+
3235
+ // Jump to end and forget the data so .add doesn't re-fire
3236
+ firingIndex = list.length;
3237
+ memory = false;
3238
+ }
3122
3239
  }
3123
3240
  }
3241
+
3242
+ // Forget the data if we're done with it
3243
+ if ( !options.memory ) {
3244
+ memory = false;
3245
+ }
3246
+
3124
3247
  firing = false;
3125
- if ( list ) {
3126
- if ( stack ) {
3127
- if ( stack.length ) {
3128
- fire( stack.shift() );
3129
- }
3130
- } else if ( memory ) {
3248
+
3249
+ // Clean up if we're done firing for good
3250
+ if ( locked ) {
3251
+
3252
+ // Keep an empty list if we have data for future add calls
3253
+ if ( memory ) {
3131
3254
  list = [];
3255
+
3256
+ // Otherwise, this object is spent
3132
3257
  } else {
3133
- self.disable();
3258
+ list = "";
3134
3259
  }
3135
3260
  }
3136
3261
  },
3262
+
3137
3263
  // Actual Callbacks object
3138
3264
  self = {
3265
+
3139
3266
  // Add a callback or a collection of callbacks to the list
3140
3267
  add: function() {
3141
3268
  if ( list ) {
3142
- // First, we save the current length
3143
- var start = list.length;
3144
- (function add( args ) {
3269
+
3270
+ // If we have memory from a past run, we should fire after adding
3271
+ if ( memory && !firing ) {
3272
+ firingIndex = list.length - 1;
3273
+ queue.push( memory );
3274
+ }
3275
+
3276
+ ( function add( args ) {
3145
3277
  jQuery.each( args, function( _, arg ) {
3146
- var type = jQuery.type( arg );
3147
- if ( type === "function" ) {
3278
+ if ( jQuery.isFunction( arg ) ) {
3148
3279
  if ( !options.unique || !self.has( arg ) ) {
3149
3280
  list.push( arg );
3150
3281
  }
3151
- } else if ( arg && arg.length && type !== "string" ) {
3282
+ } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) {
3283
+
3152
3284
  // Inspect recursively
3153
3285
  add( arg );
3154
3286
  }
3155
- });
3156
- })( arguments );
3157
- // Do we need to add the callbacks to the
3158
- // current firing batch?
3159
- if ( firing ) {
3160
- firingLength = list.length;
3161
- // With memory, if we're not firing then
3162
- // we should call right away
3163
- } else if ( memory ) {
3164
- firingStart = start;
3165
- fire( memory );
3287
+ } );
3288
+ } )( arguments );
3289
+
3290
+ if ( memory && !firing ) {
3291
+ fire();
3166
3292
  }
3167
3293
  }
3168
3294
  return this;
3169
3295
  },
3296
+
3170
3297
  // Remove a callback from the list
3171
3298
  remove: function() {
3172
- if ( list ) {
3173
- jQuery.each( arguments, function( _, arg ) {
3174
- var index;
3175
- while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
3176
- list.splice( index, 1 );
3177
- // Handle firing indexes
3178
- if ( firing ) {
3179
- if ( index <= firingLength ) {
3180
- firingLength--;
3181
- }
3182
- if ( index <= firingIndex ) {
3183
- firingIndex--;
3184
- }
3185
- }
3299
+ jQuery.each( arguments, function( _, arg ) {
3300
+ var index;
3301
+ while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
3302
+ list.splice( index, 1 );
3303
+
3304
+ // Handle firing indexes
3305
+ if ( index <= firingIndex ) {
3306
+ firingIndex--;
3186
3307
  }
3187
- });
3188
- }
3308
+ }
3309
+ } );
3189
3310
  return this;
3190
3311
  },
3312
+
3191
3313
  // Check if a given callback is in the list.
3192
3314
  // If no argument is given, return whether or not list has callbacks attached.
3193
3315
  has: function( fn ) {
3194
- return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
3316
+ return fn ?
3317
+ jQuery.inArray( fn, list ) > -1 :
3318
+ list.length > 0;
3195
3319
  },
3320
+
3196
3321
  // Remove all callbacks from the list
3197
3322
  empty: function() {
3198
- list = [];
3199
- firingLength = 0;
3323
+ if ( list ) {
3324
+ list = [];
3325
+ }
3200
3326
  return this;
3201
3327
  },
3202
- // Have the list do nothing anymore
3328
+
3329
+ // Disable .fire and .add
3330
+ // Abort any current/pending executions
3331
+ // Clear all callbacks and values
3203
3332
  disable: function() {
3204
- list = stack = memory = undefined;
3333
+ locked = queue = [];
3334
+ list = memory = "";
3205
3335
  return this;
3206
3336
  },
3207
- // Is it disabled?
3208
3337
  disabled: function() {
3209
3338
  return !list;
3210
3339
  },
3211
- // Lock the list in its current state
3340
+
3341
+ // Disable .fire
3342
+ // Also disable .add unless we have memory (since it would have no effect)
3343
+ // Abort any pending executions
3212
3344
  lock: function() {
3213
- stack = undefined;
3345
+ locked = true;
3214
3346
  if ( !memory ) {
3215
3347
  self.disable();
3216
3348
  }
3217
3349
  return this;
3218
3350
  },
3219
- // Is it locked?
3220
3351
  locked: function() {
3221
- return !stack;
3352
+ return !!locked;
3222
3353
  },
3354
+
3223
3355
  // Call all callbacks with the given context and arguments
3224
3356
  fireWith: function( context, args ) {
3225
- if ( list && ( !fired || stack ) ) {
3357
+ if ( !locked ) {
3226
3358
  args = args || [];
3227
3359
  args = [ context, args.slice ? args.slice() : args ];
3228
- if ( firing ) {
3229
- stack.push( args );
3230
- } else {
3231
- fire( args );
3360
+ queue.push( args );
3361
+ if ( !firing ) {
3362
+ fire();
3232
3363
  }
3233
3364
  }
3234
3365
  return this;
3235
3366
  },
3367
+
3236
3368
  // Call all the callbacks with the given arguments
3237
3369
  fire: function() {
3238
3370
  self.fireWith( this, arguments );
3239
3371
  return this;
3240
3372
  },
3373
+
3241
3374
  // To know if the callbacks have already been called at least once
3242
3375
  fired: function() {
3243
3376
  return !!fired;
@@ -3248,14 +3381,15 @@ jQuery.Callbacks = function( options ) {
3248
3381
  };
3249
3382
 
3250
3383
 
3251
- jQuery.extend({
3384
+ jQuery.extend( {
3252
3385
 
3253
3386
  Deferred: function( func ) {
3254
3387
  var tuples = [
3388
+
3255
3389
  // action, add listener, listener list, final state
3256
- [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
3257
- [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
3258
- [ "notify", "progress", jQuery.Callbacks("memory") ]
3390
+ [ "resolve", "done", jQuery.Callbacks( "once memory" ), "resolved" ],
3391
+ [ "reject", "fail", jQuery.Callbacks( "once memory" ), "rejected" ],
3392
+ [ "notify", "progress", jQuery.Callbacks( "memory" ) ]
3259
3393
  ],
3260
3394
  state = "pending",
3261
3395
  promise = {
@@ -3268,25 +3402,30 @@ jQuery.extend({
3268
3402
  },
3269
3403
  then: function( /* fnDone, fnFail, fnProgress */ ) {
3270
3404
  var fns = arguments;
3271
- return jQuery.Deferred(function( newDefer ) {
3405
+ return jQuery.Deferred( function( newDefer ) {
3272
3406
  jQuery.each( tuples, function( i, tuple ) {
3273
3407
  var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
3408
+
3274
3409
  // deferred[ done | fail | progress ] for forwarding actions to newDefer
3275
- deferred[ tuple[1] ](function() {
3410
+ deferred[ tuple[ 1 ] ]( function() {
3276
3411
  var returned = fn && fn.apply( this, arguments );
3277
3412
  if ( returned && jQuery.isFunction( returned.promise ) ) {
3278
3413
  returned.promise()
3414
+ .progress( newDefer.notify )
3279
3415
  .done( newDefer.resolve )
3280
- .fail( newDefer.reject )
3281
- .progress( newDefer.notify );
3416
+ .fail( newDefer.reject );
3282
3417
  } else {
3283
- newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
3418
+ newDefer[ tuple[ 0 ] + "With" ](
3419
+ this === promise ? newDefer.promise() : this,
3420
+ fn ? [ returned ] : arguments
3421
+ );
3284
3422
  }
3285
- });
3286
- });
3423
+ } );
3424
+ } );
3287
3425
  fns = null;
3288
- }).promise();
3426
+ } ).promise();
3289
3427
  },
3428
+
3290
3429
  // Get a promise for this deferred
3291
3430
  // If obj is provided, the promise aspect is added to the object
3292
3431
  promise: function( obj ) {
@@ -3304,11 +3443,12 @@ jQuery.extend({
3304
3443
  stateString = tuple[ 3 ];
3305
3444
 
3306
3445
  // promise[ done | fail | progress ] = list.add
3307
- promise[ tuple[1] ] = list.add;
3446
+ promise[ tuple[ 1 ] ] = list.add;
3308
3447
 
3309
3448
  // Handle state
3310
3449
  if ( stateString ) {
3311
- list.add(function() {
3450
+ list.add( function() {
3451
+
3312
3452
  // state = [ resolved | rejected ]
3313
3453
  state = stateString;
3314
3454
 
@@ -3317,12 +3457,12 @@ jQuery.extend({
3317
3457
  }
3318
3458
 
3319
3459
  // deferred[ resolve | reject | notify ]
3320
- deferred[ tuple[0] ] = function() {
3321
- deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
3460
+ deferred[ tuple[ 0 ] ] = function() {
3461
+ deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments );
3322
3462
  return this;
3323
3463
  };
3324
- deferred[ tuple[0] + "With" ] = list.fireWith;
3325
- });
3464
+ deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
3465
+ } );
3326
3466
 
3327
3467
  // Make the deferred a promise
3328
3468
  promise.promise( deferred );
@@ -3343,9 +3483,11 @@ jQuery.extend({
3343
3483
  length = resolveValues.length,
3344
3484
 
3345
3485
  // the count of uncompleted subordinates
3346
- remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
3486
+ remaining = length !== 1 ||
3487
+ ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
3347
3488
 
3348
- // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
3489
+ // the master Deferred.
3490
+ // If resolveValues consist of only a single Deferred, just use that.
3349
3491
  deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
3350
3492
 
3351
3493
  // Update function for both resolve and progress values
@@ -3356,7 +3498,7 @@ jQuery.extend({
3356
3498
  if ( values === progressValues ) {
3357
3499
  deferred.notifyWith( contexts, values );
3358
3500
 
3359
- } else if ( !(--remaining) ) {
3501
+ } else if ( !( --remaining ) ) {
3360
3502
  deferred.resolveWith( contexts, values );
3361
3503
  }
3362
3504
  };
@@ -3372,9 +3514,9 @@ jQuery.extend({
3372
3514
  for ( ; i < length; i++ ) {
3373
3515
  if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
3374
3516
  resolveValues[ i ].promise()
3517
+ .progress( updateFunc( i, progressContexts, progressValues ) )
3375
3518
  .done( updateFunc( i, resolveContexts, resolveValues ) )
3376
- .fail( deferred.reject )
3377
- .progress( updateFunc( i, progressContexts, progressValues ) );
3519
+ .fail( deferred.reject );
3378
3520
  } else {
3379
3521
  --remaining;
3380
3522
  }
@@ -3388,20 +3530,22 @@ jQuery.extend({
3388
3530
 
3389
3531
  return deferred.promise();
3390
3532
  }
3391
- });
3533
+ } );
3392
3534
 
3393
3535
 
3394
3536
  // The deferred used on DOM ready
3395
3537
  var readyList;
3396
3538
 
3397
3539
  jQuery.fn.ready = function( fn ) {
3540
+
3398
3541
  // Add the callback
3399
3542
  jQuery.ready.promise().done( fn );
3400
3543
 
3401
3544
  return this;
3402
3545
  };
3403
3546
 
3404
- jQuery.extend({
3547
+ jQuery.extend( {
3548
+
3405
3549
  // Is the DOM ready to be used? Set to true once it occurs.
3406
3550
  isReady: false,
3407
3551
 
@@ -3426,11 +3570,6 @@ jQuery.extend({
3426
3570
  return;
3427
3571
  }
3428
3572
 
3429
- // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
3430
- if ( !document.body ) {
3431
- return setTimeout( jQuery.ready );
3432
- }
3433
-
3434
3573
  // Remember that the DOM is ready
3435
3574
  jQuery.isReady = true;
3436
3575
 
@@ -3448,15 +3587,15 @@ jQuery.extend({
3448
3587
  jQuery( document ).off( "ready" );
3449
3588
  }
3450
3589
  }
3451
- });
3590
+ } );
3452
3591
 
3453
3592
  /**
3454
3593
  * Clean-up method for dom ready events
3455
3594
  */
3456
3595
  function detach() {
3457
3596
  if ( document.addEventListener ) {
3458
- document.removeEventListener( "DOMContentLoaded", completed, false );
3459
- window.removeEventListener( "load", completed, false );
3597
+ document.removeEventListener( "DOMContentLoaded", completed );
3598
+ window.removeEventListener( "load", completed );
3460
3599
 
3461
3600
  } else {
3462
3601
  document.detachEvent( "onreadystatechange", completed );
@@ -3468,8 +3607,12 @@ function detach() {
3468
3607
  * The ready event handler and self cleanup method
3469
3608
  */
3470
3609
  function completed() {
3610
+
3471
3611
  // readyState === "complete" is good enough for us to call the dom ready in oldIE
3472
- if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) {
3612
+ if ( document.addEventListener ||
3613
+ window.event.type === "load" ||
3614
+ document.readyState === "complete" ) {
3615
+
3473
3616
  detach();
3474
3617
  jQuery.ready();
3475
3618
  }
@@ -3480,23 +3623,28 @@ jQuery.ready.promise = function( obj ) {
3480
3623
 
3481
3624
  readyList = jQuery.Deferred();
3482
3625
 
3483
- // Catch cases where $(document).ready() is called after the browser event has already occurred.
3484
- // we once tried to use readyState "interactive" here, but it caused issues like the one
3485
- // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
3486
- if ( document.readyState === "complete" ) {
3626
+ // Catch cases where $(document).ready() is called
3627
+ // after the browser event has already occurred.
3628
+ // Support: IE6-10
3629
+ // Older IE sometimes signals "interactive" too soon
3630
+ if ( document.readyState === "complete" ||
3631
+ ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
3632
+
3487
3633
  // Handle it asynchronously to allow scripts the opportunity to delay ready
3488
- setTimeout( jQuery.ready );
3634
+ window.setTimeout( jQuery.ready );
3489
3635
 
3490
3636
  // Standards-based browsers support DOMContentLoaded
3491
3637
  } else if ( document.addEventListener ) {
3638
+
3492
3639
  // Use the handy event callback
3493
- document.addEventListener( "DOMContentLoaded", completed, false );
3640
+ document.addEventListener( "DOMContentLoaded", completed );
3494
3641
 
3495
3642
  // A fallback to window.onload, that will always work
3496
- window.addEventListener( "load", completed, false );
3643
+ window.addEventListener( "load", completed );
3497
3644
 
3498
3645
  // If IE event model is used
3499
3646
  } else {
3647
+
3500
3648
  // Ensure firing before onload, maybe late but safe also for iframes
3501
3649
  document.attachEvent( "onreadystatechange", completed );
3502
3650
 
@@ -3509,18 +3657,19 @@ jQuery.ready.promise = function( obj ) {
3509
3657
 
3510
3658
  try {
3511
3659
  top = window.frameElement == null && document.documentElement;
3512
- } catch(e) {}
3660
+ } catch ( e ) {}
3513
3661
 
3514
3662
  if ( top && top.doScroll ) {
3515
- (function doScrollCheck() {
3663
+ ( function doScrollCheck() {
3516
3664
  if ( !jQuery.isReady ) {
3517
3665
 
3518
3666
  try {
3667
+
3519
3668
  // Use the trick by Diego Perini
3520
3669
  // http://javascript.nwbox.com/IEContentLoaded/
3521
- top.doScroll("left");
3522
- } catch(e) {
3523
- return setTimeout( doScrollCheck, 50 );
3670
+ top.doScroll( "left" );
3671
+ } catch ( e ) {
3672
+ return window.setTimeout( doScrollCheck, 50 );
3524
3673
  }
3525
3674
 
3526
3675
  // detach all dom ready events
@@ -3529,15 +3678,16 @@ jQuery.ready.promise = function( obj ) {
3529
3678
  // and execute any waiting functions
3530
3679
  jQuery.ready();
3531
3680
  }
3532
- })();
3681
+ } )();
3533
3682
  }
3534
3683
  }
3535
3684
  }
3536
3685
  return readyList.promise( obj );
3537
3686
  };
3538
3687
 
3688
+ // Kick off the DOM ready check even if the user does not
3689
+ jQuery.ready.promise();
3539
3690
 
3540
- var strundefined = typeof undefined;
3541
3691
 
3542
3692
 
3543
3693
 
@@ -3547,19 +3697,21 @@ var i;
3547
3697
  for ( i in jQuery( support ) ) {
3548
3698
  break;
3549
3699
  }
3550
- support.ownLast = i !== "0";
3700
+ support.ownFirst = i === "0";
3551
3701
 
3552
3702
  // Note: most support tests are defined in their respective modules.
3553
3703
  // false until the test is run
3554
3704