tdiary 3.2.2.20130617 → 3.2.2.20130720

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * jQuery JavaScript Library v1.8.0
2
+ * jQuery JavaScript Library v1.8.3
3
3
  * http://jquery.com/
4
4
  *
5
5
  * Includes Sizzle.js
@@ -9,7 +9,7 @@
9
9
  * Released under the MIT license
10
10
  * http://jquery.org/license
11
11
  *
12
- * Date: Thu Aug 09 2012 16:24:48 GMT-0400 (Eastern Daylight Time)
12
+ * Date: Tue Nov 13 2012 08:20:33 GMT-0500 (Eastern Standard Time)
13
13
  */
14
14
  (function( window, undefined ) {
15
15
  var
@@ -51,8 +51,8 @@ var
51
51
  core_rnotwhite = /\S/,
52
52
  core_rspace = /\s+/,
53
53
 
54
- // IE doesn't match non-breaking spaces with \s
55
- rtrim = core_rnotwhite.test("\xA0") ? (/^[\s\xA0]+|[\s\xA0]+$/g) : /^\s+|\s+$/g,
54
+ // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
55
+ rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
56
56
 
57
57
  // A simple way to check for HTML strings
58
58
  // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
@@ -186,7 +186,7 @@ jQuery.fn = jQuery.prototype = {
186
186
  selector: "",
187
187
 
188
188
  // The current version of jQuery being used
189
- jquery: "1.8.0",
189
+ jquery: "1.8.3",
190
190
 
191
191
  // The default length of a jQuery object is 0
192
192
  length: 0,
@@ -573,7 +573,7 @@ jQuery.extend({
573
573
  },
574
574
 
575
575
  nodeName: function( elem, name ) {
576
- return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
576
+ return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
577
577
  },
578
578
 
579
579
  // args is for internal usage only
@@ -619,7 +619,7 @@ jQuery.extend({
619
619
  },
620
620
 
621
621
  // Use native String.trim function wherever possible
622
- trim: core_trim ?
622
+ trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
623
623
  function( text ) {
624
624
  return text == null ?
625
625
  "" :
@@ -630,7 +630,7 @@ jQuery.extend({
630
630
  function( text ) {
631
631
  return text == null ?
632
632
  "" :
633
- text.toString().replace( rtrim, "" );
633
+ ( text + "" ).replace( rtrim, "" );
634
634
  },
635
635
 
636
636
  // results is for internal usage only
@@ -776,7 +776,7 @@ jQuery.extend({
776
776
  };
777
777
 
778
778
  // Set the guid of unique handler to the same of original handler, so it can be removed
779
- proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
779
+ proxy.guid = fn.guid = fn.guid || jQuery.guid++;
780
780
 
781
781
  return proxy;
782
782
  },
@@ -844,9 +844,10 @@ jQuery.ready.promise = function( obj ) {
844
844
 
845
845
  readyList = jQuery.Deferred();
846
846
 
847
- // Catch cases where $(document).ready() is called after the
848
- // browser event has already occurred.
849
- if ( document.readyState === "complete" || ( document.readyState !== "loading" && document.addEventListener ) ) {
847
+ // Catch cases where $(document).ready() is called after the browser event has already occurred.
848
+ // we once tried to use readyState "interactive" here, but it caused issues like the one
849
+ // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
850
+ if ( document.readyState === "complete" ) {
850
851
  // Handle it asynchronously to allow scripts the opportunity to delay ready
851
852
  setTimeout( jQuery.ready, 1 );
852
853
 
@@ -997,9 +998,12 @@ jQuery.Callbacks = function( options ) {
997
998
  var start = list.length;
998
999
  (function add( args ) {
999
1000
  jQuery.each( args, function( _, arg ) {
1000
- if ( jQuery.isFunction( arg ) && ( !options.unique || !self.has( arg ) ) ) {
1001
- list.push( arg );
1002
- } else if ( arg && arg.length ) {
1001
+ var type = jQuery.type( arg );
1002
+ if ( type === "function" ) {
1003
+ if ( !options.unique || !self.has( arg ) ) {
1004
+ list.push( arg );
1005
+ }
1006
+ } else if ( arg && arg.length && type !== "string" ) {
1003
1007
  // Inspect recursively
1004
1008
  add( arg );
1005
1009
  }
@@ -1141,7 +1145,7 @@ jQuery.extend({
1141
1145
  // Get a promise for this deferred
1142
1146
  // If obj is provided, the promise aspect is added to the object
1143
1147
  promise: function( obj ) {
1144
- return typeof obj === "object" ? jQuery.extend( obj, promise ) : promise;
1148
+ return obj != null ? jQuery.extend( obj, promise ) : promise;
1145
1149
  }
1146
1150
  },
1147
1151
  deferred = {};
@@ -1251,24 +1255,23 @@ jQuery.support = (function() {
1251
1255
  clickFn,
1252
1256
  div = document.createElement("div");
1253
1257
 
1254
- // Preliminary tests
1258
+ // Setup
1255
1259
  div.setAttribute( "className", "t" );
1256
1260
  div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
1257
1261
 
1262
+ // Support tests won't run in some limited or non-browser environments
1258
1263
  all = div.getElementsByTagName("*");
1259
1264
  a = div.getElementsByTagName("a")[ 0 ];
1260
- a.style.cssText = "top:1px;float:left;opacity:.5";
1261
-
1262
- // Can't get basic test support
1263
- if ( !all || !all.length || !a ) {
1265
+ if ( !all || !a || !all.length ) {
1264
1266
  return {};
1265
1267
  }
1266
1268
 
1267
- // First batch of supports tests
1269
+ // First batch of tests
1268
1270
  select = document.createElement("select");
1269
1271
  opt = select.appendChild( document.createElement("option") );
1270
1272
  input = div.getElementsByTagName("input")[ 0 ];
1271
1273
 
1274
+ a.style.cssText = "top:1px;float:left;opacity:.5";
1272
1275
  support = {
1273
1276
  // IE strips leading whitespace when .innerHTML is used
1274
1277
  leadingWhitespace: ( div.firstChild.nodeType === 3 ),
@@ -1310,7 +1313,7 @@ jQuery.support = (function() {
1310
1313
  // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1311
1314
  getSetAttribute: div.className !== "t",
1312
1315
 
1313
- // Tests for enctype support on a form(#6743)
1316
+ // Tests for enctype support on a form (#6743)
1314
1317
  enctype: !!document.createElement("form").enctype,
1315
1318
 
1316
1319
  // Makes sure cloning an html5 element does not cause problems
@@ -1452,10 +1455,8 @@ jQuery.support = (function() {
1452
1455
  support.boxSizing = ( div.offsetWidth === 4 );
1453
1456
  support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 );
1454
1457
 
1455
- // NOTE: To any future maintainer, window.getComputedStyle was used here
1456
- // instead of getComputedStyle because it gave a better gzip size.
1457
- // The difference between window.getComputedStyle and getComputedStyle is
1458
- // 7 bytes
1458
+ // NOTE: To any future maintainer, we've window.getComputedStyle
1459
+ // because jsdom on node.js will break without it.
1459
1460
  if ( window.getComputedStyle ) {
1460
1461
  support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
1461
1462
  support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
@@ -1505,7 +1506,7 @@ jQuery.support = (function() {
1505
1506
 
1506
1507
  return support;
1507
1508
  })();
1508
- var rbrace = /^(?:\{.*\}|\[.*\])$/,
1509
+ var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
1509
1510
  rmultiDash = /([A-Z])/g;
1510
1511
 
1511
1512
  jQuery.extend({
@@ -1513,7 +1514,7 @@ jQuery.extend({
1513
1514
 
1514
1515
  deletedIds: [],
1515
1516
 
1516
- // Please use with caution
1517
+ // Remove at next major release (1.9/2.0)
1517
1518
  uuid: 0,
1518
1519
 
1519
1520
  // Unique for each copy of jQuery on the page
@@ -1565,7 +1566,7 @@ jQuery.extend({
1565
1566
  // Only DOM nodes need a new unique ID for each element since their data
1566
1567
  // ends up in the global cache
1567
1568
  if ( isNode ) {
1568
- elem[ internalKey ] = id = jQuery.deletedIds.pop() || ++jQuery.uuid;
1569
+ elem[ internalKey ] = id = jQuery.deletedIds.pop() || jQuery.guid++;
1569
1570
  } else {
1570
1571
  id = internalKey;
1571
1572
  }
@@ -1739,7 +1740,7 @@ jQuery.fn.extend({
1739
1740
  for ( l = attr.length; i < l; i++ ) {
1740
1741
  name = attr[i].name;
1741
1742
 
1742
- if ( name.indexOf( "data-" ) === 0 ) {
1743
+ if ( !name.indexOf( "data-" ) ) {
1743
1744
  name = jQuery.camelCase( name.substring(5) );
1744
1745
 
1745
1746
  dataAttr( elem, name, data[ name ] );
@@ -1868,6 +1869,7 @@ jQuery.extend({
1868
1869
  type = type || "fx";
1869
1870
 
1870
1871
  var queue = jQuery.queue( elem, type ),
1872
+ startLength = queue.length,
1871
1873
  fn = queue.shift(),
1872
1874
  hooks = jQuery._queueHooks( elem, type ),
1873
1875
  next = function() {
@@ -1877,6 +1879,7 @@ jQuery.extend({
1877
1879
  // If the fx queue is dequeued, always remove the progress sentinel
1878
1880
  if ( fn === "inprogress" ) {
1879
1881
  fn = queue.shift();
1882
+ startLength--;
1880
1883
  }
1881
1884
 
1882
1885
  if ( fn ) {
@@ -1891,7 +1894,8 @@ jQuery.extend({
1891
1894
  delete hooks.stop;
1892
1895
  fn.call( elem, next, hooks );
1893
1896
  }
1894
- if ( !queue.length && hooks ) {
1897
+
1898
+ if ( !startLength && hooks ) {
1895
1899
  hooks.empty.fire();
1896
1900
  }
1897
1901
  },
@@ -1977,7 +1981,8 @@ jQuery.fn.extend({
1977
1981
  type = type || "fx";
1978
1982
 
1979
1983
  while( i-- ) {
1980
- if ( (tmp = jQuery._data( elements[ i ], type + "queueHooks" )) && tmp.empty ) {
1984
+ tmp = jQuery._data( elements[ i ], type + "queueHooks" );
1985
+ if ( tmp && tmp.empty ) {
1981
1986
  count++;
1982
1987
  tmp.empty.add( resolve );
1983
1988
  }
@@ -2045,7 +2050,7 @@ jQuery.fn.extend({
2045
2050
  setClass = " " + elem.className + " ";
2046
2051
 
2047
2052
  for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2048
- if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
2053
+ if ( setClass.indexOf( " " + classNames[ c ] + " " ) < 0 ) {
2049
2054
  setClass += classNames[ c ] + " ";
2050
2055
  }
2051
2056
  }
@@ -2078,7 +2083,7 @@ jQuery.fn.extend({
2078
2083
  // loop over each item in the removal list
2079
2084
  for ( c = 0, cl = removes.length; c < cl; c++ ) {
2080
2085
  // Remove until there is nothing to remove,
2081
- while ( className.indexOf(" " + removes[ c ] + " ") > -1 ) {
2086
+ while ( className.indexOf(" " + removes[ c ] + " ") >= 0 ) {
2082
2087
  className = className.replace( " " + removes[ c ] + " " , " " );
2083
2088
  }
2084
2089
  }
@@ -2132,7 +2137,7 @@ jQuery.fn.extend({
2132
2137
  i = 0,
2133
2138
  l = this.length;
2134
2139
  for ( ; i < l; i++ ) {
2135
- if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
2140
+ if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
2136
2141
  return true;
2137
2142
  }
2138
2143
  }
@@ -2213,26 +2218,25 @@ jQuery.extend({
2213
2218
  },
2214
2219
  select: {
2215
2220
  get: function( elem ) {
2216
- var value, i, max, option,
2217
- index = elem.selectedIndex,
2218
- values = [],
2221
+ var value, option,
2219
2222
  options = elem.options,
2220
- one = elem.type === "select-one";
2221
-
2222
- // Nothing was selected
2223
- if ( index < 0 ) {
2224
- return null;
2225
- }
2223
+ index = elem.selectedIndex,
2224
+ one = elem.type === "select-one" || index < 0,
2225
+ values = one ? null : [],
2226
+ max = one ? index + 1 : options.length,
2227
+ i = index < 0 ?
2228
+ max :
2229
+ one ? index : 0;
2226
2230
 
2227
2231
  // Loop through all the selected options
2228
- i = one ? index : 0;
2229
- max = one ? index + 1 : options.length;
2230
2232
  for ( ; i < max; i++ ) {
2231
2233
  option = options[ i ];
2232
2234
 
2233
- // Don't return options that are disabled or in a disabled optgroup
2234
- if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
2235
- (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
2235
+ // oldIE doesn't update selected after form reset (#2551)
2236
+ if ( ( option.selected || i === index ) &&
2237
+ // Don't return options that are disabled or in a disabled optgroup
2238
+ ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
2239
+ ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
2236
2240
 
2237
2241
  // Get the specific value for the option
2238
2242
  value = jQuery( option ).val();
@@ -2247,11 +2251,6 @@ jQuery.extend({
2247
2251
  }
2248
2252
  }
2249
2253
 
2250
- // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
2251
- if ( one && !values.length && options.length ) {
2252
- return jQuery( options[ index ] ).val();
2253
- }
2254
-
2255
2254
  return values;
2256
2255
  },
2257
2256
 
@@ -2310,7 +2309,7 @@ jQuery.extend({
2310
2309
  return ret;
2311
2310
 
2312
2311
  } else {
2313
- elem.setAttribute( name, "" + value );
2312
+ elem.setAttribute( name, value + "" );
2314
2313
  return value;
2315
2314
  }
2316
2315
 
@@ -2574,7 +2573,7 @@ if ( !jQuery.support.style ) {
2574
2573
  return elem.style.cssText.toLowerCase() || undefined;
2575
2574
  },
2576
2575
  set: function( elem, value ) {
2577
- return ( elem.style.cssText = "" + value );
2576
+ return ( elem.style.cssText = value + "" );
2578
2577
  }
2579
2578
  };
2580
2579
  }
@@ -2707,6 +2706,7 @@ jQuery.event = {
2707
2706
  handler: handler,
2708
2707
  guid: handler.guid,
2709
2708
  selector: selector,
2709
+ needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
2710
2710
  namespace: namespaces.join(".")
2711
2711
  }, handleObjIn );
2712
2712
 
@@ -2942,7 +2942,7 @@ jQuery.event = {
2942
2942
  }
2943
2943
  // Note that this is a bare JS function and not a jQuery handler
2944
2944
  handle = ontype && cur[ ontype ];
2945
- if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) {
2945
+ if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
2946
2946
  event.preventDefault();
2947
2947
  }
2948
2948
  }
@@ -2987,10 +2987,10 @@ jQuery.event = {
2987
2987
  // Make a writable jQuery.Event from the native event object
2988
2988
  event = jQuery.event.fix( event || window.event );
2989
2989
 
2990
- var i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related,
2990
+ var i, j, cur, ret, selMatch, matched, matches, handleObj, sel, related,
2991
2991
  handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
2992
2992
  delegateCount = handlers.delegateCount,
2993
- args = [].slice.call( arguments ),
2993
+ args = core_slice.call( arguments ),
2994
2994
  run_all = !event.exclusive && !event.namespace,
2995
2995
  special = jQuery.event.special[ event.type ] || {},
2996
2996
  handlerQueue = [];
@@ -3008,23 +3008,20 @@ jQuery.event = {
3008
3008
  // Avoid non-left-click bubbling in Firefox (#3861)
3009
3009
  if ( delegateCount && !(event.button && event.type === "click") ) {
3010
3010
 
3011
- // Pregenerate a single jQuery object for reuse with .is()
3012
- jqcur = jQuery(this);
3013
- jqcur.context = this;
3014
-
3015
3011
  for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
3016
3012
 
3017
- // Don't process clicks (ONLY) on disabled elements (#6911, #8165, #xxxx)
3013
+ // Don't process clicks (ONLY) on disabled elements (#6911, #8165, #11382, #11764)
3018
3014
  if ( cur.disabled !== true || event.type !== "click" ) {
3019
3015
  selMatch = {};
3020
3016
  matches = [];
3021
- jqcur[0] = cur;
3022
3017
  for ( i = 0; i < delegateCount; i++ ) {
3023
3018
  handleObj = handlers[ i ];
3024
3019
  sel = handleObj.selector;
3025
3020
 
3026
3021
  if ( selMatch[ sel ] === undefined ) {
3027
- selMatch[ sel ] = jqcur.is( sel );
3022
+ selMatch[ sel ] = handleObj.needsContext ?
3023
+ jQuery( sel, this ).index( cur ) >= 0 :
3024
+ jQuery.find( sel, this, null, [ cur ] ).length;
3028
3025
  }
3029
3026
  if ( selMatch[ sel ] ) {
3030
3027
  matches.push( handleObj );
@@ -3165,11 +3162,6 @@ jQuery.event = {
3165
3162
  },
3166
3163
 
3167
3164
  special: {
3168
- ready: {
3169
- // Make sure the ready event is setup
3170
- setup: jQuery.bindReady
3171
- },
3172
-
3173
3165
  load: {
3174
3166
  // Prevent triggered image.load events from bubbling to window.load
3175
3167
  noBubble: true
@@ -3236,7 +3228,7 @@ jQuery.removeEvent = document.removeEventListener ?
3236
3228
 
3237
3229
  if ( elem.detachEvent ) {
3238
3230
 
3239
- // #8545, #7054, preventing memory leaks for custom events in IE6-8
3231
+ // #8545, #7054, preventing memory leaks for custom events in IE6-8
3240
3232
  // detachEvent needed property on element, by name of that event, to properly expose it to GC
3241
3233
  if ( typeof elem[ name ] === "undefined" ) {
3242
3234
  elem[ name ] = null;
@@ -3458,7 +3450,7 @@ if ( !jQuery.support.changeBubbles ) {
3458
3450
  teardown: function() {
3459
3451
  jQuery.event.remove( this, "._change" );
3460
3452
 
3461
- return rformElems.test( this.nodeName );
3453
+ return !rformElems.test( this.nodeName );
3462
3454
  }
3463
3455
  };
3464
3456
  }
@@ -3599,7 +3591,7 @@ jQuery.fn.extend({
3599
3591
  },
3600
3592
  undelegate: function( selector, types, fn ) {
3601
3593
  // ( namespace ) or ( selector, types [, fn] )
3602
- return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
3594
+ return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
3603
3595
  },
3604
3596
 
3605
3597
  trigger: function( type, data ) {
@@ -3670,29 +3662,72 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl
3670
3662
  });
3671
3663
  /*!
3672
3664
  * Sizzle CSS Selector Engine
3673
- * Copyright 2012 jQuery Foundation and other contributors
3674
- * Released under the MIT license
3675
- * http://sizzlejs.com/
3665
+ * Copyright 2012 jQuery Foundation and other contributors
3666
+ * Released under the MIT license
3667
+ * http://sizzlejs.com/
3676
3668
  */
3677
3669
  (function( window, undefined ) {
3678
3670
 
3679
3671
  var cachedruns,
3680
- dirruns,
3681
- sortOrder,
3682
- siblingCheck,
3683
3672
  assertGetIdNotName,
3673
+ Expr,
3674
+ getText,
3675
+ isXML,
3676
+ contains,
3677
+ compile,
3678
+ sortOrder,
3679
+ hasDuplicate,
3680
+ outermostContext,
3681
+
3682
+ baseHasDuplicate = true,
3683
+ strundefined = "undefined",
3684
+
3685
+ expando = ( "sizcache" + Math.random() ).replace( ".", "" ),
3684
3686
 
3687
+ Token = String,
3685
3688
  document = window.document,
3686
3689
  docElem = document.documentElement,
3687
-
3688
- strundefined = "undefined",
3689
- hasDuplicate = false,
3690
- baseHasDuplicate = true,
3690
+ dirruns = 0,
3691
3691
  done = 0,
3692
- slice = [].slice,
3692
+ pop = [].pop,
3693
3693
  push = [].push,
3694
+ slice = [].slice,
3695
+ // Use a stripped-down indexOf if a native one is unavailable
3696
+ indexOf = [].indexOf || function( elem ) {
3697
+ var i = 0,
3698
+ len = this.length;
3699
+ for ( ; i < len; i++ ) {
3700
+ if ( this[i] === elem ) {
3701
+ return i;
3702
+ }
3703
+ }
3704
+ return -1;
3705
+ },
3694
3706
 
3695
- expando = ( "sizcache" + Math.random() ).replace( ".", "" ),
3707
+ // Augment a function for special use by Sizzle
3708
+ markFunction = function( fn, value ) {
3709
+ fn[ expando ] = value == null || value;
3710
+ return fn;
3711
+ },
3712
+
3713
+ createCache = function() {
3714
+ var cache = {},
3715
+ keys = [];
3716
+
3717
+ return markFunction(function( key, value ) {
3718
+ // Only keep the most recent entries
3719
+ if ( keys.push( key ) > Expr.cacheLength ) {
3720
+ delete cache[ keys.shift() ];
3721
+ }
3722
+
3723
+ // Retrieve with (key + " ") to avoid collision with native Object.prototype properties (see Issue #157)
3724
+ return (cache[ key + " " ] = value);
3725
+ }, cache );
3726
+ },
3727
+
3728
+ classCache = createCache(),
3729
+ tokenCache = createCache(),
3730
+ compilerCache = createCache(),
3696
3731
 
3697
3732
  // Regex
3698
3733
 
@@ -3710,29 +3745,29 @@ var cachedruns,
3710
3745
  operators = "([*^$|!~]?=)",
3711
3746
  attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
3712
3747
  "*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
3713
- pseudos = ":(" + characterEncoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|((?:[^,]|\\\\,|(?:,(?=[^\\[]*\\]))|(?:,(?=[^\\(]*\\))))*))\\)|)",
3714
- pos = ":(nth|eq|gt|lt|first|last|even|odd)(?:\\((\\d*)\\)|)(?=[^-]|$)",
3715
- combinators = whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*",
3716
- groups = "(?=[^\\x20\\t\\r\\n\\f])(?:\\\\.|" + attributes + "|" + pseudos.replace( 2, 7 ) + "|[^\\\\(),])+",
3717
-
3718
- // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
3719
- rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
3720
3748
 
3721
- rcombinators = new RegExp( "^" + combinators ),
3749
+ // Prefer arguments not in parens/brackets,
3750
+ // then attribute selectors and non-pseudos (denoted by :),
3751
+ // then anything else
3752
+ // These preferences are here to reduce the number of selectors
3753
+ // needing tokenize in the PSEUDO preFilter
3754
+ pseudos = ":(" + characterEncoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + attributes + ")|[^:]|\\\\.)*|.*))\\)|)",
3722
3755
 
3723
- // All simple (non-comma) selectors, excluding insignifant trailing whitespace
3724
- rgroups = new RegExp( groups + "?(?=" + whitespace + "*,|$)", "g" ),
3756
+ // For matchExpr.POS and matchExpr.needsContext
3757
+ pos = ":(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
3758
+ "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)",
3725
3759
 
3726
- // A selector, or everything after leading whitespace
3727
- // Optionally followed in either case by a ")" for terminating sub-selectors
3728
- rselector = new RegExp( "^(?:(?!,)(?:(?:^|,)" + whitespace + "*" + groups + ")*?|" + whitespace + "*(.*?))(\\)|$)" ),
3760
+ // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
3761
+ rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
3729
3762
 
3730
- // All combinators and selector components (attribute test, tag, pseudo, etc.), the latter appearing together when consecutive
3731
- rtokens = new RegExp( groups.slice( 19, -6 ) + "\\x20\\t\\r\\n\\f>+~])+|" + combinators, "g" ),
3763
+ rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
3764
+ rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ),
3765
+ rpseudo = new RegExp( pseudos ),
3732
3766
 
3733
3767
  // Easily-parseable/retrievable ID or TAG or CLASS selectors
3734
3768
  rquickExpr = /^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,
3735
3769
 
3770
+ rnot = /^:not/,
3736
3771
  rsibling = /[\x20\t\r\n\f]*[+~]/,
3737
3772
  rendsWithNot = /:not\($/,
3738
3773
 
@@ -3745,56 +3780,46 @@ var cachedruns,
3745
3780
  "ID": new RegExp( "^#(" + characterEncoding + ")" ),
3746
3781
  "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
3747
3782
  "NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ),
3748
- "TAG": new RegExp( "^(" + characterEncoding.replace( "[-", "[-\\*" ) + ")" ),
3783
+ "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
3749
3784
  "ATTR": new RegExp( "^" + attributes ),
3750
3785
  "PSEUDO": new RegExp( "^" + pseudos ),
3751
- "CHILD": new RegExp( "^:(only|nth|last|first)-child(?:\\(" + whitespace +
3786
+ "POS": new RegExp( pos, "i" ),
3787
+ "CHILD": new RegExp( "^:(only|nth|first|last)-child(?:\\(" + whitespace +
3752
3788
  "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
3753
3789
  "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
3754
- "POS": new RegExp( pos, "ig" ),
3755
3790
  // For use in libraries implementing .is()
3756
3791
  "needsContext": new RegExp( "^" + whitespace + "*[>+~]|" + pos, "i" )
3757
3792
  },
3758
3793
 
3759
- classCache = {},
3760
- cachedClasses = [],
3761
- compilerCache = {},
3762
- cachedSelectors = [],
3763
-
3764
- // Mark a function for use in filtering
3765
- markFunction = function( fn ) {
3766
- fn.sizzleFilter = true;
3767
- return fn;
3768
- },
3769
-
3770
- // Returns a function to use in pseudos for input types
3771
- createInputFunction = function( type ) {
3772
- return function( elem ) {
3773
- // Check the input's nodeName and type
3774
- return elem.nodeName.toLowerCase() === "input" && elem.type === type;
3775
- };
3776
- },
3777
-
3778
- // Returns a function to use in pseudos for buttons
3779
- createButtonFunction = function( type ) {
3780
- return function( elem ) {
3781
- var name = elem.nodeName.toLowerCase();
3782
- return (name === "input" || name === "button") && elem.type === type;
3783
- };
3784
- },
3794
+ // Support
3785
3795
 
3786
3796
  // Used for testing something on an element
3787
3797
  assert = function( fn ) {
3788
- var pass = false,
3789
- div = document.createElement("div");
3798
+ var div = document.createElement("div");
3799
+
3790
3800
  try {
3791
- pass = fn( div );
3792
- } catch (e) {}
3793
- // release memory in IE
3794
- div = null;
3795
- return pass;
3801
+ return fn( div );
3802
+ } catch (e) {
3803
+ return false;
3804
+ } finally {
3805
+ // release memory in IE
3806
+ div = null;
3807
+ }
3796
3808
  },
3797
3809
 
3810
+ // Check if getElementsByTagName("*") returns only elements
3811
+ assertTagNameNoComments = assert(function( div ) {
3812
+ div.appendChild( document.createComment("") );
3813
+ return !div.getElementsByTagName("*").length;
3814
+ }),
3815
+
3816
+ // Check if getAttribute returns normalized href attributes
3817
+ assertHrefNotNormalized = assert(function( div ) {
3818
+ div.innerHTML = "<a href='#'></a>";
3819
+ return div.firstChild && typeof div.firstChild.getAttribute !== strundefined &&
3820
+ div.firstChild.getAttribute("href") === "#";
3821
+ }),
3822
+
3798
3823
  // Check if attributes should be retrieved by attribute nodes
3799
3824
  assertAttributes = assert(function( div ) {
3800
3825
  div.innerHTML = "<select></select>";
@@ -3803,6 +3828,19 @@ var cachedruns,
3803
3828
  return type !== "boolean" && type !== "string";
3804
3829
  }),
3805
3830
 
3831
+ // Check if getElementsByClassName can be trusted
3832
+ assertUsableClassName = assert(function( div ) {
3833
+ // Opera can't find a second classname (in 9.6)
3834
+ div.innerHTML = "<div class='hidden e'></div><div class='hidden'></div>";
3835
+ if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) {
3836
+ return false;
3837
+ }
3838
+
3839
+ // Safari 3.2 caches class attributes and doesn't catch changes
3840
+ div.lastChild.className = "e";
3841
+ return div.getElementsByClassName("e").length === 2;
3842
+ }),
3843
+
3806
3844
  // Check if getElementById returns elements by name
3807
3845
  // Check if getElementsByName privileges form controls or returns elements by ID
3808
3846
  assertUsableName = assert(function( div ) {
@@ -3814,58 +3852,45 @@ var cachedruns,
3814
3852
  // Test
3815
3853
  var pass = document.getElementsByName &&
3816
3854
  // buggy browsers will return fewer than the correct 2
3817
- document.getElementsByName( expando ).length ===
3855
+ document.getElementsByName( expando ).length === 2 +
3818
3856
  // buggy browsers will return more than the correct 0
3819
- 2 + document.getElementsByName( expando + 0 ).length;
3857
+ document.getElementsByName( expando + 0 ).length;
3820
3858
  assertGetIdNotName = !document.getElementById( expando );
3821
3859
 
3822
3860
  // Cleanup
3823
3861
  docElem.removeChild( div );
3824
3862
 
3825
3863
  return pass;
3826
- }),
3827
-
3828
- // Check if the browser returns only elements
3829
- // when doing getElementsByTagName("*")
3830
- assertTagNameNoComments = assert(function( div ) {
3831
- div.appendChild( document.createComment("") );
3832
- return div.getElementsByTagName("*").length === 0;
3833
- }),
3834
-
3835
- // Check if getAttribute returns normalized href attributes
3836
- assertHrefNotNormalized = assert(function( div ) {
3837
- div.innerHTML = "<a href='#'></a>";
3838
- return div.firstChild && typeof div.firstChild.getAttribute !== strundefined &&
3839
- div.firstChild.getAttribute("href") === "#";
3840
- }),
3864
+ });
3841
3865
 
3842
- // Check if getElementsByClassName can be trusted
3843
- assertUsableClassName = assert(function( div ) {
3844
- // Opera can't find a second classname (in 9.6)
3845
- div.innerHTML = "<div class='hidden e'></div><div class='hidden'></div>";
3846
- if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
3847
- return false;
3866
+ // If slice is not available, provide a backup
3867
+ try {
3868
+ slice.call( docElem.childNodes, 0 )[0].nodeType;
3869
+ } catch ( e ) {
3870
+ slice = function( i ) {
3871
+ var elem,
3872
+ results = [];
3873
+ for ( ; (elem = this[i]); i++ ) {
3874
+ results.push( elem );
3848
3875
  }
3876
+ return results;
3877
+ };
3878
+ }
3849
3879
 
3850
- // Safari caches class attributes, doesn't catch changes (in 3.2)
3851
- div.lastChild.className = "e";
3852
- return div.getElementsByClassName("e").length !== 1;
3853
- });
3854
-
3855
- var Sizzle = function( selector, context, results, seed ) {
3880
+ function Sizzle( selector, context, results, seed ) {
3856
3881
  results = results || [];
3857
3882
  context = context || document;
3858
3883
  var match, elem, xml, m,
3859
3884
  nodeType = context.nodeType;
3860
3885
 
3861
- if ( nodeType !== 1 && nodeType !== 9 ) {
3862
- return [];
3863
- }
3864
-
3865
3886
  if ( !selector || typeof selector !== "string" ) {
3866
3887
  return results;
3867
3888
  }
3868
3889
 
3890
+ if ( nodeType !== 1 && nodeType !== 9 ) {
3891
+ return [];
3892
+ }
3893
+
3869
3894
  xml = isXML( context );
3870
3895
 
3871
3896
  if ( !xml && !seed ) {
@@ -3909,22 +3934,158 @@ var Sizzle = function( selector, context, results, seed ) {
3909
3934
  }
3910
3935
 
3911
3936
  // All others
3912
- return select( selector, context, results, seed, xml );
3937
+ return select( selector.replace( rtrim, "$1" ), context, results, seed, xml );
3938
+ }
3939
+
3940
+ Sizzle.matches = function( expr, elements ) {
3941
+ return Sizzle( expr, null, null, elements );
3913
3942
  };
3914
3943
 
3915
- var Expr = Sizzle.selectors = {
3944
+ Sizzle.matchesSelector = function( elem, expr ) {
3945
+ return Sizzle( expr, null, null, [ elem ] ).length > 0;
3946
+ };
3916
3947
 
3917
- // Can be adjusted by the user
3918
- cacheLength: 50,
3948
+ // Returns a function to use in pseudos for input types
3949
+ function createInputPseudo( type ) {
3950
+ return function( elem ) {
3951
+ var name = elem.nodeName.toLowerCase();
3952
+ return name === "input" && elem.type === type;
3953
+ };
3954
+ }
3919
3955
 
3920
- match: matchExpr,
3956
+ // Returns a function to use in pseudos for buttons
3957
+ function createButtonPseudo( type ) {
3958
+ return function( elem ) {
3959
+ var name = elem.nodeName.toLowerCase();
3960
+ return (name === "input" || name === "button") && elem.type === type;
3961
+ };
3962
+ }
3963
+
3964
+ // Returns a function to use in pseudos for positionals
3965
+ function createPositionalPseudo( fn ) {
3966
+ return markFunction(function( argument ) {
3967
+ argument = +argument;
3968
+ return markFunction(function( seed, matches ) {
3969
+ var j,
3970
+ matchIndexes = fn( [], seed.length, argument ),
3971
+ i = matchIndexes.length;
3972
+
3973
+ // Match elements found at the specified indexes
3974
+ while ( i-- ) {
3975
+ if ( seed[ (j = matchIndexes[i]) ] ) {
3976
+ seed[j] = !(matches[j] = seed[j]);
3977
+ }
3978
+ }
3979
+ });
3980
+ });
3981
+ }
3982
+
3983
+ /**
3984
+ * Utility function for retrieving the text value of an array of DOM nodes
3985
+ * @param {Array|Element} elem
3986
+ */
3987
+ getText = Sizzle.getText = function( elem ) {
3988
+ var node,
3989
+ ret = "",
3990
+ i = 0,
3991
+ nodeType = elem.nodeType;
3992
+
3993
+ if ( nodeType ) {
3994
+ if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
3995
+ // Use textContent for elements
3996
+ // innerText usage removed for consistency of new lines (see #11153)
3997
+ if ( typeof elem.textContent === "string" ) {
3998
+ return elem.textContent;
3999
+ } else {
4000
+ // Traverse its children
4001
+ for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
4002
+ ret += getText( elem );
4003
+ }
4004
+ }
4005
+ } else if ( nodeType === 3 || nodeType === 4 ) {
4006
+ return elem.nodeValue;
4007
+ }
4008
+ // Do not include comment or processing instruction nodes
4009
+ } else {
3921
4010
 
3922
- order: [ "ID", "TAG" ],
4011
+ // If no nodeType, this is expected to be an array
4012
+ for ( ; (node = elem[i]); i++ ) {
4013
+ // Do not traverse comment nodes
4014
+ ret += getText( node );
4015
+ }
4016
+ }
4017
+ return ret;
4018
+ };
3923
4019
 
3924
- attrHandle: {},
4020
+ isXML = Sizzle.isXML = function( elem ) {
4021
+ // documentElement is verified for cases where it doesn't yet exist
4022
+ // (such as loading iframes in IE - #4833)
4023
+ var documentElement = elem && (elem.ownerDocument || elem).documentElement;
4024
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
4025
+ };
4026
+
4027
+ // Element contains another
4028
+ contains = Sizzle.contains = docElem.contains ?
4029
+ function( a, b ) {
4030
+ var adown = a.nodeType === 9 ? a.documentElement : a,
4031
+ bup = b && b.parentNode;
4032
+ return a === bup || !!( bup && bup.nodeType === 1 && adown.contains && adown.contains(bup) );
4033
+ } :
4034
+ docElem.compareDocumentPosition ?
4035
+ function( a, b ) {
4036
+ return b && !!( a.compareDocumentPosition( b ) & 16 );
4037
+ } :
4038
+ function( a, b ) {
4039
+ while ( (b = b.parentNode) ) {
4040
+ if ( b === a ) {
4041
+ return true;
4042
+ }
4043
+ }
4044
+ return false;
4045
+ };
4046
+
4047
+ Sizzle.attr = function( elem, name ) {
4048
+ var val,
4049
+ xml = isXML( elem );
4050
+
4051
+ if ( !xml ) {
4052
+ name = name.toLowerCase();
4053
+ }
4054
+ if ( (val = Expr.attrHandle[ name ]) ) {
4055
+ return val( elem );
4056
+ }
4057
+ if ( xml || assertAttributes ) {
4058
+ return elem.getAttribute( name );
4059
+ }
4060
+ val = elem.getAttributeNode( name );
4061
+ return val ?
4062
+ typeof elem[ name ] === "boolean" ?
4063
+ elem[ name ] ? name : null :
4064
+ val.specified ? val.value : null :
4065
+ null;
4066
+ };
4067
+
4068
+ Expr = Sizzle.selectors = {
4069
+
4070
+ // Can be adjusted by the user
4071
+ cacheLength: 50,
3925
4072
 
3926
4073
  createPseudo: markFunction,
3927
4074
 
4075
+ match: matchExpr,
4076
+
4077
+ // IE6/7 return a modified href
4078
+ attrHandle: assertHrefNotNormalized ?
4079
+ {} :
4080
+ {
4081
+ "href": function( elem ) {
4082
+ return elem.getAttribute( "href", 2 );
4083
+ },
4084
+ "type": function( elem ) {
4085
+ return elem.getAttribute("type");
4086
+ }
4087
+ },
4088
+
3928
4089
  find: {
3929
4090
  "ID": assertGetIdNotName ?
3930
4091
  function( id, context, xml ) {
@@ -3971,7 +4132,19 @@ var Expr = Sizzle.selectors = {
3971
4132
  return tmp;
3972
4133
  }
3973
4134
  return results;
4135
+ },
4136
+
4137
+ "NAME": assertUsableName && function( tag, context ) {
4138
+ if ( typeof context.getElementsByName !== strundefined ) {
4139
+ return context.getElementsByName( name );
3974
4140
  }
4141
+ },
4142
+
4143
+ "CLASS": assertUsableClassName && function( className, context, xml ) {
4144
+ if ( typeof context.getElementsByClassName !== strundefined && !xml ) {
4145
+ return context.getElementsByClassName( className );
4146
+ }
4147
+ }
3975
4148
  },
3976
4149
 
3977
4150
  relative: {
@@ -3996,7 +4169,7 @@ var Expr = Sizzle.selectors = {
3996
4169
  },
3997
4170
 
3998
4171
  "CHILD": function( match ) {
3999
- /* matches from matchExpr.CHILD
4172
+ /* matches from matchExpr["CHILD"]
4000
4173
  1 type (only|nth|...)
4001
4174
  2 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
4002
4175
  3 xn-component of xn+y argument ([+-]?\d*n|)
@@ -4027,24 +4200,30 @@ var Expr = Sizzle.selectors = {
4027
4200
  },
4028
4201
 
4029
4202
  "PSEUDO": function( match ) {
4030
- var argument,
4031
- unquoted = match[4];
4032
-
4203
+ var unquoted, excess;
4033
4204
  if ( matchExpr["CHILD"].test( match[0] ) ) {
4034
4205
  return null;
4035
4206
  }
4036
4207
 
4037
- // Relinquish our claim on characters in `unquoted` from a closing parenthesis on
4038
- if ( unquoted && (argument = rselector.exec( unquoted )) && argument.pop() ) {
4039
-
4040
- match[0] = match[0].slice( 0, argument[0].length - unquoted.length - 1 );
4041
- unquoted = argument[0].slice( 0, -1 );
4208
+ if ( match[3] ) {
4209
+ match[2] = match[3];
4210
+ } else if ( (unquoted = match[4]) ) {
4211
+ // Only check arguments that contain a pseudo
4212
+ if ( rpseudo.test(unquoted) &&
4213
+ // Get excess from tokenize (recursively)
4214
+ (excess = tokenize( unquoted, true )) &&
4215
+ // advance to the next closing parenthesis
4216
+ (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
4217
+
4218
+ // excess is a negative index
4219
+ unquoted = unquoted.slice( 0, excess );
4220
+ match[0] = match[0].slice( 0, excess );
4221
+ }
4222
+ match[2] = unquoted;
4042
4223
  }
4043
4224
 
4044
- // Quoted or unquoted, we have the full argument
4045
4225
  // Return only captures needed by the pseudo filter method (type and argument)
4046
- match.splice( 2, 3, unquoted || match[3] );
4047
- return match;
4226
+ return match.slice( 0, 3 );
4048
4227
  }
4049
4228
  },
4050
4229
 
@@ -4076,91 +4255,65 @@ var Expr = Sizzle.selectors = {
4076
4255
  },
4077
4256
 
4078
4257
  "CLASS": function( className ) {
4079
- var pattern = classCache[ className ];
4080
- if ( !pattern ) {
4081
- pattern = classCache[ className ] = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" );
4082
- cachedClasses.push( className );
4083
- // Avoid too large of a cache
4084
- if ( cachedClasses.length > Expr.cacheLength ) {
4085
- delete classCache[ cachedClasses.shift() ];
4086
- }
4087
- }
4088
- return function( elem ) {
4089
- return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" );
4090
- };
4258
+ var pattern = classCache[ expando ][ className + " " ];
4259
+
4260
+ return pattern ||
4261
+ (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
4262
+ classCache( className, function( elem ) {
4263
+ return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" );
4264
+ });
4091
4265
  },
4092
4266
 
4093
4267
  "ATTR": function( name, operator, check ) {
4094
- if ( !operator ) {
4095
- return function( elem ) {
4096
- return Sizzle.attr( elem, name ) != null;
4097
- };
4098
- }
4099
-
4100
- return function( elem ) {
4101
- var result = Sizzle.attr( elem, name ),
4102
- value = result + "";
4268
+ return function( elem, context ) {
4269
+ var result = Sizzle.attr( elem, name );
4103
4270
 
4104
4271
  if ( result == null ) {
4105
4272
  return operator === "!=";
4106
4273
  }
4107
-
4108
- switch ( operator ) {
4109
- case "=":
4110
- return value === check;
4111
- case "!=":
4112
- return value !== check;
4113
- case "^=":
4114
- return check && value.indexOf( check ) === 0;
4115
- case "*=":
4116
- return check && value.indexOf( check ) > -1;
4117
- case "$=":
4118
- return check && value.substr( value.length - check.length ) === check;
4119
- case "~=":
4120
- return ( " " + value + " " ).indexOf( check ) > -1;
4121
- case "|=":
4122
- return value === check || value.substr( 0, check.length + 1 ) === check + "-";
4274
+ if ( !operator ) {
4275
+ return true;
4123
4276
  }
4277
+
4278
+ result += "";
4279
+
4280
+ return operator === "=" ? result === check :
4281
+ operator === "!=" ? result !== check :
4282
+ operator === "^=" ? check && result.indexOf( check ) === 0 :
4283
+ operator === "*=" ? check && result.indexOf( check ) > -1 :
4284
+ operator === "$=" ? check && result.substr( result.length - check.length ) === check :
4285
+ operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
4286
+ operator === "|=" ? result === check || result.substr( 0, check.length + 1 ) === check + "-" :
4287
+ false;
4124
4288
  };
4125
4289
  },
4126
4290
 
4127
4291
  "CHILD": function( type, argument, first, last ) {
4128
4292
 
4129
4293
  if ( type === "nth" ) {
4130
- var doneName = done++;
4131
-
4132
4294
  return function( elem ) {
4133
- var parent, diff,
4134
- count = 0,
4135
- node = elem;
4295
+ var node, diff,
4296
+ parent = elem.parentNode;
4136
4297
 
4137
4298
  if ( first === 1 && last === 0 ) {
4138
4299
  return true;
4139
4300
  }
4140
4301
 
4141
- parent = elem.parentNode;
4142
-
4143
- if ( parent && (parent[ expando ] !== doneName || !elem.sizset) ) {
4302
+ if ( parent ) {
4303
+ diff = 0;
4144
4304
  for ( node = parent.firstChild; node; node = node.nextSibling ) {
4145
4305
  if ( node.nodeType === 1 ) {
4146
- node.sizset = ++count;
4147
- if ( node === elem ) {
4306
+ diff++;
4307
+ if ( elem === node ) {
4148
4308
  break;
4149
4309
  }
4150
4310
  }
4151
4311
  }
4152
-
4153
- parent[ expando ] = doneName;
4154
4312
  }
4155
4313
 
4156
- diff = elem.sizset - last;
4157
-
4158
- if ( first === 0 ) {
4159
- return diff === 0;
4160
-
4161
- } else {
4162
- return ( diff % first === 0 && diff / first >= 0 );
4163
- }
4314
+ // Incorporate the offset (or cast to NaN), then check against cycle size
4315
+ diff -= last;
4316
+ return diff === first || ( diff % first === 0 && diff / first >= 0 );
4164
4317
  };
4165
4318
  }
4166
4319
 
@@ -4195,35 +4348,82 @@ var Expr = Sizzle.selectors = {
4195
4348
  };
4196
4349
  },
4197
4350
 
4198
- "PSEUDO": function( pseudo, argument, context, xml ) {
4351
+ "PSEUDO": function( pseudo, argument ) {
4199
4352
  // pseudo-class names are case-insensitive
4200
4353
  // http://www.w3.org/TR/selectors/#pseudo-classes
4201
4354
  // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
4202
- var fn = Expr.pseudos[ pseudo ] || Expr.pseudos[ pseudo.toLowerCase() ];
4355
+ // Remember that setFilters inherits from pseudos
4356
+ var args,
4357
+ fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
4358
+ Sizzle.error( "unsupported pseudo: " + pseudo );
4203
4359
 
4204
- if ( !fn ) {
4205
- Sizzle.error( "unsupported pseudo: " + pseudo );
4360
+ // The user may use createPseudo to indicate that
4361
+ // arguments are needed to create the filter function
4362
+ // just as Sizzle does
4363
+ if ( fn[ expando ] ) {
4364
+ return fn( argument );
4206
4365
  }
4207
4366
 
4208
- // The user may set fn.sizzleFilter to indicate
4209
- // that arguments are needed to create the filter function
4210
- // just as Sizzle does
4211
- if ( !fn.sizzleFilter ) {
4212
- return fn;
4367
+ // But maintain support for old signatures
4368
+ if ( fn.length > 1 ) {
4369
+ args = [ pseudo, pseudo, "", argument ];
4370
+ return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
4371
+ markFunction(function( seed, matches ) {
4372
+ var idx,
4373
+ matched = fn( seed, argument ),
4374
+ i = matched.length;
4375
+ while ( i-- ) {
4376
+ idx = indexOf.call( seed, matched[i] );
4377
+ seed[ idx ] = !( matches[ idx ] = matched[i] );
4378
+ }
4379
+ }) :
4380
+ function( elem ) {
4381
+ return fn( elem, 0, args );
4382
+ };
4213
4383
  }
4214
4384
 
4215
- return fn( argument, context, xml );
4385
+ return fn;
4216
4386
  }
4217
4387
  },
4218
4388
 
4219
4389
  pseudos: {
4220
- "not": markFunction(function( selector, context, xml ) {
4390
+ "not": markFunction(function( selector ) {
4221
4391
  // Trim the selector passed to compile
4222
4392
  // to avoid treating leading and trailing
4223
4393
  // spaces as combinators
4224
- var matcher = compile( selector.replace( rtrim, "$1" ), context, xml );
4394
+ var input = [],
4395
+ results = [],
4396
+ matcher = compile( selector.replace( rtrim, "$1" ) );
4397
+
4398
+ return matcher[ expando ] ?
4399
+ markFunction(function( seed, matches, context, xml ) {
4400
+ var elem,
4401
+ unmatched = matcher( seed, null, xml, [] ),
4402
+ i = seed.length;
4403
+
4404
+ // Match elements unmatched by `matcher`
4405
+ while ( i-- ) {
4406
+ if ( (elem = unmatched[i]) ) {
4407
+ seed[i] = !(matches[i] = elem);
4408
+ }
4409
+ }
4410
+ }) :
4411
+ function( elem, context, xml ) {
4412
+ input[0] = elem;
4413
+ matcher( input, null, xml, results );
4414
+ return !results.pop();
4415
+ };
4416
+ }),
4417
+
4418
+ "has": markFunction(function( selector ) {
4225
4419
  return function( elem ) {
4226
- return !matcher( elem );
4420
+ return Sizzle( selector, elem ).length > 0;
4421
+ };
4422
+ }),
4423
+
4424
+ "contains": markFunction(function( text ) {
4425
+ return function( elem ) {
4426
+ return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
4227
4427
  };
4228
4428
  }),
4229
4429
 
@@ -4273,18 +4473,6 @@ var Expr = Sizzle.selectors = {
4273
4473
  return true;
4274
4474
  },
4275
4475
 
4276
- "contains": markFunction(function( text ) {
4277
- return function( elem ) {
4278
- return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
4279
- };
4280
- }),
4281
-
4282
- "has": markFunction(function( selector ) {
4283
- return function( elem ) {
4284
- return Sizzle( selector, elem ).length > 0;
4285
- };
4286
- }),
4287
-
4288
4476
  "header": function( elem ) {
4289
4477
  return rheader.test( elem.nodeName );
4290
4478
  },
@@ -4299,14 +4487,14 @@ var Expr = Sizzle.selectors = {
4299
4487
  },
4300
4488
 
4301
4489
  // Input types
4302
- "radio": createInputFunction("radio"),
4303
- "checkbox": createInputFunction("checkbox"),
4304
- "file": createInputFunction("file"),
4305
- "password": createInputFunction("password"),
4306
- "image": createInputFunction("image"),
4490
+ "radio": createInputPseudo("radio"),
4491
+ "checkbox": createInputPseudo("checkbox"),
4492
+ "file": createInputPseudo("file"),
4493
+ "password": createInputPseudo("password"),
4494
+ "image": createInputPseudo("image"),
4307
4495
 
4308
- "submit": createButtonFunction("submit"),
4309
- "reset": createButtonFunction("reset"),
4496
+ "submit": createButtonPseudo("submit"),
4497
+ "reset": createButtonPseudo("reset"),
4310
4498
 
4311
4499
  "button": function( elem ) {
4312
4500
  var name = elem.nodeName.toLowerCase();
@@ -4319,210 +4507,76 @@ var Expr = Sizzle.selectors = {
4319
4507
 
4320
4508
  "focus": function( elem ) {
4321
4509
  var doc = elem.ownerDocument;
4322
- return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus()) && !!(elem.type || elem.href);
4510
+ return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
4323
4511
  },
4324
4512
 
4325
4513
  "active": function( elem ) {
4326
4514
  return elem === elem.ownerDocument.activeElement;
4327
- }
4328
- },
4329
-
4330
- setFilters: {
4331
- "first": function( elements, argument, not ) {
4332
- return not ? elements.slice( 1 ) : [ elements[0] ];
4333
- },
4334
-
4335
- "last": function( elements, argument, not ) {
4336
- var elem = elements.pop();
4337
- return not ? elements : [ elem ];
4338
- },
4339
-
4340
- "even": function( elements, argument, not ) {
4341
- var results = [],
4342
- i = not ? 1 : 0,
4343
- len = elements.length;
4344
- for ( ; i < len; i = i + 2 ) {
4345
- results.push( elements[i] );
4346
- }
4347
- return results;
4348
- },
4349
-
4350
- "odd": function( elements, argument, not ) {
4351
- var results = [],
4352
- i = not ? 0 : 1,
4353
- len = elements.length;
4354
- for ( ; i < len; i = i + 2 ) {
4355
- results.push( elements[i] );
4356
- }
4357
- return results;
4358
- },
4359
-
4360
- "lt": function( elements, argument, not ) {
4361
- return not ? elements.slice( +argument ) : elements.slice( 0, +argument );
4362
- },
4363
-
4364
- "gt": function( elements, argument, not ) {
4365
- return not ? elements.slice( 0, +argument + 1 ) : elements.slice( +argument + 1 );
4366
- },
4367
-
4368
- "eq": function( elements, argument, not ) {
4369
- var elem = elements.splice( +argument, 1 );
4370
- return not ? elements : elem;
4371
- }
4372
- }
4373
- };
4374
-
4375
- // Deprecated
4376
- Expr.setFilters["nth"] = Expr.setFilters["eq"];
4377
-
4378
- // Back-compat
4379
- Expr.filters = Expr.pseudos;
4380
-
4381
- // IE6/7 return a modified href
4382
- if ( !assertHrefNotNormalized ) {
4383
- Expr.attrHandle = {
4384
- "href": function( elem ) {
4385
- return elem.getAttribute( "href", 2 );
4386
4515
  },
4387
- "type": function( elem ) {
4388
- return elem.getAttribute("type");
4389
- }
4390
- };
4391
- }
4392
-
4393
- // Add getElementsByName if usable
4394
- if ( assertUsableName ) {
4395
- Expr.order.push("NAME");
4396
- Expr.find["NAME"] = function( name, context ) {
4397
- if ( typeof context.getElementsByName !== strundefined ) {
4398
- return context.getElementsByName( name );
4399
- }
4400
- };
4401
- }
4402
-
4403
- // Add getElementsByClassName if usable
4404
- if ( assertUsableClassName ) {
4405
- Expr.order.splice( 1, 0, "CLASS" );
4406
- Expr.find["CLASS"] = function( className, context, xml ) {
4407
- if ( typeof context.getElementsByClassName !== strundefined && !xml ) {
4408
- return context.getElementsByClassName( className );
4409
- }
4410
- };
4411
- }
4412
-
4413
- // If slice is not available, provide a backup
4414
- try {
4415
- slice.call( docElem.childNodes, 0 )[0].nodeType;
4416
- } catch ( e ) {
4417
- slice = function( i ) {
4418
- var elem, results = [];
4419
- for ( ; (elem = this[i]); i++ ) {
4420
- results.push( elem );
4421
- }
4422
- return results;
4423
- };
4424
- }
4425
4516
 
4426
- var isXML = Sizzle.isXML = function( elem ) {
4427
- // documentElement is verified for cases where it doesn't yet exist
4428
- // (such as loading iframes in IE - #4833)
4429
- var documentElement = elem && (elem.ownerDocument || elem).documentElement;
4430
- return documentElement ? documentElement.nodeName !== "HTML" : false;
4431
- };
4517
+ // Positional types
4518
+ "first": createPositionalPseudo(function() {
4519
+ return [ 0 ];
4520
+ }),
4432
4521
 
4433
- // Element contains another
4434
- var contains = Sizzle.contains = docElem.compareDocumentPosition ?
4435
- function( a, b ) {
4436
- return !!( a.compareDocumentPosition( b ) & 16 );
4437
- } :
4438
- docElem.contains ?
4439
- function( a, b ) {
4440
- var adown = a.nodeType === 9 ? a.documentElement : a,
4441
- bup = b.parentNode;
4442
- return a === bup || !!( bup && bup.nodeType === 1 && adown.contains && adown.contains(bup) );
4443
- } :
4444
- function( a, b ) {
4445
- while ( (b = b.parentNode) ) {
4446
- if ( b === a ) {
4447
- return true;
4448
- }
4449
- }
4450
- return false;
4451
- };
4522
+ "last": createPositionalPseudo(function( matchIndexes, length ) {
4523
+ return [ length - 1 ];
4524
+ }),
4452
4525
 
4453
- /**
4454
- * Utility function for retrieving the text value of an array of DOM nodes
4455
- * @param {Array|Element} elem
4456
- */
4457
- var getText = Sizzle.getText = function( elem ) {
4458
- var node,
4459
- ret = "",
4460
- i = 0,
4461
- nodeType = elem.nodeType;
4526
+ "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
4527
+ return [ argument < 0 ? argument + length : argument ];
4528
+ }),
4462
4529
 
4463
- if ( nodeType ) {
4464
- if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
4465
- // Use textContent for elements
4466
- // innerText usage removed for consistency of new lines (see #11153)
4467
- if ( typeof elem.textContent === "string" ) {
4468
- return elem.textContent;
4469
- } else {
4470
- // Traverse its children
4471
- for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
4472
- ret += getText( elem );
4473
- }
4530
+ "even": createPositionalPseudo(function( matchIndexes, length ) {
4531
+ for ( var i = 0; i < length; i += 2 ) {
4532
+ matchIndexes.push( i );
4474
4533
  }
4475
- } else if ( nodeType === 3 || nodeType === 4 ) {
4476
- return elem.nodeValue;
4477
- }
4478
- // Do not include comment or processing instruction nodes
4479
- } else {
4534
+ return matchIndexes;
4535
+ }),
4480
4536
 
4481
- // If no nodeType, this is expected to be an array
4482
- for ( ; (node = elem[i]); i++ ) {
4483
- // Do not traverse comment nodes
4484
- ret += getText( node );
4485
- }
4486
- }
4487
- return ret;
4488
- };
4537
+ "odd": createPositionalPseudo(function( matchIndexes, length ) {
4538
+ for ( var i = 1; i < length; i += 2 ) {
4539
+ matchIndexes.push( i );
4540
+ }
4541
+ return matchIndexes;
4542
+ }),
4489
4543
 
4490
- Sizzle.attr = function( elem, name ) {
4491
- var attr,
4492
- xml = isXML( elem );
4544
+ "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
4545
+ for ( var i = argument < 0 ? argument + length : argument; --i >= 0; ) {
4546
+ matchIndexes.push( i );
4547
+ }
4548
+ return matchIndexes;
4549
+ }),
4493
4550
 
4494
- if ( !xml ) {
4495
- name = name.toLowerCase();
4496
- }
4497
- if ( Expr.attrHandle[ name ] ) {
4498
- return Expr.attrHandle[ name ]( elem );
4499
- }
4500
- if ( assertAttributes || xml ) {
4501
- return elem.getAttribute( name );
4551
+ "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
4552
+ for ( var i = argument < 0 ? argument + length : argument; ++i < length; ) {
4553
+ matchIndexes.push( i );
4554
+ }
4555
+ return matchIndexes;
4556
+ })
4502
4557
  }
4503
- attr = elem.getAttributeNode( name );
4504
- return attr ?
4505
- typeof elem[ name ] === "boolean" ?
4506
- elem[ name ] ? name : null :
4507
- attr.specified ? attr.value : null :
4508
- null;
4509
4558
  };
4510
4559
 
4511
- Sizzle.error = function( msg ) {
4512
- throw new Error( "Syntax error, unrecognized expression: " + msg );
4513
- };
4560
+ function siblingCheck( a, b, ret ) {
4561
+ if ( a === b ) {
4562
+ return ret;
4563
+ }
4564
+
4565
+ var cur = a.nextSibling;
4566
+
4567
+ while ( cur ) {
4568
+ if ( cur === b ) {
4569
+ return -1;
4570
+ }
4514
4571
 
4515
- // Check if the JavaScript engine is using some sort of
4516
- // optimization where it does not always call our comparision
4517
- // function. If that is the case, discard the hasDuplicate value.
4518
- // Thus far that includes Google Chrome.
4519
- [0, 0].sort(function() {
4520
- return (baseHasDuplicate = 0);
4521
- });
4572
+ cur = cur.nextSibling;
4573
+ }
4522
4574
 
4575
+ return 1;
4576
+ }
4523
4577
 
4524
- if ( docElem.compareDocumentPosition ) {
4525
- sortOrder = function( a, b ) {
4578
+ sortOrder = docElem.compareDocumentPosition ?
4579
+ function( a, b ) {
4526
4580
  if ( a === b ) {
4527
4581
  hasDuplicate = true;
4528
4582
  return 0;
@@ -4532,10 +4586,8 @@ if ( docElem.compareDocumentPosition ) {
4532
4586
  a.compareDocumentPosition :
4533
4587
  a.compareDocumentPosition(b) & 4
4534
4588
  ) ? -1 : 1;
4535
- };
4536
-
4537
- } else {
4538
- sortOrder = function( a, b ) {
4589
+ } :
4590
+ function( a, b ) {
4539
4591
  // The nodes are identical, we can exit early
4540
4592
  if ( a === b ) {
4541
4593
  hasDuplicate = true;
@@ -4595,397 +4647,532 @@ if ( docElem.compareDocumentPosition ) {
4595
4647
  siblingCheck( ap[i], b, 1 );
4596
4648
  };
4597
4649
 
4598
- siblingCheck = function( a, b, ret ) {
4599
- if ( a === b ) {
4600
- return ret;
4601
- }
4602
-
4603
- var cur = a.nextSibling;
4604
-
4605
- while ( cur ) {
4606
- if ( cur === b ) {
4607
- return -1;
4608
- }
4609
-
4610
- cur = cur.nextSibling;
4611
- }
4612
-
4613
- return 1;
4614
- };
4615
- }
4650
+ // Always assume the presence of duplicates if sort doesn't
4651
+ // pass them to our comparison function (as in Google Chrome).
4652
+ [0, 0].sort( sortOrder );
4653
+ baseHasDuplicate = !hasDuplicate;
4616
4654
 
4617
4655
  // Document sorting and removing duplicates
4618
4656
  Sizzle.uniqueSort = function( results ) {
4619
4657
  var elem,
4620
- i = 1;
4658
+ duplicates = [],
4659
+ i = 1,
4660
+ j = 0;
4621
4661
 
4622
- if ( sortOrder ) {
4623
- hasDuplicate = baseHasDuplicate;
4624
- results.sort( sortOrder );
4662
+ hasDuplicate = baseHasDuplicate;
4663
+ results.sort( sortOrder );
4625
4664
 
4626
- if ( hasDuplicate ) {
4627
- for ( ; (elem = results[i]); i++ ) {
4628
- if ( elem === results[ i - 1 ] ) {
4629
- results.splice( i--, 1 );
4630
- }
4665
+ if ( hasDuplicate ) {
4666
+ for ( ; (elem = results[i]); i++ ) {
4667
+ if ( elem === results[ i - 1 ] ) {
4668
+ j = duplicates.push( i );
4631
4669
  }
4632
4670
  }
4671
+ while ( j-- ) {
4672
+ results.splice( duplicates[ j ], 1 );
4673
+ }
4633
4674
  }
4634
4675
 
4635
4676
  return results;
4636
4677
  };
4637
4678
 
4638
- function multipleContexts( selector, contexts, results, seed ) {
4639
- var i = 0,
4640
- len = contexts.length;
4641
- for ( ; i < len; i++ ) {
4642
- Sizzle( selector, contexts[i], results, seed );
4643
- }
4644
- }
4645
-
4646
- function handlePOSGroup( selector, posfilter, argument, contexts, seed, not ) {
4647
- var results,
4648
- fn = Expr.setFilters[ posfilter.toLowerCase() ];
4679
+ Sizzle.error = function( msg ) {
4680
+ throw new Error( "Syntax error, unrecognized expression: " + msg );
4681
+ };
4649
4682
 
4650
- if ( !fn ) {
4651
- Sizzle.error( posfilter );
4652
- }
4683
+ function tokenize( selector, parseOnly ) {
4684
+ var matched, match, tokens, type,
4685
+ soFar, groups, preFilters,
4686
+ cached = tokenCache[ expando ][ selector + " " ];
4653
4687
 
4654
- if ( selector || !(results = seed) ) {
4655
- multipleContexts( selector || "*", contexts, (results = []), seed );
4688
+ if ( cached ) {
4689
+ return parseOnly ? 0 : cached.slice( 0 );
4656
4690
  }
4657
4691
 
4658
- return results.length > 0 ? fn( results, argument, not ) : [];
4659
- }
4660
-
4661
- function handlePOS( selector, context, results, seed, groups ) {
4662
- var match, not, anchor, ret, elements, currentContexts, part, lastIndex,
4663
- i = 0,
4664
- len = groups.length,
4665
- rpos = matchExpr["POS"],
4666
- // This is generated here in case matchExpr["POS"] is extended
4667
- rposgroups = new RegExp( "^" + rpos.source + "(?!" + whitespace + ")", "i" ),
4668
- // This is for making sure non-participating
4669
- // matching groups are represented cross-browser (IE6-8)
4670
- setUndefined = function() {
4671
- var i = 1,
4672
- len = arguments.length - 2;
4673
- for ( ; i < len; i++ ) {
4674
- if ( arguments[i] === undefined ) {
4675
- match[i] = undefined;
4676
- }
4677
- }
4678
- };
4679
-
4680
- for ( ; i < len; i++ ) {
4681
- // Reset regex index to 0
4682
- rpos.exec("");
4683
- selector = groups[i];
4684
- ret = [];
4685
- anchor = 0;
4686
- elements = seed;
4687
- while ( (match = rpos.exec( selector )) ) {
4688
- lastIndex = rpos.lastIndex = match.index + match[0].length;
4689
- if ( lastIndex > anchor ) {
4690
- part = selector.slice( anchor, match.index );
4691
- anchor = lastIndex;
4692
- currentContexts = [ context ];
4693
-
4694
- if ( rcombinators.test(part) ) {
4695
- if ( elements ) {
4696
- currentContexts = elements;
4697
- }
4698
- elements = seed;
4699
- }
4700
-
4701
- if ( (not = rendsWithNot.test( part )) ) {
4702
- part = part.slice( 0, -5 ).replace( rcombinators, "$&*" );
4703
- }
4704
-
4705
- if ( match.length > 1 ) {
4706
- match[0].replace( rposgroups, setUndefined );
4707
- }
4708
- elements = handlePOSGroup( part, match[1], match[2], currentContexts, elements, not );
4709
- }
4710
- }
4692
+ soFar = selector;
4693
+ groups = [];
4694
+ preFilters = Expr.preFilter;
4711
4695
 
4712
- if ( elements ) {
4713
- ret = ret.concat( elements );
4696
+ while ( soFar ) {
4714
4697
 
4715
- if ( (part = selector.slice( anchor )) && part !== ")" ) {
4716
- if ( rcombinators.test(part) ) {
4717
- multipleContexts( part, ret, results, seed );
4718
- } else {
4719
- Sizzle( part, context, results, seed ? seed.concat(elements) : elements );
4720
- }
4721
- } else {
4722
- push.apply( results, ret );
4698
+ // Comma and first run
4699
+ if ( !matched || (match = rcomma.exec( soFar )) ) {
4700
+ if ( match ) {
4701
+ // Don't consume trailing commas as valid
4702
+ soFar = soFar.slice( match[0].length ) || soFar;
4723
4703
  }
4724
- } else {
4725
- Sizzle( selector, context, results, seed );
4704
+ groups.push( tokens = [] );
4726
4705
  }
4727
- }
4728
4706
 
4729
- // Do not sort if this is a single filter
4730
- return len === 1 ? results : Sizzle.uniqueSort( results );
4731
- }
4732
-
4733
- function tokenize( selector, context, xml ) {
4734
- var tokens, soFar, type,
4735
- groups = [],
4736
- i = 0,
4737
-
4738
- // Catch obvious selector issues: terminal ")"; nonempty fallback match
4739
- // rselector never fails to match *something*
4740
- match = rselector.exec( selector ),
4741
- matched = !match.pop() && !match.pop(),
4742
- selectorGroups = matched && selector.match( rgroups ) || [""],
4707
+ matched = false;
4743
4708
 
4744
- preFilters = Expr.preFilter,
4745
- filters = Expr.filter,
4746
- checkContext = !xml && context !== document;
4709
+ // Combinators
4710
+ if ( (match = rcombinators.exec( soFar )) ) {
4711
+ tokens.push( matched = new Token( match.shift() ) );
4712
+ soFar = soFar.slice( matched.length );
4747
4713
 
4748
- for ( ; (soFar = selectorGroups[i]) != null && matched; i++ ) {
4749
- groups.push( tokens = [] );
4750
-
4751
- // Need to make sure we're within a narrower context if necessary
4752
- // Adding a descendant combinator will generate what is needed
4753
- if ( checkContext ) {
4754
- soFar = " " + soFar;
4714
+ // Cast descendant combinators to space
4715
+ matched.type = match[0].replace( rtrim, " " );
4755
4716
  }
4756
4717
 
4757
- while ( soFar ) {
4758
- matched = false;
4759
-
4760
- // Combinators
4761
- if ( (match = rcombinators.exec( soFar )) ) {
4762
- soFar = soFar.slice( match[0].length );
4763
-
4764
- // Cast descendant combinators to space
4765
- matched = tokens.push({ part: match.pop().replace( rtrim, " " ), captures: match });
4766
- }
4767
-
4768
- // Filters
4769
- for ( type in filters ) {
4770
- if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
4771
- (match = preFilters[ type ]( match, context, xml )) ) ) {
4772
-
4773
- soFar = soFar.slice( match.shift().length );
4774
- matched = tokens.push({ part: type, captures: match });
4775
- }
4776
- }
4718
+ // Filters
4719
+ for ( type in Expr.filter ) {
4720
+ if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
4721
+ (match = preFilters[ type ]( match ))) ) {
4777
4722
 
4778
- if ( !matched ) {
4779
- break;
4723
+ tokens.push( matched = new Token( match.shift() ) );
4724
+ soFar = soFar.slice( matched.length );
4725
+ matched.type = type;
4726
+ matched.matches = match;
4780
4727
  }
4781
4728
  }
4782
- }
4783
4729
 
4784
- if ( !matched ) {
4785
- Sizzle.error( selector );
4730
+ if ( !matched ) {
4731
+ break;
4732
+ }
4786
4733
  }
4787
4734
 
4788
- return groups;
4735
+ // Return the length of the invalid excess
4736
+ // if we're just parsing
4737
+ // Otherwise, throw an error or return tokens
4738
+ return parseOnly ?
4739
+ soFar.length :
4740
+ soFar ?
4741
+ Sizzle.error( selector ) :
4742
+ // Cache the tokens
4743
+ tokenCache( selector, groups ).slice( 0 );
4789
4744
  }
4790
4745
 
4791
- function addCombinator( matcher, combinator, context ) {
4746
+ function addCombinator( matcher, combinator, base ) {
4792
4747
  var dir = combinator.dir,
4748
+ checkNonElements = base && combinator.dir === "parentNode",
4793
4749
  doneName = done++;
4794
4750
 
4795
- if ( !matcher ) {
4796
- // If there is no matcher to check, check against the context
4797
- matcher = function( elem ) {
4798
- return elem === context;
4799
- };
4800
- }
4801
4751
  return combinator.first ?
4802
- function( elem, context ) {
4752
+ // Check against closest ancestor/preceding element
4753
+ function( elem, context, xml ) {
4803
4754
  while ( (elem = elem[ dir ]) ) {
4804
- if ( elem.nodeType === 1 ) {
4805
- return matcher( elem, context ) && elem;
4755
+ if ( checkNonElements || elem.nodeType === 1 ) {
4756
+ return matcher( elem, context, xml );
4806
4757
  }
4807
4758
  }
4808
4759
  } :
4809
- function( elem, context ) {
4810
- var cache,
4811
- dirkey = doneName + "." + dirruns,
4812
- cachedkey = dirkey + "." + cachedruns;
4813
- while ( (elem = elem[ dir ]) ) {
4814
- if ( elem.nodeType === 1 ) {
4815
- if ( (cache = elem[ expando ]) === cachedkey ) {
4816
- return elem.sizset;
4817
- } else if ( typeof cache === "string" && cache.indexOf(dirkey) === 0 ) {
4818
- if ( elem.sizset ) {
4819
- return elem;
4760
+
4761
+ // Check against all ancestor/preceding elements
4762
+ function( elem, context, xml ) {
4763
+ // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
4764
+ if ( !xml ) {
4765
+ var cache,
4766
+ dirkey = dirruns + " " + doneName + " ",
4767
+ cachedkey = dirkey + cachedruns;
4768
+ while ( (elem = elem[ dir ]) ) {
4769
+ if ( checkNonElements || elem.nodeType === 1 ) {
4770
+ if ( (cache = elem[ expando ]) === cachedkey ) {
4771
+ return elem.sizset;
4772
+ } else if ( typeof cache === "string" && cache.indexOf(dirkey) === 0 ) {
4773
+ if ( elem.sizset ) {
4774
+ return elem;
4775
+ }
4776
+ } else {
4777
+ elem[ expando ] = cachedkey;
4778
+ if ( matcher( elem, context, xml ) ) {
4779
+ elem.sizset = true;
4780
+ return elem;
4781
+ }
4782
+ elem.sizset = false;
4820
4783
  }
4821
- } else {
4822
- elem[ expando ] = cachedkey;
4823
- if ( matcher( elem, context ) ) {
4824
- elem.sizset = true;
4784
+ }
4785
+ }
4786
+ } else {
4787
+ while ( (elem = elem[ dir ]) ) {
4788
+ if ( checkNonElements || elem.nodeType === 1 ) {
4789
+ if ( matcher( elem, context, xml ) ) {
4825
4790
  return elem;
4826
4791
  }
4827
- elem.sizset = false;
4828
4792
  }
4829
4793
  }
4830
4794
  }
4831
4795
  };
4832
4796
  }
4833
4797
 
4834
- function addMatcher( higher, deeper ) {
4835
- return higher ?
4836
- function( elem, context ) {
4837
- var result = deeper( elem, context );
4838
- return result && higher( result === true ? elem : result, context );
4798
+ function elementMatcher( matchers ) {
4799
+ return matchers.length > 1 ?
4800
+ function( elem, context, xml ) {
4801
+ var i = matchers.length;
4802
+ while ( i-- ) {
4803
+ if ( !matchers[i]( elem, context, xml ) ) {
4804
+ return false;
4805
+ }
4806
+ }
4807
+ return true;
4839
4808
  } :
4840
- deeper;
4809
+ matchers[0];
4841
4810
  }
4842
4811
 
4843
- // ["TAG", ">", "ID", " ", "CLASS"]
4844
- function matcherFromTokens( tokens, context, xml ) {
4845
- var token, matcher,
4846
- i = 0;
4812
+ function condense( unmatched, map, filter, context, xml ) {
4813
+ var elem,
4814
+ newUnmatched = [],
4815
+ i = 0,
4816
+ len = unmatched.length,
4817
+ mapped = map != null;
4847
4818
 
4848
- for ( ; (token = tokens[i]); i++ ) {
4849
- if ( Expr.relative[ token.part ] ) {
4850
- matcher = addCombinator( matcher, Expr.relative[ token.part ], context );
4851
- } else {
4852
- token.captures.push( context, xml );
4853
- matcher = addMatcher( matcher, Expr.filter[ token.part ].apply( null, token.captures ) );
4819
+ for ( ; i < len; i++ ) {
4820
+ if ( (elem = unmatched[i]) ) {
4821
+ if ( !filter || filter( elem, context, xml ) ) {
4822
+ newUnmatched.push( elem );
4823
+ if ( mapped ) {
4824
+ map.push( i );
4825
+ }
4826
+ }
4854
4827
  }
4855
4828
  }
4856
4829
 
4857
- return matcher;
4830
+ return newUnmatched;
4858
4831
  }
4859
4832
 
4860
- function matcherFromGroupMatchers( matchers ) {
4861
- return function( elem, context ) {
4862
- var matcher,
4863
- j = 0;
4864
- for ( ; (matcher = matchers[j]); j++ ) {
4865
- if ( matcher(elem, context) ) {
4866
- return true;
4867
- }
4833
+ function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
4834
+ if ( postFilter && !postFilter[ expando ] ) {
4835
+ postFilter = setMatcher( postFilter );
4836
+ }
4837
+ if ( postFinder && !postFinder[ expando ] ) {
4838
+ postFinder = setMatcher( postFinder, postSelector );
4839
+ }
4840
+ return markFunction(function( seed, results, context, xml ) {
4841
+ var temp, i, elem,
4842
+ preMap = [],
4843
+ postMap = [],
4844
+ preexisting = results.length,
4845
+
4846
+ // Get initial elements from seed or context
4847
+ elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
4848
+
4849
+ // Prefilter to get matcher input, preserving a map for seed-results synchronization
4850
+ matcherIn = preFilter && ( seed || !selector ) ?
4851
+ condense( elems, preMap, preFilter, context, xml ) :
4852
+ elems,
4853
+
4854
+ matcherOut = matcher ?
4855
+ // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
4856
+ postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
4857
+
4858
+ // ...intermediate processing is necessary
4859
+ [] :
4860
+
4861
+ // ...otherwise use results directly
4862
+ results :
4863
+ matcherIn;
4864
+
4865
+ // Find primary matches
4866
+ if ( matcher ) {
4867
+ matcher( matcherIn, matcherOut, context, xml );
4868
4868
  }
4869
- return false;
4870
- };
4871
- }
4872
4869
 
4873
- var compile = Sizzle.compile = function( selector, context, xml ) {
4874
- var tokens, group, i,
4875
- cached = compilerCache[ selector ];
4870
+ // Apply postFilter
4871
+ if ( postFilter ) {
4872
+ temp = condense( matcherOut, postMap );
4873
+ postFilter( temp, [], context, xml );
4876
4874
 
4877
- // Return a cached group function if already generated (context dependent)
4878
- if ( cached && cached.context === context ) {
4879
- return cached;
4880
- }
4875
+ // Un-match failing elements by moving them back to matcherIn
4876
+ i = temp.length;
4877
+ while ( i-- ) {
4878
+ if ( (elem = temp[i]) ) {
4879
+ matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
4880
+ }
4881
+ }
4882
+ }
4881
4883
 
4882
- // Generate a function of recursive functions that can be used to check each element
4883
- group = tokenize( selector, context, xml );
4884
- for ( i = 0; (tokens = group[i]); i++ ) {
4885
- group[i] = matcherFromTokens( tokens, context, xml );
4886
- }
4884
+ if ( seed ) {
4885
+ if ( postFinder || preFilter ) {
4886
+ if ( postFinder ) {
4887
+ // Get the final matcherOut by condensing this intermediate into postFinder contexts
4888
+ temp = [];
4889
+ i = matcherOut.length;
4890
+ while ( i-- ) {
4891
+ if ( (elem = matcherOut[i]) ) {
4892
+ // Restore matcherIn since elem is not yet a final match
4893
+ temp.push( (matcherIn[i] = elem) );
4894
+ }
4895
+ }
4896
+ postFinder( null, (matcherOut = []), temp, xml );
4897
+ }
4887
4898
 
4888
- // Cache the compiled function
4889
- cached = compilerCache[ selector ] = matcherFromGroupMatchers( group );
4890
- cached.context = context;
4891
- cached.runs = cached.dirruns = 0;
4892
- cachedSelectors.push( selector );
4893
- // Ensure only the most recent are cached
4894
- if ( cachedSelectors.length > Expr.cacheLength ) {
4895
- delete compilerCache[ cachedSelectors.shift() ];
4896
- }
4897
- return cached;
4898
- };
4899
+ // Move matched elements from seed to results to keep them synchronized
4900
+ i = matcherOut.length;
4901
+ while ( i-- ) {
4902
+ if ( (elem = matcherOut[i]) &&
4903
+ (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
4899
4904
 
4900
- Sizzle.matches = function( expr, elements ) {
4901
- return Sizzle( expr, null, null, elements );
4902
- };
4905
+ seed[temp] = !(results[temp] = elem);
4906
+ }
4907
+ }
4908
+ }
4903
4909
 
4904
- Sizzle.matchesSelector = function( elem, expr ) {
4905
- return Sizzle( expr, null, null, [ elem ] ).length > 0;
4906
- };
4910
+ // Add elements to results, through postFinder if defined
4911
+ } else {
4912
+ matcherOut = condense(
4913
+ matcherOut === results ?
4914
+ matcherOut.splice( preexisting, matcherOut.length ) :
4915
+ matcherOut
4916
+ );
4917
+ if ( postFinder ) {
4918
+ postFinder( null, results, matcherOut, xml );
4919
+ } else {
4920
+ push.apply( results, matcherOut );
4921
+ }
4922
+ }
4923
+ });
4924
+ }
4907
4925
 
4908
- var select = function( selector, context, results, seed, xml ) {
4909
- // Remove excessive whitespace
4910
- selector = selector.replace( rtrim, "$1" );
4911
- var elements, matcher, i, len, elem, token,
4912
- type, findContext, notTokens,
4913
- match = selector.match( rgroups ),
4914
- tokens = selector.match( rtokens ),
4915
- contextNodeType = context.nodeType;
4916
-
4917
- // POS handling
4918
- if ( matchExpr["POS"].test(selector) ) {
4919
- return handlePOS( selector, context, results, seed, match );
4926
+ function matcherFromTokens( tokens ) {
4927
+ var checkContext, matcher, j,
4928
+ len = tokens.length,
4929
+ leadingRelative = Expr.relative[ tokens[0].type ],
4930
+ implicitRelative = leadingRelative || Expr.relative[" "],
4931
+ i = leadingRelative ? 1 : 0,
4932
+
4933
+ // The foundational matcher ensures that elements are reachable from top-level context(s)
4934
+ matchContext = addCombinator( function( elem ) {
4935
+ return elem === checkContext;
4936
+ }, implicitRelative, true ),
4937
+ matchAnyContext = addCombinator( function( elem ) {
4938
+ return indexOf.call( checkContext, elem ) > -1;
4939
+ }, implicitRelative, true ),
4940
+ matchers = [ function( elem, context, xml ) {
4941
+ return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
4942
+ (checkContext = context).nodeType ?
4943
+ matchContext( elem, context, xml ) :
4944
+ matchAnyContext( elem, context, xml ) );
4945
+ } ];
4946
+
4947
+ for ( ; i < len; i++ ) {
4948
+ if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
4949
+ matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
4950
+ } else {
4951
+ matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
4952
+
4953
+ // Return special upon seeing a positional matcher
4954
+ if ( matcher[ expando ] ) {
4955
+ // Find the next relative operator (if any) for proper handling
4956
+ j = ++i;
4957
+ for ( ; j < len; j++ ) {
4958
+ if ( Expr.relative[ tokens[j].type ] ) {
4959
+ break;
4960
+ }
4961
+ }
4962
+ return setMatcher(
4963
+ i > 1 && elementMatcher( matchers ),
4964
+ i > 1 && tokens.slice( 0, i - 1 ).join("").replace( rtrim, "$1" ),
4965
+ matcher,
4966
+ i < j && matcherFromTokens( tokens.slice( i, j ) ),
4967
+ j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
4968
+ j < len && tokens.join("")
4969
+ );
4970
+ }
4971
+ matchers.push( matcher );
4972
+ }
4920
4973
  }
4921
4974
 
4922
- if ( seed ) {
4923
- elements = slice.call( seed, 0 );
4975
+ return elementMatcher( matchers );
4976
+ }
4977
+
4978
+ function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
4979
+ var bySet = setMatchers.length > 0,
4980
+ byElement = elementMatchers.length > 0,
4981
+ superMatcher = function( seed, context, xml, results, expandContext ) {
4982
+ var elem, j, matcher,
4983
+ setMatched = [],
4984
+ matchedCount = 0,
4985
+ i = "0",
4986
+ unmatched = seed && [],
4987
+ outermost = expandContext != null,
4988
+ contextBackup = outermostContext,
4989
+ // We must always have either seed elements or context
4990
+ elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
4991
+ // Nested matchers should use non-integer dirruns
4992
+ dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.E);
4993
+
4994
+ if ( outermost ) {
4995
+ outermostContext = context !== document && context;
4996
+ cachedruns = superMatcher.el;
4997
+ }
4924
4998
 
4925
- // To maintain document order, only narrow the
4926
- // set if there is one group
4927
- } else if ( match && match.length === 1 ) {
4999
+ // Add elements passing elementMatchers directly to results
5000
+ for ( ; (elem = elems[i]) != null; i++ ) {
5001
+ if ( byElement && elem ) {
5002
+ for ( j = 0; (matcher = elementMatchers[j]); j++ ) {
5003
+ if ( matcher( elem, context, xml ) ) {
5004
+ results.push( elem );
5005
+ break;
5006
+ }
5007
+ }
5008
+ if ( outermost ) {
5009
+ dirruns = dirrunsUnique;
5010
+ cachedruns = ++superMatcher.el;
5011
+ }
5012
+ }
4928
5013
 
4929
- // Take a shortcut and set the context if the root selector is an ID
4930
- if ( tokens.length > 1 && contextNodeType === 9 && !xml &&
4931
- (match = matchExpr["ID"].exec( tokens[0] )) ) {
5014
+ // Track unmatched elements for set filters
5015
+ if ( bySet ) {
5016
+ // They will have gone through all possible matchers
5017
+ if ( (elem = !matcher && elem) ) {
5018
+ matchedCount--;
5019
+ }
4932
5020
 
4933
- context = Expr.find["ID"]( match[1], context, xml )[0];
4934
- if ( !context ) {
4935
- return results;
5021
+ // Lengthen the array for every element, matched or not
5022
+ if ( seed ) {
5023
+ unmatched.push( elem );
5024
+ }
5025
+ }
4936
5026
  }
4937
5027
 
4938
- selector = selector.slice( tokens.shift().length );
4939
- }
5028
+ // Apply set filters to unmatched elements
5029
+ matchedCount += i;
5030
+ if ( bySet && i !== matchedCount ) {
5031
+ for ( j = 0; (matcher = setMatchers[j]); j++ ) {
5032
+ matcher( unmatched, setMatched, context, xml );
5033
+ }
4940
5034
 
4941
- findContext = ( (match = rsibling.exec( tokens[0] )) && !match.index && context.parentNode ) || context;
5035
+ if ( seed ) {
5036
+ // Reintegrate element matches to eliminate the need for sorting
5037
+ if ( matchedCount > 0 ) {
5038
+ while ( i-- ) {
5039
+ if ( !(unmatched[i] || setMatched[i]) ) {
5040
+ setMatched[i] = pop.call( results );
5041
+ }
5042
+ }
5043
+ }
4942
5044
 
4943
- // Get the last token, excluding :not
4944
- notTokens = tokens.pop();
4945
- token = notTokens.split(":not")[0];
5045
+ // Discard index placeholder values to get only actual matches
5046
+ setMatched = condense( setMatched );
5047
+ }
4946
5048
 
4947
- for ( i = 0, len = Expr.order.length; i < len; i++ ) {
4948
- type = Expr.order[i];
5049
+ // Add matches to results
5050
+ push.apply( results, setMatched );
4949
5051
 
4950
- if ( (match = matchExpr[ type ].exec( token )) ) {
4951
- elements = Expr.find[ type ]( (match[1] || "").replace( rbackslash, "" ), findContext, xml );
5052
+ // Seedless set matches succeeding multiple successful matchers stipulate sorting
5053
+ if ( outermost && !seed && setMatched.length > 0 &&
5054
+ ( matchedCount + setMatchers.length ) > 1 ) {
4952
5055
 
4953
- if ( elements == null ) {
4954
- continue;
5056
+ Sizzle.uniqueSort( results );
4955
5057
  }
5058
+ }
4956
5059
 
4957
- if ( token === notTokens ) {
4958
- selector = selector.slice( 0, selector.length - notTokens.length ) +
4959
- token.replace( matchExpr[ type ], "" );
5060
+ // Override manipulation of globals by nested matchers
5061
+ if ( outermost ) {
5062
+ dirruns = dirrunsUnique;
5063
+ outermostContext = contextBackup;
5064
+ }
4960
5065
 
4961
- if ( !selector ) {
4962
- push.apply( results, slice.call(elements, 0) );
4963
- }
4964
- }
4965
- break;
5066
+ return unmatched;
5067
+ };
5068
+
5069
+ superMatcher.el = 0;
5070
+ return bySet ?
5071
+ markFunction( superMatcher ) :
5072
+ superMatcher;
5073
+ }
5074
+
5075
+ compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
5076
+ var i,
5077
+ setMatchers = [],
5078
+ elementMatchers = [],
5079
+ cached = compilerCache[ expando ][ selector + " " ];
5080
+
5081
+ if ( !cached ) {
5082
+ // Generate a function of recursive functions that can be used to check each element
5083
+ if ( !group ) {
5084
+ group = tokenize( selector );
5085
+ }
5086
+ i = group.length;
5087
+ while ( i-- ) {
5088
+ cached = matcherFromTokens( group[i] );
5089
+ if ( cached[ expando ] ) {
5090
+ setMatchers.push( cached );
5091
+ } else {
5092
+ elementMatchers.push( cached );
4966
5093
  }
4967
5094
  }
5095
+
5096
+ // Cache the compiled function
5097
+ cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
5098
+ }
5099
+ return cached;
5100
+ };
5101
+
5102
+ function multipleContexts( selector, contexts, results ) {
5103
+ var i = 0,
5104
+ len = contexts.length;
5105
+ for ( ; i < len; i++ ) {
5106
+ Sizzle( selector, contexts[i], results );
4968
5107
  }
5108
+ return results;
5109
+ }
4969
5110
 
4970
- // Only loop over the given elements once
4971
- // If selector is empty, we're already done
4972
- if ( selector ) {
4973
- matcher = compile( selector, context, xml );
4974
- dirruns = matcher.dirruns++;
5111
+ function select( selector, context, results, seed, xml ) {
5112
+ var i, tokens, token, type, find,
5113
+ match = tokenize( selector ),
5114
+ j = match.length;
4975
5115
 
4976
- if ( elements == null ) {
4977
- elements = Expr.find["TAG"]( "*", (rsibling.test( selector ) && context.parentNode) || context );
4978
- }
4979
- for ( i = 0; (elem = elements[i]); i++ ) {
4980
- cachedruns = matcher.runs++;
4981
- if ( matcher(elem, context) ) {
4982
- results.push( elem );
5116
+ if ( !seed ) {
5117
+ // Try to minimize operations if there is only one group
5118
+ if ( match.length === 1 ) {
5119
+
5120
+ // Take a shortcut and set the context if the root selector is an ID
5121
+ tokens = match[0] = match[0].slice( 0 );
5122
+ if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
5123
+ context.nodeType === 9 && !xml &&
5124
+ Expr.relative[ tokens[1].type ] ) {
5125
+
5126
+ context = Expr.find["ID"]( token.matches[0].replace( rbackslash, "" ), context, xml )[0];
5127
+ if ( !context ) {
5128
+ return results;
5129
+ }
5130
+
5131
+ selector = selector.slice( tokens.shift().length );
5132
+ }
5133
+
5134
+ // Fetch a seed set for right-to-left matching
5135
+ for ( i = matchExpr["POS"].test( selector ) ? -1 : tokens.length - 1; i >= 0; i-- ) {
5136
+ token = tokens[i];
5137
+
5138
+ // Abort if we hit a combinator
5139
+ if ( Expr.relative[ (type = token.type) ] ) {
5140
+ break;
5141
+ }
5142
+ if ( (find = Expr.find[ type ]) ) {
5143
+ // Search, expanding context for leading sibling combinators
5144
+ if ( (seed = find(
5145
+ token.matches[0].replace( rbackslash, "" ),
5146
+ rsibling.test( tokens[0].type ) && context.parentNode || context,
5147
+ xml
5148
+ )) ) {
5149
+
5150
+ // If seed is empty or no tokens remain, we can return early
5151
+ tokens.splice( i, 1 );
5152
+ selector = seed.length && tokens.join("");
5153
+ if ( !selector ) {
5154
+ push.apply( results, slice.call( seed, 0 ) );
5155
+ return results;
5156
+ }
5157
+
5158
+ break;
5159
+ }
5160
+ }
4983
5161
  }
4984
5162
  }
4985
5163
  }
4986
5164
 
5165
+ // Compile and execute a filtering function
5166
+ // Provide `match` to avoid retokenization if we modified the selector above
5167
+ compile( selector, match )(
5168
+ seed,
5169
+ context,
5170
+ xml,
5171
+ results,
5172
+ rsibling.test( selector )
5173
+ );
4987
5174
  return results;
4988
- };
5175
+ }
4989
5176
 
4990
5177
  if ( document.querySelectorAll ) {
4991
5178
  (function() {
@@ -4993,11 +5180,15 @@ if ( document.querySelectorAll ) {
4993
5180
  oldSelect = select,
4994
5181
  rescape = /'|\\/g,
4995
5182
  rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,
4996
- rbuggyQSA = [],
5183
+
5184
+ // qSa(:focus) reports false when true (Chrome 21), no need to also add to buggyMatches since matches checks buggyQSA
5185
+ // A support test would require too much code (would include document ready)
5186
+ rbuggyQSA = [ ":focus" ],
5187
+
4997
5188
  // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
4998
5189
  // A support test would require too much code (would include document ready)
4999
5190
  // just skip matchesSelector for :active
5000
- rbuggyMatches = [":active"],
5191
+ rbuggyMatches = [ ":active" ],
5001
5192
  matches = docElem.matchesSelector ||
5002
5193
  docElem.mozMatchesSelector ||
5003
5194
  docElem.webkitMatchesSelector ||
@@ -5007,7 +5198,12 @@ if ( document.querySelectorAll ) {
5007
5198
  // Build QSA regex
5008
5199
  // Regex strategy adopted from Diego Perini
5009
5200
  assert(function( div ) {
5010
- div.innerHTML = "<select><option selected></option></select>";
5201
+ // Select is set to empty string on purpose
5202
+ // This is to test IE's treatment of not explictly
5203
+ // setting a boolean content attribute,
5204
+ // since its presence should be enough
5205
+ // http://bugs.jquery.com/ticket/12359
5206
+ div.innerHTML = "<select><option selected=''></option></select>";
5011
5207
 
5012
5208
  // IE8 - Some boolean attributes are not treated correctly
5013
5209
  if ( !div.querySelectorAll("[selected]").length ) {
@@ -5033,42 +5229,52 @@ if ( document.querySelectorAll ) {
5033
5229
 
5034
5230
  // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
5035
5231
  // IE8 throws error here (do not put tests after this one)
5036
- div.innerHTML = "<input type='hidden'>";
5232
+ div.innerHTML = "<input type='hidden'/>";
5037
5233
  if ( !div.querySelectorAll(":enabled").length ) {
5038
5234
  rbuggyQSA.push(":enabled", ":disabled");
5039
5235
  }
5040
5236
  });
5041
5237
 
5042
- rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
5238
+ // rbuggyQSA always contains :focus, so no need for a length check
5239
+ rbuggyQSA = /* rbuggyQSA.length && */ new RegExp( rbuggyQSA.join("|") );
5043
5240
 
5044
5241
  select = function( selector, context, results, seed, xml ) {
5045
5242
  // Only use querySelectorAll when not filtering,
5046
5243
  // when this is not xml,
5047
5244
  // and when no QSA bugs apply
5048
- if ( !seed && !xml && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
5049
- if ( context.nodeType === 9 ) {
5050
- try {
5051
- push.apply( results, slice.call(context.querySelectorAll( selector ), 0) );
5052
- return results;
5053
- } catch(qsaError) {}
5245
+ if ( !seed && !xml && !rbuggyQSA.test( selector ) ) {
5246
+ var groups, i,
5247
+ old = true,
5248
+ nid = expando,
5249
+ newContext = context,
5250
+ newSelector = context.nodeType === 9 && selector;
5251
+
5054
5252
  // qSA works strangely on Element-rooted queries
5055
5253
  // We can work around this by specifying an extra ID on the root
5056
5254
  // and working up from there (Thanks to Andrew Dupont for the technique)
5057
5255
  // IE 8 doesn't work on object elements
5058
- } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
5059
- var old = context.getAttribute("id"),
5060
- nid = old || expando,
5061
- newContext = rsibling.test( selector ) && context.parentNode || context;
5256
+ if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
5257
+ groups = tokenize( selector );
5062
5258
 
5063
- if ( old ) {
5064
- nid = nid.replace( rescape, "\\$&" );
5259
+ if ( (old = context.getAttribute("id")) ) {
5260
+ nid = old.replace( rescape, "\\$&" );
5065
5261
  } else {
5066
5262
  context.setAttribute( "id", nid );
5067
5263
  }
5264
+ nid = "[id='" + nid + "'] ";
5068
5265
 
5266
+ i = groups.length;
5267
+ while ( i-- ) {
5268
+ groups[i] = nid + groups[i].join("");
5269
+ }
5270
+ newContext = rsibling.test( selector ) && context.parentNode || context;
5271
+ newSelector = groups.join(",");
5272
+ }
5273
+
5274
+ if ( newSelector ) {
5069
5275
  try {
5070
5276
  push.apply( results, slice.call( newContext.querySelectorAll(
5071
- selector.replace( rgroups, "[id='" + nid + "'] $&" )
5277
+ newSelector
5072
5278
  ), 0 ) );
5073
5279
  return results;
5074
5280
  } catch(qsaError) {
@@ -5093,11 +5299,11 @@ if ( document.querySelectorAll ) {
5093
5299
  // Gecko does not error, returns false instead
5094
5300
  try {
5095
5301
  matches.call( div, "[test!='']:sizzle" );
5096
- rbuggyMatches.push( Expr.match.PSEUDO );
5302
+ rbuggyMatches.push( "!=", pseudos );
5097
5303
  } catch ( e ) {}
5098
5304
  });
5099
5305
 
5100
- // rbuggyMatches always contains :active, so no need for a length check
5306
+ // rbuggyMatches always contains :active and :focus, so no need for a length check
5101
5307
  rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") );
5102
5308
 
5103
5309
  Sizzle.matchesSelector = function( elem, expr ) {
@@ -5105,7 +5311,7 @@ if ( document.querySelectorAll ) {
5105
5311
  expr = expr.replace( rattributeQuotes, "='$1']" );
5106
5312
 
5107
5313
  // rbuggyMatches always contains :active, so no need for an existence check
5108
- if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && (!rbuggyQSA || !rbuggyQSA.test( expr )) ) {
5314
+ if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && !rbuggyQSA.test( expr ) ) {
5109
5315
  try {
5110
5316
  var ret = matches.call( elem, expr );
5111
5317
 
@@ -5125,6 +5331,14 @@ if ( document.querySelectorAll ) {
5125
5331
  })();
5126
5332
  }
5127
5333
 
5334
+ // Deprecated
5335
+ Expr.pseudos["nth"] = Expr.pseudos["eq"];
5336
+
5337
+ // Back-compat
5338
+ function setFilters() {}
5339
+ Expr.filters = setFilters.prototype = Expr.pseudos;
5340
+ Expr.setFilters = new setFilters();
5341
+
5128
5342
  // Override sizzle attribute retrieval
5129
5343
  Sizzle.attr = jQuery.attr;
5130
5344
  jQuery.find = Sizzle;
@@ -5923,15 +6137,11 @@ jQuery.buildFragment = function( args, context, scripts ) {
5923
6137
  first = args[ 0 ];
5924
6138
 
5925
6139
  // Set context from what may come in as undefined or a jQuery collection or a node
6140
+ // Updated to fix #12266 where accessing context[0] could throw an exception in IE9/10 &
6141
+ // also doubles as fix for #8950 where plain objects caused createDocumentFragment exception
5926
6142
  context = context || document;
5927
- context = (context[0] || context).ownerDocument || context[0] || context;
5928
-
5929
- // Ensure that an attr object doesn't incorrectly stand in as a document object
5930
- // Chrome and Firefox seem to allow this to occur and will throw exception
5931
- // Fixes #8950
5932
- if ( typeof context.createDocumentFragment === "undefined" ) {
5933
- context = document;
5934
- }
6143
+ context = !context.nodeType && context[0] || context;
6144
+ context = context.ownerDocument || context;
5935
6145
 
5936
6146
  // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
5937
6147
  // Cloning options loses the selected state, so don't cache them
@@ -6076,8 +6286,8 @@ jQuery.extend({
6076
6286
  },
6077
6287
 
6078
6288
  clean: function( elems, context, fragment, scripts ) {
6079
- var j, safe, elem, tag, wrap, depth, div, hasBody, tbody, len, handleScript, jsTags,
6080
- i = 0,
6289
+ var i, j, elem, tag, wrap, depth, div, hasBody, tbody, len, handleScript, jsTags,
6290
+ safe = context === document && safeFragment,
6081
6291
  ret = [];
6082
6292
 
6083
6293
  // Ensure that context is a document
@@ -6086,7 +6296,7 @@ jQuery.extend({
6086
6296
  }
6087
6297
 
6088
6298
  // Use the already-created safe fragment if context permits
6089
- for ( safe = context === document && safeFragment; (elem = elems[i]) != null; i++ ) {
6299
+ for ( i = 0; (elem = elems[i]) != null; i++ ) {
6090
6300
  if ( typeof elem === "number" ) {
6091
6301
  elem += "";
6092
6302
  }
@@ -6102,7 +6312,8 @@ jQuery.extend({
6102
6312
  } else {
6103
6313
  // Ensure a safe container in which to render the html
6104
6314
  safe = safe || createSafeFragment( context );
6105
- div = div || safe.appendChild( context.createElement("div") );
6315
+ div = context.createElement("div");
6316
+ safe.appendChild( div );
6106
6317
 
6107
6318
  // Fix "XHTML"-style tags in all browsers
6108
6319
  elem = elem.replace(rxhtmlTag, "<$1></$2>");
@@ -6145,21 +6356,20 @@ jQuery.extend({
6145
6356
 
6146
6357
  elem = div.childNodes;
6147
6358
 
6148
- // Remember the top-level container for proper cleanup
6149
- div = safe.lastChild;
6359
+ // Take out of fragment container (we need a fresh div each time)
6360
+ div.parentNode.removeChild( div );
6150
6361
  }
6151
6362
  }
6152
6363
 
6153
6364
  if ( elem.nodeType ) {
6154
6365
  ret.push( elem );
6155
6366
  } else {
6156
- ret = jQuery.merge( ret, elem );
6367
+ jQuery.merge( ret, elem );
6157
6368
  }
6158
6369
  }
6159
6370
 
6160
6371
  // Fix #11356: Clear elements from safeFragment
6161
6372
  if ( div ) {
6162
- safe.removeChild( div );
6163
6373
  elem = div = safe = null;
6164
6374
  }
6165
6375
 
@@ -6294,9 +6504,10 @@ if ( matched.browser ) {
6294
6504
  browser.version = matched.version;
6295
6505
  }
6296
6506
 
6297
- // Deprecated, use jQuery.browser.webkit instead
6298
- // Maintained for back-compat only
6299
- if ( browser.webkit ) {
6507
+ // Chrome is Webkit, but Webkit is also Safari.
6508
+ if ( browser.chrome ) {
6509
+ browser.webkit = true;
6510
+ } else if ( browser.webkit ) {
6300
6511
  browser.safari = true;
6301
6512
  }
6302
6513
 
@@ -6322,23 +6533,25 @@ jQuery.sub = function() {
6322
6533
  var rootjQuerySub = jQuerySub(document);
6323
6534
  return jQuerySub;
6324
6535
  };
6325
-
6536
+
6326
6537
  })();
6327
6538
  var curCSS, iframe, iframeDoc,
6328
6539
  ralpha = /alpha\([^)]*\)/i,
6329
6540
  ropacity = /opacity=([^)]*)/,
6330
6541
  rposition = /^(top|right|bottom|left)$/,
6542
+ // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
6543
+ // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6544
+ rdisplayswap = /^(none|table(?!-c[ea]).+)/,
6331
6545
  rmargin = /^margin/,
6332
6546
  rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
6333
6547
  rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
6334
6548
  rrelNum = new RegExp( "^([-+])=(" + core_pnum + ")", "i" ),
6335
- elemdisplay = {},
6549
+ elemdisplay = { BODY: "block" },
6336
6550
 
6337
6551
  cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6338
6552
  cssNormalTransform = {
6339
6553
  letterSpacing: 0,
6340
- fontWeight: 400,
6341
- lineHeight: 1
6554
+ fontWeight: 400
6342
6555
  },
6343
6556
 
6344
6557
  cssExpand = [ "Top", "Right", "Bottom", "Left" ],
@@ -6604,18 +6817,20 @@ jQuery.extend({
6604
6817
  }
6605
6818
  });
6606
6819
 
6607
- // NOTE: To any future maintainer, we've used both window.getComputedStyle
6608
- // and getComputedStyle here to produce a better gzip size
6820
+ // NOTE: To any future maintainer, we've window.getComputedStyle
6821
+ // because jsdom on node.js will break without it.
6609
6822
  if ( window.getComputedStyle ) {
6610
6823
  curCSS = function( elem, name ) {
6611
6824
  var ret, width, minWidth, maxWidth,
6612
- computed = getComputedStyle( elem, null ),
6825
+ computed = window.getComputedStyle( elem, null ),
6613
6826
  style = elem.style;
6614
6827
 
6615
6828
  if ( computed ) {
6616
6829
 
6617
- ret = computed[ name ];
6618
- if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
6830
+ // getPropertyValue is only needed for .css('filter') in IE9, see #12537
6831
+ ret = computed.getPropertyValue( name ) || computed[ name ];
6832
+
6833
+ if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
6619
6834
  ret = jQuery.style( elem, name );
6620
6835
  }
6621
6836
 
@@ -6738,7 +6953,10 @@ function getWidthOrHeight( elem, name, extra ) {
6738
6953
  valueIsBorderBox = true,
6739
6954
  isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box";
6740
6955
 
6741
- if ( val <= 0 ) {
6956
+ // some non-html elements return undefined for offsetWidth, so check for null/undefined
6957
+ // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
6958
+ // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
6959
+ if ( val <= 0 || val == null ) {
6742
6960
  // Fall back to computed then uncomputed css if necessary
6743
6961
  val = curCSS( elem, name );
6744
6962
  if ( val < 0 || val == null ) {
@@ -6817,12 +7035,14 @@ jQuery.each([ "height", "width" ], function( i, name ) {
6817
7035
  jQuery.cssHooks[ name ] = {
6818
7036
  get: function( elem, computed, extra ) {
6819
7037
  if ( computed ) {
6820
- if ( elem.offsetWidth !== 0 || curCSS( elem, "display" ) !== "none" ) {
6821
- return getWidthOrHeight( elem, name, extra );
6822
- } else {
7038
+ // certain elements can have dimension info if we invisibly show them
7039
+ // however, it must have a current display style that would benefit from this
7040
+ if ( elem.offsetWidth === 0 && rdisplayswap.test( curCSS( elem, "display" ) ) ) {
6823
7041
  return jQuery.swap( elem, cssShow, function() {
6824
7042
  return getWidthOrHeight( elem, name, extra );
6825
7043
  });
7044
+ } else {
7045
+ return getWidthOrHeight( elem, name, extra );
6826
7046
  }
6827
7047
  }
6828
7048
  },
@@ -7056,10 +7276,10 @@ function buildParams( prefix, obj, traditional, add ) {
7056
7276
  add( prefix, obj );
7057
7277
  }
7058
7278
  }
7059
- var // Document location
7060
- ajaxLocation,
7061
- // Document location segments
7279
+ var
7280
+ // Document location
7062
7281
  ajaxLocParts,
7282
+ ajaxLocation,
7063
7283
 
7064
7284
  rhash = /#.*$/,
7065
7285
  rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
@@ -7228,7 +7448,7 @@ jQuery.fn.load = function( url, params, callback ) {
7228
7448
  params = undefined;
7229
7449
 
7230
7450
  // Otherwise, build a param string
7231
- } else if ( typeof params === "object" ) {
7451
+ } else if ( params && typeof params === "object" ) {
7232
7452
  type = "POST";
7233
7453
  }
7234
7454
 
@@ -7576,7 +7796,7 @@ jQuery.extend({
7576
7796
 
7577
7797
  // Set data for the fake xhr object
7578
7798
  jqXHR.status = status;
7579
- jqXHR.statusText = "" + ( nativeStatusText || statusText );
7799
+ jqXHR.statusText = ( nativeStatusText || statusText ) + "";
7580
7800
 
7581
7801
  // Success/Error
7582
7802
  if ( isSuccess ) {
@@ -7636,11 +7856,11 @@ jQuery.extend({
7636
7856
  // Extract dataTypes list
7637
7857
  s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace );
7638
7858
 
7639
- // Determine if a cross-domain request is in order
7859
+ // A cross-domain request is in order when we have a protocol:host:port mismatch
7640
7860
  if ( s.crossDomain == null ) {
7641
7861
  parts = rurl.exec( s.url.toLowerCase() );
7642
7862
  s.crossDomain = !!( parts &&
7643
- ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
7863
+ ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
7644
7864
  ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
7645
7865
  ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
7646
7866
  );
@@ -8262,7 +8482,7 @@ if ( jQuery.support.ajax ) {
8262
8482
  // on any attempt to access responseText (#11426)
8263
8483
  try {
8264
8484
  responses.text = xhr.responseText;
8265
- } catch( _ ) {
8485
+ } catch( e ) {
8266
8486
  }
8267
8487
 
8268
8488
  // Firefox throws an exception when accessing
@@ -8338,12 +8558,13 @@ var fxNow, timerId,
8338
8558
  animationPrefilters = [ defaultPrefilter ],
8339
8559
  tweeners = {
8340
8560
  "*": [function( prop, value ) {
8341
- var end, unit, prevScale,
8561
+ var end, unit,
8342
8562
  tween = this.createTween( prop, value ),
8343
8563
  parts = rfxnum.exec( value ),
8344
8564
  target = tween.cur(),
8345
8565
  start = +target || 0,
8346
- scale = 1;
8566
+ scale = 1,
8567
+ maxIterations = 20;
8347
8568
 
8348
8569
  if ( parts ) {
8349
8570
  end = +parts[2];
@@ -8359,17 +8580,15 @@ var fxNow, timerId,
8359
8580
  do {
8360
8581
  // If previous iteration zeroed out, double until we get *something*
8361
8582
  // Use a string for doubling factor so we don't accidentally see scale as unchanged below
8362
- prevScale = scale = scale || ".5";
8583
+ scale = scale || ".5";
8363
8584
 
8364
8585
  // Adjust and apply
8365
8586
  start = start / scale;
8366
8587
  jQuery.style( tween.elem, prop, start + unit );
8367
8588
 
8368
- // Update scale, tolerating zeroes from tween.cur()
8369
- scale = tween.cur() / target;
8370
-
8371
- // Stop looping if we've hit the mark or scale is unchanged
8372
- } while ( scale !== 1 && scale !== prevScale );
8589
+ // Update scale, tolerating zero or NaN from tween.cur()
8590
+ // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
8591
+ } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
8373
8592
  }
8374
8593
 
8375
8594
  tween.unit = unit;
@@ -8416,7 +8635,9 @@ function Animation( elem, properties, options ) {
8416
8635
  tick = function() {
8417
8636
  var currentTime = fxNow || createFxNow(),
8418
8637
  remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
8419
- percent = 1 - ( remaining / animation.duration || 0 ),
8638
+ // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
8639
+ temp = remaining / animation.duration || 0,
8640
+ percent = 1 - temp,
8420
8641
  index = 0,
8421
8642
  length = animation.tweens.length;
8422
8643
 
@@ -8568,7 +8789,7 @@ jQuery.Animation = jQuery.extend( Animation, {
8568
8789
  });
8569
8790
 
8570
8791
  function defaultPrefilter( elem, props, opts ) {
8571
- var index, prop, value, length, dataShow, tween, hooks, oldfire,
8792
+ var index, prop, value, length, dataShow, toggle, tween, hooks, oldfire,
8572
8793
  anim = this,
8573
8794
  style = elem.style,
8574
8795
  orig = {},
@@ -8642,6 +8863,7 @@ function defaultPrefilter( elem, props, opts ) {
8642
8863
  value = props[ index ];
8643
8864
  if ( rfxtypes.exec( value ) ) {
8644
8865
  delete props[ index ];
8866
+ toggle = toggle || value === "toggle";
8645
8867
  if ( value === ( hidden ? "hide" : "show" ) ) {
8646
8868
  continue;
8647
8869
  }
@@ -8652,6 +8874,14 @@ function defaultPrefilter( elem, props, opts ) {
8652
8874
  length = handled.length;
8653
8875
  if ( length ) {
8654
8876
  dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} );
8877
+ if ( "hidden" in dataShow ) {
8878
+ hidden = dataShow.hidden;
8879
+ }
8880
+
8881
+ // store state if its toggle - enables .stop().toggle() to "reverse"
8882
+ if ( toggle ) {
8883
+ dataShow.hidden = !hidden;
8884
+ }
8655
8885
  if ( hidden ) {
8656
8886
  jQuery( elem ).show();
8657
8887
  } else {
@@ -8709,7 +8939,13 @@ Tween.prototype = {
8709
8939
  var eased,
8710
8940
  hooks = Tween.propHooks[ this.prop ];
8711
8941
 
8712
- this.pos = eased = jQuery.easing[ this.easing ]( percent, this.options.duration * percent, 0, 1, this.options.duration );
8942
+ if ( this.options.duration ) {
8943
+ this.pos = eased = jQuery.easing[ this.easing ](
8944
+ percent, this.options.duration * percent, 0, 1, this.options.duration
8945
+ );
8946
+ } else {
8947
+ this.pos = eased = percent;
8948
+ }
8713
8949
  this.now = ( this.end - this.start ) * eased + this.start;
8714
8950
 
8715
8951
  if ( this.options.step ) {
@@ -8867,6 +9103,7 @@ function genFx( type, includeWidth ) {
8867
9103
 
8868
9104
  // if we include width, step value is 1 to do all cssExpand values,
8869
9105
  // if we don't include width, step value is 2 to skip over Left and Right
9106
+ includeWidth = includeWidth? 1 : 0;
8870
9107
  for( ; i < 4 ; i += 2 - includeWidth ) {
8871
9108
  which = cssExpand[ i ];
8872
9109
  attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
@@ -8941,6 +9178,8 @@ jQuery.fx.tick = function() {
8941
9178
  timers = jQuery.timers,
8942
9179
  i = 0;
8943
9180
 
9181
+ fxNow = jQuery.now();
9182
+
8944
9183
  for ( ; i < timers.length; i++ ) {
8945
9184
  timer = timers[ i ];
8946
9185
  // Checks the timer has not already been removed
@@ -8952,6 +9191,7 @@ jQuery.fx.tick = function() {
8952
9191
  if ( !timers.length ) {
8953
9192
  jQuery.fx.stop();
8954
9193
  }
9194
+ fxNow = undefined;
8955
9195
  };
8956
9196
 
8957
9197
  jQuery.fx.timer = function( timer ) {
@@ -8995,7 +9235,8 @@ jQuery.fn.offset = function( options ) {
8995
9235
  });
8996
9236
  }
8997
9237
 
8998
- var box, docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft, top, left,
9238
+ var docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft,
9239
+ box = { top: 0, left: 0 },
8999
9240
  elem = this[ 0 ],
9000
9241
  doc = elem && elem.ownerDocument;
9001
9242
 
@@ -9009,21 +9250,25 @@ jQuery.fn.offset = function( options ) {
9009
9250
 
9010
9251
  docElem = doc.documentElement;
9011
9252
 
9012
- // Make sure we're not dealing with a disconnected DOM node
9253
+ // Make sure it's not a disconnected DOM node
9013
9254
  if ( !jQuery.contains( docElem, elem ) ) {
9014
- return { top: 0, left: 0 };
9255
+ return box;
9015
9256
  }
9016
9257
 
9017
- box = elem.getBoundingClientRect();
9258
+ // If we don't have gBCR, just use 0,0 rather than error
9259
+ // BlackBerry 5, iOS 3 (original iPhone)
9260
+ if ( typeof elem.getBoundingClientRect !== "undefined" ) {
9261
+ box = elem.getBoundingClientRect();
9262
+ }
9018
9263
  win = getWindow( doc );
9019
9264
  clientTop = docElem.clientTop || body.clientTop || 0;
9020
9265
  clientLeft = docElem.clientLeft || body.clientLeft || 0;
9021
9266
  scrollTop = win.pageYOffset || docElem.scrollTop;
9022
9267
  scrollLeft = win.pageXOffset || docElem.scrollLeft;
9023
- top = box.top + scrollTop - clientTop;
9024
- left = box.left + scrollLeft - clientLeft;
9025
-
9026
- return { top: top, left: left };
9268
+ return {
9269
+ top: box.top + scrollTop - clientTop,
9270
+ left: box.left + scrollLeft - clientLeft
9271
+ };
9027
9272
  };
9028
9273
 
9029
9274
  jQuery.offset = {
@@ -9201,7 +9446,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
9201
9446
 
9202
9447
  // Set width or height on the element
9203
9448
  jQuery.style( elem, type, value, extra );
9204
- }, type, chainable ? margin : undefined, chainable );
9449
+ }, type, chainable ? margin : undefined, chainable, null );
9205
9450
  };
9206
9451
  });
9207
9452
  });