kit_cms 2.3.15 → 2.3.16

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.1
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 30 2012 17:17:22 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
@@ -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.1",
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
@@ -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
  },
@@ -999,8 +999,10 @@ jQuery.Callbacks = function( options ) {
999
999
  (function add( args ) {
1000
1000
  jQuery.each( args, function( _, arg ) {
1001
1001
  var type = jQuery.type( arg );
1002
- if ( type === "function" && ( !options.unique || !self.has( arg ) ) ) {
1003
- list.push( arg );
1002
+ if ( type === "function" ) {
1003
+ if ( !options.unique || !self.has( arg ) ) {
1004
+ list.push( arg );
1005
+ }
1004
1006
  } else if ( arg && arg.length && type !== "string" ) {
1005
1007
  // Inspect recursively
1006
1008
  add( arg );
@@ -1143,7 +1145,7 @@ jQuery.extend({
1143
1145
  // Get a promise for this deferred
1144
1146
  // If obj is provided, the promise aspect is added to the object
1145
1147
  promise: function( obj ) {
1146
- return typeof obj === "object" ? jQuery.extend( obj, promise ) : promise;
1148
+ return obj != null ? jQuery.extend( obj, promise ) : promise;
1147
1149
  }
1148
1150
  },
1149
1151
  deferred = {};
@@ -1253,24 +1255,23 @@ jQuery.support = (function() {
1253
1255
  clickFn,
1254
1256
  div = document.createElement("div");
1255
1257
 
1256
- // Preliminary tests
1258
+ // Setup
1257
1259
  div.setAttribute( "className", "t" );
1258
1260
  div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
1259
1261
 
1262
+ // Support tests won't run in some limited or non-browser environments
1260
1263
  all = div.getElementsByTagName("*");
1261
1264
  a = div.getElementsByTagName("a")[ 0 ];
1262
- a.style.cssText = "top:1px;float:left;opacity:.5";
1263
-
1264
- // Can't get basic test support
1265
- if ( !all || !all.length || !a ) {
1265
+ if ( !all || !a || !all.length ) {
1266
1266
  return {};
1267
1267
  }
1268
1268
 
1269
- // First batch of supports tests
1269
+ // First batch of tests
1270
1270
  select = document.createElement("select");
1271
1271
  opt = select.appendChild( document.createElement("option") );
1272
1272
  input = div.getElementsByTagName("input")[ 0 ];
1273
1273
 
1274
+ a.style.cssText = "top:1px;float:left;opacity:.5";
1274
1275
  support = {
1275
1276
  // IE strips leading whitespace when .innerHTML is used
1276
1277
  leadingWhitespace: ( div.firstChild.nodeType === 3 ),
@@ -1312,7 +1313,7 @@ jQuery.support = (function() {
1312
1313
  // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1313
1314
  getSetAttribute: div.className !== "t",
1314
1315
 
1315
- // Tests for enctype support on a form(#6743)
1316
+ // Tests for enctype support on a form (#6743)
1316
1317
  enctype: !!document.createElement("form").enctype,
1317
1318
 
1318
1319
  // Makes sure cloning an html5 element does not cause problems
@@ -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 ] );
@@ -2049,7 +2050,7 @@ jQuery.fn.extend({
2049
2050
  setClass = " " + elem.className + " ";
2050
2051
 
2051
2052
  for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2052
- if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
2053
+ if ( setClass.indexOf( " " + classNames[ c ] + " " ) < 0 ) {
2053
2054
  setClass += classNames[ c ] + " ";
2054
2055
  }
2055
2056
  }
@@ -2082,7 +2083,7 @@ jQuery.fn.extend({
2082
2083
  // loop over each item in the removal list
2083
2084
  for ( c = 0, cl = removes.length; c < cl; c++ ) {
2084
2085
  // Remove until there is nothing to remove,
2085
- while ( className.indexOf(" " + removes[ c ] + " ") > -1 ) {
2086
+ while ( className.indexOf(" " + removes[ c ] + " ") >= 0 ) {
2086
2087
  className = className.replace( " " + removes[ c ] + " " , " " );
2087
2088
  }
2088
2089
  }
@@ -2136,7 +2137,7 @@ jQuery.fn.extend({
2136
2137
  i = 0,
2137
2138
  l = this.length;
2138
2139
  for ( ; i < l; i++ ) {
2139
- 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 ) {
2140
2141
  return true;
2141
2142
  }
2142
2143
  }
@@ -2217,26 +2218,25 @@ jQuery.extend({
2217
2218
  },
2218
2219
  select: {
2219
2220
  get: function( elem ) {
2220
- var value, i, max, option,
2221
- index = elem.selectedIndex,
2222
- values = [],
2221
+ var value, option,
2223
2222
  options = elem.options,
2224
- one = elem.type === "select-one";
2225
-
2226
- // Nothing was selected
2227
- if ( index < 0 ) {
2228
- return null;
2229
- }
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;
2230
2230
 
2231
2231
  // Loop through all the selected options
2232
- i = one ? index : 0;
2233
- max = one ? index + 1 : options.length;
2234
2232
  for ( ; i < max; i++ ) {
2235
2233
  option = options[ i ];
2236
2234
 
2237
- // Don't return options that are disabled or in a disabled optgroup
2238
- if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
2239
- (!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" ) ) ) {
2240
2240
 
2241
2241
  // Get the specific value for the option
2242
2242
  value = jQuery( option ).val();
@@ -2251,11 +2251,6 @@ jQuery.extend({
2251
2251
  }
2252
2252
  }
2253
2253
 
2254
- // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
2255
- if ( one && !values.length && options.length ) {
2256
- return jQuery( options[ index ] ).val();
2257
- }
2258
-
2259
2254
  return values;
2260
2255
  },
2261
2256
 
@@ -2314,7 +2309,7 @@ jQuery.extend({
2314
2309
  return ret;
2315
2310
 
2316
2311
  } else {
2317
- elem.setAttribute( name, "" + value );
2312
+ elem.setAttribute( name, value + "" );
2318
2313
  return value;
2319
2314
  }
2320
2315
 
@@ -2578,7 +2573,7 @@ if ( !jQuery.support.style ) {
2578
2573
  return elem.style.cssText.toLowerCase() || undefined;
2579
2574
  },
2580
2575
  set: function( elem, value ) {
2581
- return ( elem.style.cssText = "" + value );
2576
+ return ( elem.style.cssText = value + "" );
2582
2577
  }
2583
2578
  };
2584
2579
  }
@@ -2711,6 +2706,7 @@ jQuery.event = {
2711
2706
  handler: handler,
2712
2707
  guid: handler.guid,
2713
2708
  selector: selector,
2709
+ needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
2714
2710
  namespace: namespaces.join(".")
2715
2711
  }, handleObjIn );
2716
2712
 
@@ -2946,7 +2942,7 @@ jQuery.event = {
2946
2942
  }
2947
2943
  // Note that this is a bare JS function and not a jQuery handler
2948
2944
  handle = ontype && cur[ ontype ];
2949
- if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) {
2945
+ if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
2950
2946
  event.preventDefault();
2951
2947
  }
2952
2948
  }
@@ -2994,7 +2990,7 @@ jQuery.event = {
2994
2990
  var i, j, cur, ret, selMatch, matched, matches, handleObj, sel, related,
2995
2991
  handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
2996
2992
  delegateCount = handlers.delegateCount,
2997
- args = [].slice.call( arguments ),
2993
+ args = core_slice.call( arguments ),
2998
2994
  run_all = !event.exclusive && !event.namespace,
2999
2995
  special = jQuery.event.special[ event.type ] || {},
3000
2996
  handlerQueue = [];
@@ -3023,7 +3019,9 @@ jQuery.event = {
3023
3019
  sel = handleObj.selector;
3024
3020
 
3025
3021
  if ( selMatch[ sel ] === undefined ) {
3026
- selMatch[ sel ] = jQuery( sel, this ).index( cur ) >= 0;
3022
+ selMatch[ sel ] = handleObj.needsContext ?
3023
+ jQuery( sel, this ).index( cur ) >= 0 :
3024
+ jQuery.find( sel, this, null, [ cur ] ).length;
3027
3025
  }
3028
3026
  if ( selMatch[ sel ] ) {
3029
3027
  matches.push( handleObj );
@@ -3230,7 +3228,7 @@ jQuery.removeEvent = document.removeEventListener ?
3230
3228
 
3231
3229
  if ( elem.detachEvent ) {
3232
3230
 
3233
- // #8545, #7054, preventing memory leaks for custom events in IE6-8
3231
+ // #8545, #7054, preventing memory leaks for custom events in IE6-8
3234
3232
  // detachEvent needed property on element, by name of that event, to properly expose it to GC
3235
3233
  if ( typeof elem[ name ] === "undefined" ) {
3236
3234
  elem[ name ] = null;
@@ -3593,7 +3591,7 @@ jQuery.fn.extend({
3593
3591
  },
3594
3592
  undelegate: function( selector, types, fn ) {
3595
3593
  // ( namespace ) or ( selector, types [, fn] )
3596
- 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 );
3597
3595
  },
3598
3596
 
3599
3597
  trigger: function( type, data ) {
@@ -3664,14 +3662,13 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl
3664
3662
  });
3665
3663
  /*!
3666
3664
  * Sizzle CSS Selector Engine
3667
- * Copyright 2012 jQuery Foundation and other contributors
3668
- * Released under the MIT license
3669
- * http://sizzlejs.com/
3665
+ * Copyright 2012 jQuery Foundation and other contributors
3666
+ * Released under the MIT license
3667
+ * http://sizzlejs.com/
3670
3668
  */
3671
3669
  (function( window, undefined ) {
3672
3670
 
3673
- var dirruns,
3674
- cachedruns,
3671
+ var cachedruns,
3675
3672
  assertGetIdNotName,
3676
3673
  Expr,
3677
3674
  getText,
@@ -3680,21 +3677,36 @@ var dirruns,
3680
3677
  compile,
3681
3678
  sortOrder,
3682
3679
  hasDuplicate,
3680
+ outermostContext,
3683
3681
 
3684
3682
  baseHasDuplicate = true,
3685
3683
  strundefined = "undefined",
3686
3684
 
3687
3685
  expando = ( "sizcache" + Math.random() ).replace( ".", "" ),
3688
3686
 
3687
+ Token = String,
3689
3688
  document = window.document,
3690
3689
  docElem = document.documentElement,
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
3707
  // Augment a function for special use by Sizzle
3696
3708
  markFunction = function( fn, value ) {
3697
- fn[ expando ] = value || true;
3709
+ fn[ expando ] = value == null || value;
3698
3710
  return fn;
3699
3711
  },
3700
3712
 
@@ -3708,7 +3720,8 @@ var dirruns,
3708
3720
  delete cache[ keys.shift() ];
3709
3721
  }
3710
3722
 
3711
- return (cache[ key ] = value);
3723
+ // Retrieve with (key + " ") to avoid collision with native Object.prototype properties (see Issue #157)
3724
+ return (cache[ key + " " ] = value);
3712
3725
  }, cache );
3713
3726
  },
3714
3727
 
@@ -3741,7 +3754,8 @@ var dirruns,
3741
3754
  pseudos = ":(" + characterEncoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + attributes + ")|[^:]|\\\\.)*|.*))\\)|)",
3742
3755
 
3743
3756
  // For matchExpr.POS and matchExpr.needsContext
3744
- pos = ":(nth|eq|gt|lt|first|last|even|odd)(?:\\(((?:-\\d)?\\d*)\\)|)(?=[^-]|$)",
3757
+ pos = ":(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
3758
+ "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)",
3745
3759
 
3746
3760
  // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
3747
3761
  rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
@@ -3769,10 +3783,10 @@ var dirruns,
3769
3783
  "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
3770
3784
  "ATTR": new RegExp( "^" + attributes ),
3771
3785
  "PSEUDO": new RegExp( "^" + pseudos ),
3772
- "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 +
3773
3788
  "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
3774
3789
  "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
3775
- "POS": new RegExp( pos, "ig" ),
3776
3790
  // For use in libraries implementing .is()
3777
3791
  "needsContext": new RegExp( "^" + whitespace + "*[>+~]|" + pos, "i" )
3778
3792
  },
@@ -3854,7 +3868,8 @@ try {
3854
3868
  slice.call( docElem.childNodes, 0 )[0].nodeType;
3855
3869
  } catch ( e ) {
3856
3870
  slice = function( i ) {
3857
- var elem, results = [];
3871
+ var elem,
3872
+ results = [];
3858
3873
  for ( ; (elem = this[i]); i++ ) {
3859
3874
  results.push( elem );
3860
3875
  }
@@ -3868,14 +3883,14 @@ function Sizzle( selector, context, results, seed ) {
3868
3883
  var match, elem, xml, m,
3869
3884
  nodeType = context.nodeType;
3870
3885
 
3871
- if ( nodeType !== 1 && nodeType !== 9 ) {
3872
- return [];
3873
- }
3874
-
3875
3886
  if ( !selector || typeof selector !== "string" ) {
3876
3887
  return results;
3877
3888
  }
3878
3889
 
3890
+ if ( nodeType !== 1 && nodeType !== 9 ) {
3891
+ return [];
3892
+ }
3893
+
3879
3894
  xml = isXML( context );
3880
3895
 
3881
3896
  if ( !xml && !seed ) {
@@ -3919,7 +3934,7 @@ function Sizzle( selector, context, results, seed ) {
3919
3934
  }
3920
3935
 
3921
3936
  // All others
3922
- return select( selector, context, results, seed, xml );
3937
+ return select( selector.replace( rtrim, "$1" ), context, results, seed, xml );
3923
3938
  }
3924
3939
 
3925
3940
  Sizzle.matches = function( expr, elements ) {
@@ -3946,6 +3961,25 @@ function createButtonPseudo( type ) {
3946
3961
  };
3947
3962
  }
3948
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
+
3949
3983
  /**
3950
3984
  * Utility function for retrieving the text value of an array of DOM nodes
3951
3985
  * @param {Array|Element} elem
@@ -3983,7 +4017,7 @@ getText = Sizzle.getText = function( elem ) {
3983
4017
  return ret;
3984
4018
  };
3985
4019
 
3986
- isXML = Sizzle.isXML = function isXML( elem ) {
4020
+ isXML = Sizzle.isXML = function( elem ) {
3987
4021
  // documentElement is verified for cases where it doesn't yet exist
3988
4022
  // (such as loading iframes in IE - #4833)
3989
4023
  var documentElement = elem && (elem.ownerDocument || elem).documentElement;
@@ -4011,23 +4045,23 @@ contains = Sizzle.contains = docElem.contains ?
4011
4045
  };
4012
4046
 
4013
4047
  Sizzle.attr = function( elem, name ) {
4014
- var attr,
4048
+ var val,
4015
4049
  xml = isXML( elem );
4016
4050
 
4017
4051
  if ( !xml ) {
4018
4052
  name = name.toLowerCase();
4019
4053
  }
4020
- if ( Expr.attrHandle[ name ] ) {
4021
- return Expr.attrHandle[ name ]( elem );
4054
+ if ( (val = Expr.attrHandle[ name ]) ) {
4055
+ return val( elem );
4022
4056
  }
4023
- if ( assertAttributes || xml ) {
4057
+ if ( xml || assertAttributes ) {
4024
4058
  return elem.getAttribute( name );
4025
4059
  }
4026
- attr = elem.getAttributeNode( name );
4027
- return attr ?
4060
+ val = elem.getAttributeNode( name );
4061
+ return val ?
4028
4062
  typeof elem[ name ] === "boolean" ?
4029
4063
  elem[ name ] ? name : null :
4030
- attr.specified ? attr.value : null :
4064
+ val.specified ? val.value : null :
4031
4065
  null;
4032
4066
  };
4033
4067
 
@@ -4040,11 +4074,6 @@ Expr = Sizzle.selectors = {
4040
4074
 
4041
4075
  match: matchExpr,
4042
4076
 
4043
- order: new RegExp( "ID|TAG" +
4044
- (assertUsableName ? "|NAME" : "") +
4045
- (assertUsableClassName ? "|CLASS" : "")
4046
- ),
4047
-
4048
4077
  // IE6/7 return a modified href
4049
4078
  attrHandle: assertHrefNotNormalized ?
4050
4079
  {} :
@@ -4105,13 +4134,13 @@ Expr = Sizzle.selectors = {
4105
4134
  return results;
4106
4135
  },
4107
4136
 
4108
- "NAME": function( tag, context ) {
4137
+ "NAME": assertUsableName && function( tag, context ) {
4109
4138
  if ( typeof context.getElementsByName !== strundefined ) {
4110
4139
  return context.getElementsByName( name );
4111
4140
  }
4112
4141
  },
4113
4142
 
4114
- "CLASS": function( className, context, xml ) {
4143
+ "CLASS": assertUsableClassName && function( className, context, xml ) {
4115
4144
  if ( typeof context.getElementsByClassName !== strundefined && !xml ) {
4116
4145
  return context.getElementsByClassName( className );
4117
4146
  }
@@ -4140,7 +4169,7 @@ Expr = Sizzle.selectors = {
4140
4169
  },
4141
4170
 
4142
4171
  "CHILD": function( match ) {
4143
- /* matches from matchExpr.CHILD
4172
+ /* matches from matchExpr["CHILD"]
4144
4173
  1 type (only|nth|...)
4145
4174
  2 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
4146
4175
  3 xn-component of xn+y argument ([+-]?\d*n|)
@@ -4170,7 +4199,7 @@ Expr = Sizzle.selectors = {
4170
4199
  return match;
4171
4200
  },
4172
4201
 
4173
- "PSEUDO": function( match, context, xml ) {
4202
+ "PSEUDO": function( match ) {
4174
4203
  var unquoted, excess;
4175
4204
  if ( matchExpr["CHILD"].test( match[0] ) ) {
4176
4205
  return null;
@@ -4182,7 +4211,7 @@ Expr = Sizzle.selectors = {
4182
4211
  // Only check arguments that contain a pseudo
4183
4212
  if ( rpseudo.test(unquoted) &&
4184
4213
  // Get excess from tokenize (recursively)
4185
- (excess = tokenize( unquoted, context, xml, true )) &&
4214
+ (excess = tokenize( unquoted, true )) &&
4186
4215
  // advance to the next closing parenthesis
4187
4216
  (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
4188
4217
 
@@ -4226,86 +4255,65 @@ Expr = Sizzle.selectors = {
4226
4255
  },
4227
4256
 
4228
4257
  "CLASS": function( className ) {
4229
- var pattern = classCache[ expando ][ className ];
4230
- if ( !pattern ) {
4231
- pattern = classCache( className, new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)") );
4232
- }
4233
- return function( elem ) {
4234
- return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" );
4235
- };
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
+ });
4236
4265
  },
4237
4266
 
4238
4267
  "ATTR": function( name, operator, check ) {
4239
- if ( !operator ) {
4240
- return function( elem ) {
4241
- return Sizzle.attr( elem, name ) != null;
4242
- };
4243
- }
4244
-
4245
- return function( elem ) {
4246
- var result = Sizzle.attr( elem, name ),
4247
- value = result + "";
4268
+ return function( elem, context ) {
4269
+ var result = Sizzle.attr( elem, name );
4248
4270
 
4249
4271
  if ( result == null ) {
4250
4272
  return operator === "!=";
4251
4273
  }
4252
-
4253
- switch ( operator ) {
4254
- case "=":
4255
- return value === check;
4256
- case "!=":
4257
- return value !== check;
4258
- case "^=":
4259
- return check && value.indexOf( check ) === 0;
4260
- case "*=":
4261
- return check && value.indexOf( check ) > -1;
4262
- case "$=":
4263
- return check && value.substr( value.length - check.length ) === check;
4264
- case "~=":
4265
- return ( " " + value + " " ).indexOf( check ) > -1;
4266
- case "|=":
4267
- return value === check || value.substr( 0, check.length + 1 ) === check + "-";
4274
+ if ( !operator ) {
4275
+ return true;
4268
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;
4269
4288
  };
4270
4289
  },
4271
4290
 
4272
4291
  "CHILD": function( type, argument, first, last ) {
4273
4292
 
4274
4293
  if ( type === "nth" ) {
4275
- var doneName = done++;
4276
-
4277
4294
  return function( elem ) {
4278
- var parent, diff,
4279
- count = 0,
4280
- node = elem;
4295
+ var node, diff,
4296
+ parent = elem.parentNode;
4281
4297
 
4282
4298
  if ( first === 1 && last === 0 ) {
4283
4299
  return true;
4284
4300
  }
4285
4301
 
4286
- parent = elem.parentNode;
4287
-
4288
- if ( parent && (parent[ expando ] !== doneName || !elem.sizset) ) {
4302
+ if ( parent ) {
4303
+ diff = 0;
4289
4304
  for ( node = parent.firstChild; node; node = node.nextSibling ) {
4290
4305
  if ( node.nodeType === 1 ) {
4291
- node.sizset = ++count;
4292
- if ( node === elem ) {
4306
+ diff++;
4307
+ if ( elem === node ) {
4293
4308
  break;
4294
4309
  }
4295
4310
  }
4296
4311
  }
4297
-
4298
- parent[ expando ] = doneName;
4299
4312
  }
4300
4313
 
4301
- diff = elem.sizset - last;
4302
-
4303
- if ( first === 0 ) {
4304
- return diff === 0;
4305
-
4306
- } else {
4307
- return ( diff % first === 0 && diff / first >= 0 );
4308
- }
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 );
4309
4317
  };
4310
4318
  }
4311
4319
 
@@ -4340,42 +4348,82 @@ Expr = Sizzle.selectors = {
4340
4348
  };
4341
4349
  },
4342
4350
 
4343
- "PSEUDO": function( pseudo, argument, context, xml ) {
4351
+ "PSEUDO": function( pseudo, argument ) {
4344
4352
  // pseudo-class names are case-insensitive
4345
4353
  // http://www.w3.org/TR/selectors/#pseudo-classes
4346
4354
  // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
4355
+ // Remember that setFilters inherits from pseudos
4347
4356
  var args,
4348
- fn = Expr.pseudos[ pseudo ] || Expr.pseudos[ pseudo.toLowerCase() ];
4349
-
4350
- if ( !fn ) {
4351
- Sizzle.error( "unsupported pseudo: " + pseudo );
4352
- }
4357
+ fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
4358
+ Sizzle.error( "unsupported pseudo: " + pseudo );
4353
4359
 
4354
4360
  // The user may use createPseudo to indicate that
4355
4361
  // arguments are needed to create the filter function
4356
4362
  // just as Sizzle does
4357
- if ( !fn[ expando ] ) {
4358
- if ( fn.length > 1 ) {
4359
- args = [ pseudo, pseudo, "", argument ];
4360
- return function( elem ) {
4363
+ if ( fn[ expando ] ) {
4364
+ return fn( argument );
4365
+ }
4366
+
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 ) {
4361
4381
  return fn( elem, 0, args );
4362
4382
  };
4363
- }
4364
- return fn;
4365
4383
  }
4366
4384
 
4367
- return fn( argument, context, xml );
4385
+ return fn;
4368
4386
  }
4369
4387
  },
4370
4388
 
4371
4389
  pseudos: {
4372
- "not": markFunction(function( selector, context, xml ) {
4390
+ "not": markFunction(function( selector ) {
4373
4391
  // Trim the selector passed to compile
4374
4392
  // to avoid treating leading and trailing
4375
4393
  // spaces as combinators
4376
- 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 ) {
4377
4419
  return function( elem ) {
4378
- 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;
4379
4427
  };
4380
4428
  }),
4381
4429
 
@@ -4425,18 +4473,6 @@ Expr = Sizzle.selectors = {
4425
4473
  return true;
4426
4474
  },
4427
4475
 
4428
- "contains": markFunction(function( text ) {
4429
- return function( elem ) {
4430
- return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
4431
- };
4432
- }),
4433
-
4434
- "has": markFunction(function( selector ) {
4435
- return function( elem ) {
4436
- return Sizzle( selector, elem ).length > 0;
4437
- };
4438
- }),
4439
-
4440
4476
  "header": function( elem ) {
4441
4477
  return rheader.test( elem.nodeName );
4442
4478
  },
@@ -4471,56 +4507,53 @@ Expr = Sizzle.selectors = {
4471
4507
 
4472
4508
  "focus": function( elem ) {
4473
4509
  var doc = elem.ownerDocument;
4474
- 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);
4475
4511
  },
4476
4512
 
4477
4513
  "active": function( elem ) {
4478
4514
  return elem === elem.ownerDocument.activeElement;
4479
- }
4480
- },
4481
-
4482
- setFilters: {
4483
- "first": function( elements, argument, not ) {
4484
- return not ? elements.slice( 1 ) : [ elements[0] ];
4485
4515
  },
4486
4516
 
4487
- "last": function( elements, argument, not ) {
4488
- var elem = elements.pop();
4489
- return not ? elements : [ elem ];
4490
- },
4517
+ // Positional types
4518
+ "first": createPositionalPseudo(function() {
4519
+ return [ 0 ];
4520
+ }),
4491
4521
 
4492
- "even": function( elements, argument, not ) {
4493
- var results = [],
4494
- i = not ? 1 : 0,
4495
- len = elements.length;
4496
- for ( ; i < len; i = i + 2 ) {
4497
- results.push( elements[i] );
4498
- }
4499
- return results;
4500
- },
4522
+ "last": createPositionalPseudo(function( matchIndexes, length ) {
4523
+ return [ length - 1 ];
4524
+ }),
4525
+
4526
+ "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
4527
+ return [ argument < 0 ? argument + length : argument ];
4528
+ }),
4501
4529
 
4502
- "odd": function( elements, argument, not ) {
4503
- var results = [],
4504
- i = not ? 0 : 1,
4505
- len = elements.length;
4506
- for ( ; i < len; i = i + 2 ) {
4507
- results.push( elements[i] );
4530
+ "even": createPositionalPseudo(function( matchIndexes, length ) {
4531
+ for ( var i = 0; i < length; i += 2 ) {
4532
+ matchIndexes.push( i );
4508
4533
  }
4509
- return results;
4510
- },
4534
+ return matchIndexes;
4535
+ }),
4511
4536
 
4512
- "lt": function( elements, argument, not ) {
4513
- return not ? elements.slice( +argument ) : elements.slice( 0, +argument );
4514
- },
4537
+ "odd": createPositionalPseudo(function( matchIndexes, length ) {
4538
+ for ( var i = 1; i < length; i += 2 ) {
4539
+ matchIndexes.push( i );
4540
+ }
4541
+ return matchIndexes;
4542
+ }),
4515
4543
 
4516
- "gt": function( elements, argument, not ) {
4517
- return not ? elements.slice( 0, +argument + 1 ) : elements.slice( +argument + 1 );
4518
- },
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
+ }),
4519
4550
 
4520
- "eq": function( elements, argument, not ) {
4521
- var elem = elements.splice( +argument, 1 );
4522
- return not ? elements : elem;
4523
- }
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
+ })
4524
4557
  }
4525
4558
  };
4526
4559
 
@@ -4622,7 +4655,9 @@ baseHasDuplicate = !hasDuplicate;
4622
4655
  // Document sorting and removing duplicates
4623
4656
  Sizzle.uniqueSort = function( results ) {
4624
4657
  var elem,
4625
- i = 1;
4658
+ duplicates = [],
4659
+ i = 1,
4660
+ j = 0;
4626
4661
 
4627
4662
  hasDuplicate = baseHasDuplicate;
4628
4663
  results.sort( sortOrder );
@@ -4630,9 +4665,12 @@ Sizzle.uniqueSort = function( results ) {
4630
4665
  if ( hasDuplicate ) {
4631
4666
  for ( ; (elem = results[i]); i++ ) {
4632
4667
  if ( elem === results[ i - 1 ] ) {
4633
- results.splice( i--, 1 );
4668
+ j = duplicates.push( i );
4634
4669
  }
4635
4670
  }
4671
+ while ( j-- ) {
4672
+ results.splice( duplicates[ j ], 1 );
4673
+ }
4636
4674
  }
4637
4675
 
4638
4676
  return results;
@@ -4642,70 +4680,50 @@ Sizzle.error = function( msg ) {
4642
4680
  throw new Error( "Syntax error, unrecognized expression: " + msg );
4643
4681
  };
4644
4682
 
4645
- function tokenize( selector, context, xml, parseOnly ) {
4683
+ function tokenize( selector, parseOnly ) {
4646
4684
  var matched, match, tokens, type,
4647
- soFar, groups, group, i,
4648
- preFilters, filters,
4649
- checkContext = !xml && context !== document,
4650
- // Token cache should maintain spaces
4651
- key = ( checkContext ? "<s>" : "" ) + selector.replace( rtrim, "$1<s>" ),
4652
- cached = tokenCache[ expando ][ key ];
4685
+ soFar, groups, preFilters,
4686
+ cached = tokenCache[ expando ][ selector + " " ];
4653
4687
 
4654
4688
  if ( cached ) {
4655
- return parseOnly ? 0 : slice.call( cached, 0 );
4689
+ return parseOnly ? 0 : cached.slice( 0 );
4656
4690
  }
4657
4691
 
4658
4692
  soFar = selector;
4659
4693
  groups = [];
4660
- i = 0;
4661
4694
  preFilters = Expr.preFilter;
4662
- filters = Expr.filter;
4663
4695
 
4664
4696
  while ( soFar ) {
4665
4697
 
4666
4698
  // Comma and first run
4667
4699
  if ( !matched || (match = rcomma.exec( soFar )) ) {
4668
4700
  if ( match ) {
4669
- soFar = soFar.slice( match[0].length );
4670
- tokens.selector = group;
4701
+ // Don't consume trailing commas as valid
4702
+ soFar = soFar.slice( match[0].length ) || soFar;
4671
4703
  }
4672
4704
  groups.push( tokens = [] );
4673
- group = "";
4674
-
4675
- // Need to make sure we're within a narrower context if necessary
4676
- // Adding a descendant combinator will generate what is needed
4677
- if ( checkContext ) {
4678
- soFar = " " + soFar;
4679
- }
4680
4705
  }
4681
4706
 
4682
4707
  matched = false;
4683
4708
 
4684
4709
  // Combinators
4685
4710
  if ( (match = rcombinators.exec( soFar )) ) {
4686
- group += match[0];
4687
- soFar = soFar.slice( match[0].length );
4711
+ tokens.push( matched = new Token( match.shift() ) );
4712
+ soFar = soFar.slice( matched.length );
4688
4713
 
4689
4714
  // Cast descendant combinators to space
4690
- matched = tokens.push({
4691
- part: match.pop().replace( rtrim, " " ),
4692
- string: match[0],
4693
- captures: match
4694
- });
4715
+ matched.type = match[0].replace( rtrim, " " );
4695
4716
  }
4696
4717
 
4697
4718
  // Filters
4698
- for ( type in filters ) {
4719
+ for ( type in Expr.filter ) {
4699
4720
  if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
4700
- ( match = preFilters[ type ](match, context, xml) )) ) {
4701
-
4702
- group += match[0];
4703
- soFar = soFar.slice( match[0].length );
4704
- matched = tokens.push({
4705
- part: type,
4706
- string: match.shift(),
4707
- captures: match
4708
- });
4721
+ (match = preFilters[ type ]( match ))) ) {
4722
+
4723
+ tokens.push( matched = new Token( match.shift() ) );
4724
+ soFar = soFar.slice( matched.length );
4725
+ matched.type = type;
4726
+ matched.matches = match;
4709
4727
  }
4710
4728
  }
4711
4729
 
@@ -4714,11 +4732,6 @@ function tokenize( selector, context, xml, parseOnly ) {
4714
4732
  }
4715
4733
  }
4716
4734
 
4717
- // Attach the full group as a selector
4718
- if ( group ) {
4719
- tokens.selector = group;
4720
- }
4721
-
4722
4735
  // Return the length of the invalid excess
4723
4736
  // if we're just parsing
4724
4737
  // Otherwise, throw an error or return tokens
@@ -4727,43 +4740,33 @@ function tokenize( selector, context, xml, parseOnly ) {
4727
4740
  soFar ?
4728
4741
  Sizzle.error( selector ) :
4729
4742
  // Cache the tokens
4730
- slice.call( tokenCache(key, groups), 0 );
4743
+ tokenCache( selector, groups ).slice( 0 );
4731
4744
  }
4732
4745
 
4733
- function addCombinator( matcher, combinator, context, xml ) {
4746
+ function addCombinator( matcher, combinator, base ) {
4734
4747
  var dir = combinator.dir,
4748
+ checkNonElements = base && combinator.dir === "parentNode",
4735
4749
  doneName = done++;
4736
4750
 
4737
- if ( !matcher ) {
4738
- // If there is no matcher to check, check against the context
4739
- matcher = function( elem ) {
4740
- return elem === context;
4741
- };
4742
- }
4743
4751
  return combinator.first ?
4744
- function( elem ) {
4752
+ // Check against closest ancestor/preceding element
4753
+ function( elem, context, xml ) {
4745
4754
  while ( (elem = elem[ dir ]) ) {
4746
- if ( elem.nodeType === 1 ) {
4747
- return matcher( elem ) && elem;
4755
+ if ( checkNonElements || elem.nodeType === 1 ) {
4756
+ return matcher( elem, context, xml );
4748
4757
  }
4749
4758
  }
4750
4759
  } :
4751
- xml ?
4752
- function( elem ) {
4753
- while ( (elem = elem[ dir ]) ) {
4754
- if ( elem.nodeType === 1 ) {
4755
- if ( matcher( elem ) ) {
4756
- return elem;
4757
- }
4758
- }
4759
- }
4760
- } :
4761
- function( 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 ) {
4762
4765
  var cache,
4763
- dirkey = doneName + "." + dirruns,
4764
- cachedkey = dirkey + "." + cachedruns;
4766
+ dirkey = dirruns + " " + doneName + " ",
4767
+ cachedkey = dirkey + cachedruns;
4765
4768
  while ( (elem = elem[ dir ]) ) {
4766
- if ( elem.nodeType === 1 ) {
4769
+ if ( checkNonElements || elem.nodeType === 1 ) {
4767
4770
  if ( (cache = elem[ expando ]) === cachedkey ) {
4768
4771
  return elem.sizset;
4769
4772
  } else if ( typeof cache === "string" && cache.indexOf(dirkey) === 0 ) {
@@ -4772,7 +4775,7 @@ function addCombinator( matcher, combinator, context, xml ) {
4772
4775
  }
4773
4776
  } else {
4774
4777
  elem[ expando ] = cachedkey;
4775
- if ( matcher( elem ) ) {
4778
+ if ( matcher( elem, context, xml ) ) {
4776
4779
  elem.sizset = true;
4777
4780
  return elem;
4778
4781
  }
@@ -4780,254 +4783,394 @@ function addCombinator( matcher, combinator, context, xml ) {
4780
4783
  }
4781
4784
  }
4782
4785
  }
4783
- };
4786
+ } else {
4787
+ while ( (elem = elem[ dir ]) ) {
4788
+ if ( checkNonElements || elem.nodeType === 1 ) {
4789
+ if ( matcher( elem, context, xml ) ) {
4790
+ return elem;
4791
+ }
4792
+ }
4793
+ }
4794
+ }
4795
+ };
4784
4796
  }
4785
4797
 
4786
- function addMatcher( higher, deeper ) {
4787
- return higher ?
4788
- function( elem ) {
4789
- var result = deeper( elem );
4790
- return result && higher( result === true ? elem : result );
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;
4791
4808
  } :
4792
- deeper;
4809
+ matchers[0];
4793
4810
  }
4794
4811
 
4795
- // ["TAG", ">", "ID", " ", "CLASS"]
4796
- function matcherFromTokens( tokens, context, xml ) {
4797
- var token, matcher,
4798
- 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;
4799
4818
 
4800
- for ( ; (token = tokens[i]); i++ ) {
4801
- if ( Expr.relative[ token.part ] ) {
4802
- matcher = addCombinator( matcher, Expr.relative[ token.part ], context, xml );
4803
- } else {
4804
- matcher = addMatcher( matcher, Expr.filter[ token.part ].apply(null, token.captures.concat( context, xml )) );
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
+ }
4805
4827
  }
4806
4828
  }
4807
4829
 
4808
- return matcher;
4830
+ return newUnmatched;
4809
4831
  }
4810
4832
 
4811
- function matcherFromGroupMatchers( matchers ) {
4812
- return function( elem ) {
4813
- var matcher,
4814
- j = 0;
4815
- for ( ; (matcher = matchers[j]); j++ ) {
4816
- if ( matcher(elem) ) {
4817
- return true;
4818
- }
4819
- }
4820
- return false;
4821
- };
4822
- }
4823
-
4824
- compile = Sizzle.compile = function( selector, context, xml ) {
4825
- var group, i, len,
4826
- cached = compilerCache[ expando ][ selector ];
4827
-
4828
- // Return a cached group function if already generated (context dependent)
4829
- if ( cached && cached.context === context ) {
4830
- return cached;
4833
+ function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
4834
+ if ( postFilter && !postFilter[ expando ] ) {
4835
+ postFilter = setMatcher( postFilter );
4831
4836
  }
4832
-
4833
- // Generate a function of recursive functions that can be used to check each element
4834
- group = tokenize( selector, context, xml );
4835
- for ( i = 0, len = group.length; i < len; i++ ) {
4836
- group[i] = matcherFromTokens(group[i], context, xml);
4837
+ if ( postFinder && !postFinder[ expando ] ) {
4838
+ postFinder = setMatcher( postFinder, postSelector );
4837
4839
  }
4840
+ return markFunction(function( seed, results, context, xml ) {
4841
+ var temp, i, elem,
4842
+ preMap = [],
4843
+ postMap = [],
4844
+ preexisting = results.length,
4838
4845
 
4839
- // Cache the compiled function
4840
- cached = compilerCache( selector, matcherFromGroupMatchers(group) );
4841
- cached.context = context;
4842
- cached.runs = cached.dirruns = 0;
4843
- return cached;
4844
- };
4846
+ // Get initial elements from seed or context
4847
+ elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
4845
4848
 
4846
- function multipleContexts( selector, contexts, results, seed ) {
4847
- var i = 0,
4848
- len = contexts.length;
4849
- for ( ; i < len; i++ ) {
4850
- Sizzle( selector, contexts[i], results, seed );
4851
- }
4852
- }
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
4853
 
4854
- function handlePOSGroup( selector, posfilter, argument, contexts, seed, not ) {
4855
- var results,
4856
- fn = Expr.setFilters[ posfilter.toLowerCase() ];
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
4857
 
4858
- if ( !fn ) {
4859
- Sizzle.error( posfilter );
4860
- }
4858
+ // ...intermediate processing is necessary
4859
+ [] :
4861
4860
 
4862
- if ( selector || !(results = seed) ) {
4863
- multipleContexts( selector || "*", contexts, (results = []), seed );
4864
- }
4861
+ // ...otherwise use results directly
4862
+ results :
4863
+ matcherIn;
4865
4864
 
4866
- return results.length > 0 ? fn( results, argument, not ) : [];
4867
- }
4865
+ // Find primary matches
4866
+ if ( matcher ) {
4867
+ matcher( matcherIn, matcherOut, context, xml );
4868
+ }
4868
4869
 
4869
- function handlePOS( groups, context, results, seed ) {
4870
- var group, part, j, groupLen, token, selector,
4871
- anchor, elements, match, matched,
4872
- lastIndex, currentContexts, not,
4873
- i = 0,
4874
- len = groups.length,
4875
- rpos = matchExpr["POS"],
4876
- // This is generated here in case matchExpr["POS"] is extended
4877
- rposgroups = new RegExp( "^" + rpos.source + "(?!" + whitespace + ")", "i" ),
4878
- // This is for making sure non-participating
4879
- // matching groups are represented cross-browser (IE6-8)
4880
- setUndefined = function() {
4881
- var i = 1,
4882
- len = arguments.length - 2;
4883
- for ( ; i < len; i++ ) {
4884
- if ( arguments[i] === undefined ) {
4885
- match[i] = undefined;
4870
+ // Apply postFilter
4871
+ if ( postFilter ) {
4872
+ temp = condense( matcherOut, postMap );
4873
+ postFilter( temp, [], context, xml );
4874
+
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);
4886
4880
  }
4887
4881
  }
4888
- };
4882
+ }
4889
4883
 
4890
- for ( ; i < len; i++ ) {
4891
- group = groups[i];
4892
- part = "";
4893
- elements = seed;
4894
- for ( j = 0, groupLen = group.length; j < groupLen; j++ ) {
4895
- token = group[j];
4896
- selector = token.string;
4897
- if ( token.part === "PSEUDO" ) {
4898
- // Reset regex index to 0
4899
- rpos.exec("");
4900
- anchor = 0;
4901
- while ( (match = rpos.exec( selector )) ) {
4902
- matched = true;
4903
- lastIndex = rpos.lastIndex = match.index + match[0].length;
4904
- if ( lastIndex > anchor ) {
4905
- part += selector.slice( anchor, match.index );
4906
- anchor = lastIndex;
4907
- currentContexts = [ context ];
4908
-
4909
- if ( rcombinators.test(part) ) {
4910
- if ( elements ) {
4911
- currentContexts = elements;
4912
- }
4913
- elements = seed;
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) );
4914
4894
  }
4895
+ }
4896
+ postFinder( null, (matcherOut = []), temp, xml );
4897
+ }
4915
4898
 
4916
- if ( (not = rendsWithNot.test( part )) ) {
4917
- part = part.slice( 0, -5 ).replace( rcombinators, "$&*" );
4918
- anchor++;
4919
- }
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 ) {
4920
4904
 
4921
- if ( match.length > 1 ) {
4922
- match[0].replace( rposgroups, setUndefined );
4923
- }
4924
- elements = handlePOSGroup( part, match[1], match[2], currentContexts, elements, not );
4905
+ seed[temp] = !(results[temp] = elem);
4925
4906
  }
4926
- part = "";
4927
4907
  }
4928
-
4929
4908
  }
4930
4909
 
4931
- if ( !matched ) {
4932
- part += selector;
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 );
4933
4921
  }
4934
- matched = false;
4935
4922
  }
4923
+ });
4924
+ }
4936
4925
 
4937
- if ( part ) {
4938
- if ( rcombinators.test(part) ) {
4939
- multipleContexts( part, elements || [ context ], results, seed );
4940
- } else {
4941
- Sizzle( part, context, results, seed ? seed.concat(elements) : elements );
4942
- }
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 ) ];
4943
4950
  } else {
4944
- push.apply( results, elements );
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 );
4945
4972
  }
4946
4973
  }
4947
4974
 
4948
- // Do not sort if this is a single filter
4949
- return len === 1 ? results : Sizzle.uniqueSort( results );
4975
+ return elementMatcher( matchers );
4950
4976
  }
4951
4977
 
4952
- function select( selector, context, results, seed, xml ) {
4953
- // Remove excessive whitespace
4954
- selector = selector.replace( rtrim, "$1" );
4955
- var elements, matcher, cached, elem,
4956
- i, tokens, token, lastToken, findContext, type,
4957
- match = tokenize( selector, context, xml ),
4958
- contextNodeType = context.nodeType;
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
+ }
4998
+
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
+ }
4959
5013
 
4960
- // POS handling
4961
- if ( matchExpr["POS"].test(selector) ) {
4962
- return handlePOS( match, context, results, seed );
4963
- }
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
+ }
5020
+
5021
+ // Lengthen the array for every element, matched or not
5022
+ if ( seed ) {
5023
+ unmatched.push( elem );
5024
+ }
5025
+ }
5026
+ }
4964
5027
 
4965
- if ( seed ) {
4966
- elements = slice.call( seed, 0 );
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
+ }
4967
5034
 
4968
- // To maintain document order, only narrow the
4969
- // set if there is one group
4970
- } else if ( match.length === 1 ) {
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
+ }
4971
5044
 
4972
- // Take a shortcut and set the context if the root selector is an ID
4973
- if ( (tokens = slice.call( match[0], 0 )).length > 2 &&
4974
- (token = tokens[0]).part === "ID" &&
4975
- contextNodeType === 9 && !xml &&
4976
- Expr.relative[ tokens[1].part ] ) {
5045
+ // Discard index placeholder values to get only actual matches
5046
+ setMatched = condense( setMatched );
5047
+ }
4977
5048
 
4978
- context = Expr.find["ID"]( token.captures[0].replace( rbackslash, "" ), context, xml )[0];
4979
- if ( !context ) {
4980
- return results;
4981
- }
5049
+ // Add matches to results
5050
+ push.apply( results, setMatched );
4982
5051
 
4983
- selector = selector.slice( tokens.shift().string.length );
4984
- }
5052
+ // Seedless set matches succeeding multiple successful matchers stipulate sorting
5053
+ if ( outermost && !seed && setMatched.length > 0 &&
5054
+ ( matchedCount + setMatchers.length ) > 1 ) {
4985
5055
 
4986
- findContext = ( (match = rsibling.exec( tokens[0].string )) && !match.index && context.parentNode ) || context;
5056
+ Sizzle.uniqueSort( results );
5057
+ }
5058
+ }
4987
5059
 
4988
- // Reduce the set if possible
4989
- lastToken = "";
4990
- for ( i = tokens.length - 1; i >= 0; i-- ) {
4991
- token = tokens[i];
4992
- type = token.part;
4993
- lastToken = token.string + lastToken;
4994
- if ( Expr.relative[ type ] ) {
4995
- break;
5060
+ // Override manipulation of globals by nested matchers
5061
+ if ( outermost ) {
5062
+ dirruns = dirrunsUnique;
5063
+ outermostContext = contextBackup;
4996
5064
  }
4997
- if ( Expr.order.test(type) ) {
4998
- elements = Expr.find[ type ]( token.captures[0].replace( rbackslash, "" ), findContext, xml );
4999
- if ( elements == null ) {
5000
- continue;
5001
- } else {
5002
- selector = selector.slice( 0, selector.length - lastToken.length ) +
5003
- lastToken.replace( matchExpr[ type ], "" );
5004
5065
 
5005
- if ( !selector ) {
5006
- push.apply( results, slice.call(elements, 0) );
5007
- }
5066
+ return unmatched;
5067
+ };
5008
5068
 
5009
- break;
5010
- }
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 );
5011
5093
  }
5012
5094
  }
5095
+
5096
+ // Cache the compiled function
5097
+ cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
5013
5098
  }
5099
+ return cached;
5100
+ };
5014
5101
 
5015
- // Only loop over the given elements once
5016
- if ( selector ) {
5017
- matcher = compile( selector, context, xml );
5018
- dirruns = matcher.dirruns++;
5019
- if ( elements == null ) {
5020
- elements = Expr.find["TAG"]( "*", (rsibling.test( selector ) && context.parentNode) || context );
5021
- }
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 );
5107
+ }
5108
+ return results;
5109
+ }
5110
+
5111
+ function select( selector, context, results, seed, xml ) {
5112
+ var i, tokens, token, type, find,
5113
+ match = tokenize( selector ),
5114
+ j = match.length;
5115
+
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
+ }
5022
5130
 
5023
- for ( i = 0; (elem = elements[i]); i++ ) {
5024
- cachedruns = matcher.runs++;
5025
- if ( matcher(elem) ) {
5026
- results.push( elem );
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
+ }
5027
5161
  }
5028
5162
  }
5029
5163
  }
5030
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
+ );
5031
5174
  return results;
5032
5175
  }
5033
5176
 
@@ -5037,11 +5180,15 @@ if ( document.querySelectorAll ) {
5037
5180
  oldSelect = select,
5038
5181
  rescape = /'|\\/g,
5039
5182
  rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,
5040
- 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
+
5041
5188
  // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
5042
5189
  // A support test would require too much code (would include document ready)
5043
5190
  // just skip matchesSelector for :active
5044
- rbuggyMatches = [":active"],
5191
+ rbuggyMatches = [ ":active" ],
5045
5192
  matches = docElem.matchesSelector ||
5046
5193
  docElem.mozMatchesSelector ||
5047
5194
  docElem.webkitMatchesSelector ||
@@ -5088,44 +5235,46 @@ if ( document.querySelectorAll ) {
5088
5235
  }
5089
5236
  });
5090
5237
 
5091
- 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("|") );
5092
5240
 
5093
5241
  select = function( selector, context, results, seed, xml ) {
5094
5242
  // Only use querySelectorAll when not filtering,
5095
5243
  // when this is not xml,
5096
5244
  // and when no QSA bugs apply
5097
- if ( !seed && !xml && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
5098
- if ( context.nodeType === 9 ) {
5099
- try {
5100
- push.apply( results, slice.call(context.querySelectorAll( selector ), 0) );
5101
- return results;
5102
- } 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
+
5103
5252
  // qSA works strangely on Element-rooted queries
5104
5253
  // We can work around this by specifying an extra ID on the root
5105
5254
  // and working up from there (Thanks to Andrew Dupont for the technique)
5106
5255
  // IE 8 doesn't work on object elements
5107
- } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
5108
- var groups, i, len,
5109
- old = context.getAttribute("id"),
5110
- nid = old || expando,
5111
- newContext = rsibling.test( selector ) && context.parentNode || context;
5256
+ if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
5257
+ groups = tokenize( selector );
5112
5258
 
5113
- if ( old ) {
5114
- nid = nid.replace( rescape, "\\$&" );
5259
+ if ( (old = context.getAttribute("id")) ) {
5260
+ nid = old.replace( rescape, "\\$&" );
5115
5261
  } else {
5116
5262
  context.setAttribute( "id", nid );
5117
5263
  }
5264
+ nid = "[id='" + nid + "'] ";
5118
5265
 
5119
- groups = tokenize(selector, context, xml);
5120
- // Trailing space is unnecessary
5121
- // There is always a context check
5122
- nid = "[id='" + nid + "']";
5123
- for ( i = 0, len = groups.length; i < len; i++ ) {
5124
- groups[i] = nid + groups[i].selector;
5266
+ i = groups.length;
5267
+ while ( i-- ) {
5268
+ groups[i] = nid + groups[i].join("");
5125
5269
  }
5270
+ newContext = rsibling.test( selector ) && context.parentNode || context;
5271
+ newSelector = groups.join(",");
5272
+ }
5273
+
5274
+ if ( newSelector ) {
5126
5275
  try {
5127
5276
  push.apply( results, slice.call( newContext.querySelectorAll(
5128
- groups.join(",")
5277
+ newSelector
5129
5278
  ), 0 ) );
5130
5279
  return results;
5131
5280
  } catch(qsaError) {
@@ -5150,11 +5299,11 @@ if ( document.querySelectorAll ) {
5150
5299
  // Gecko does not error, returns false instead
5151
5300
  try {
5152
5301
  matches.call( div, "[test!='']:sizzle" );
5153
- rbuggyMatches.push( matchExpr["PSEUDO"].source, matchExpr["POS"].source, "!=" );
5302
+ rbuggyMatches.push( "!=", pseudos );
5154
5303
  } catch ( e ) {}
5155
5304
  });
5156
5305
 
5157
- // 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
5158
5307
  rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") );
5159
5308
 
5160
5309
  Sizzle.matchesSelector = function( elem, expr ) {
@@ -5162,7 +5311,7 @@ if ( document.querySelectorAll ) {
5162
5311
  expr = expr.replace( rattributeQuotes, "='$1']" );
5163
5312
 
5164
5313
  // rbuggyMatches always contains :active, so no need for an existence check
5165
- if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && (!rbuggyQSA || !rbuggyQSA.test( expr )) ) {
5314
+ if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && !rbuggyQSA.test( expr ) ) {
5166
5315
  try {
5167
5316
  var ret = matches.call( elem, expr );
5168
5317
 
@@ -5183,10 +5332,12 @@ if ( document.querySelectorAll ) {
5183
5332
  }
5184
5333
 
5185
5334
  // Deprecated
5186
- Expr.setFilters["nth"] = Expr.setFilters["eq"];
5335
+ Expr.pseudos["nth"] = Expr.pseudos["eq"];
5187
5336
 
5188
5337
  // Back-compat
5189
- Expr.filters = Expr.pseudos;
5338
+ function setFilters() {}
5339
+ Expr.filters = setFilters.prototype = Expr.pseudos;
5340
+ Expr.setFilters = new setFilters();
5190
5341
 
5191
5342
  // Override sizzle attribute retrieval
5192
5343
  Sizzle.attr = jQuery.attr;
@@ -6395,7 +6546,7 @@ var curCSS, iframe, iframeDoc,
6395
6546
  rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
6396
6547
  rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
6397
6548
  rrelNum = new RegExp( "^([-+])=(" + core_pnum + ")", "i" ),
6398
- elemdisplay = {},
6549
+ elemdisplay = { BODY: "block" },
6399
6550
 
6400
6551
  cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6401
6552
  cssNormalTransform = {
@@ -6676,7 +6827,9 @@ if ( window.getComputedStyle ) {
6676
6827
 
6677
6828
  if ( computed ) {
6678
6829
 
6679
- ret = computed[ name ];
6830
+ // getPropertyValue is only needed for .css('filter') in IE9, see #12537
6831
+ ret = computed.getPropertyValue( name ) || computed[ name ];
6832
+
6680
6833
  if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
6681
6834
  ret = jQuery.style( elem, name );
6682
6835
  }
@@ -7123,10 +7276,10 @@ function buildParams( prefix, obj, traditional, add ) {
7123
7276
  add( prefix, obj );
7124
7277
  }
7125
7278
  }
7126
- var // Document location
7127
- ajaxLocation,
7128
- // Document location segments
7279
+ var
7280
+ // Document location
7129
7281
  ajaxLocParts,
7282
+ ajaxLocation,
7130
7283
 
7131
7284
  rhash = /#.*$/,
7132
7285
  rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
@@ -7643,7 +7796,7 @@ jQuery.extend({
7643
7796
 
7644
7797
  // Set data for the fake xhr object
7645
7798
  jqXHR.status = status;
7646
- jqXHR.statusText = "" + ( nativeStatusText || statusText );
7799
+ jqXHR.statusText = ( nativeStatusText || statusText ) + "";
7647
7800
 
7648
7801
  // Success/Error
7649
7802
  if ( isSuccess ) {
@@ -7703,11 +7856,11 @@ jQuery.extend({
7703
7856
  // Extract dataTypes list
7704
7857
  s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace );
7705
7858
 
7706
- // 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
7707
7860
  if ( s.crossDomain == null ) {
7708
7861
  parts = rurl.exec( s.url.toLowerCase() );
7709
7862
  s.crossDomain = !!( parts &&
7710
- ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
7863
+ ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
7711
7864
  ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
7712
7865
  ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
7713
7866
  );
@@ -8329,7 +8482,7 @@ if ( jQuery.support.ajax ) {
8329
8482
  // on any attempt to access responseText (#11426)
8330
8483
  try {
8331
8484
  responses.text = xhr.responseText;
8332
- } catch( _ ) {
8485
+ } catch( e ) {
8333
8486
  }
8334
8487
 
8335
8488
  // Firefox throws an exception when accessing
@@ -8405,12 +8558,13 @@ var fxNow, timerId,
8405
8558
  animationPrefilters = [ defaultPrefilter ],
8406
8559
  tweeners = {
8407
8560
  "*": [function( prop, value ) {
8408
- var end, unit, prevScale,
8561
+ var end, unit,
8409
8562
  tween = this.createTween( prop, value ),
8410
8563
  parts = rfxnum.exec( value ),
8411
8564
  target = tween.cur(),
8412
8565
  start = +target || 0,
8413
- scale = 1;
8566
+ scale = 1,
8567
+ maxIterations = 20;
8414
8568
 
8415
8569
  if ( parts ) {
8416
8570
  end = +parts[2];
@@ -8426,17 +8580,15 @@ var fxNow, timerId,
8426
8580
  do {
8427
8581
  // If previous iteration zeroed out, double until we get *something*
8428
8582
  // Use a string for doubling factor so we don't accidentally see scale as unchanged below
8429
- prevScale = scale = scale || ".5";
8583
+ scale = scale || ".5";
8430
8584
 
8431
8585
  // Adjust and apply
8432
8586
  start = start / scale;
8433
8587
  jQuery.style( tween.elem, prop, start + unit );
8434
8588
 
8435
- // Update scale, tolerating zeroes from tween.cur()
8436
- scale = tween.cur() / target;
8437
-
8438
- // Stop looping if we've hit the mark or scale is unchanged
8439
- } 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 );
8440
8592
  }
8441
8593
 
8442
8594
  tween.unit = unit;
@@ -8483,7 +8635,9 @@ function Animation( elem, properties, options ) {
8483
8635
  tick = function() {
8484
8636
  var currentTime = fxNow || createFxNow(),
8485
8637
  remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
8486
- 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,
8487
8641
  index = 0,
8488
8642
  length = animation.tweens.length;
8489
8643
 
@@ -8635,7 +8789,7 @@ jQuery.Animation = jQuery.extend( Animation, {
8635
8789
  });
8636
8790
 
8637
8791
  function defaultPrefilter( elem, props, opts ) {
8638
- var index, prop, value, length, dataShow, tween, hooks, oldfire,
8792
+ var index, prop, value, length, dataShow, toggle, tween, hooks, oldfire,
8639
8793
  anim = this,
8640
8794
  style = elem.style,
8641
8795
  orig = {},
@@ -8709,6 +8863,7 @@ function defaultPrefilter( elem, props, opts ) {
8709
8863
  value = props[ index ];
8710
8864
  if ( rfxtypes.exec( value ) ) {
8711
8865
  delete props[ index ];
8866
+ toggle = toggle || value === "toggle";
8712
8867
  if ( value === ( hidden ? "hide" : "show" ) ) {
8713
8868
  continue;
8714
8869
  }
@@ -8719,6 +8874,14 @@ function defaultPrefilter( elem, props, opts ) {
8719
8874
  length = handled.length;
8720
8875
  if ( length ) {
8721
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
+ }
8722
8885
  if ( hidden ) {
8723
8886
  jQuery( elem ).show();
8724
8887
  } else {
@@ -9015,6 +9178,8 @@ jQuery.fx.tick = function() {
9015
9178
  timers = jQuery.timers,
9016
9179
  i = 0;
9017
9180
 
9181
+ fxNow = jQuery.now();
9182
+
9018
9183
  for ( ; i < timers.length; i++ ) {
9019
9184
  timer = timers[ i ];
9020
9185
  // Checks the timer has not already been removed
@@ -9026,6 +9191,7 @@ jQuery.fx.tick = function() {
9026
9191
  if ( !timers.length ) {
9027
9192
  jQuery.fx.stop();
9028
9193
  }
9194
+ fxNow = undefined;
9029
9195
  };
9030
9196
 
9031
9197
  jQuery.fx.timer = function( timer ) {
@@ -9069,7 +9235,8 @@ jQuery.fn.offset = function( options ) {
9069
9235
  });
9070
9236
  }
9071
9237
 
9072
- 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 },
9073
9240
  elem = this[ 0 ],
9074
9241
  doc = elem && elem.ownerDocument;
9075
9242
 
@@ -9083,21 +9250,25 @@ jQuery.fn.offset = function( options ) {
9083
9250
 
9084
9251
  docElem = doc.documentElement;
9085
9252
 
9086
- // Make sure we're not dealing with a disconnected DOM node
9253
+ // Make sure it's not a disconnected DOM node
9087
9254
  if ( !jQuery.contains( docElem, elem ) ) {
9088
- return { top: 0, left: 0 };
9255
+ return box;
9089
9256
  }
9090
9257
 
9091
- 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
+ }
9092
9263
  win = getWindow( doc );
9093
9264
  clientTop = docElem.clientTop || body.clientTop || 0;
9094
9265
  clientLeft = docElem.clientLeft || body.clientLeft || 0;
9095
9266
  scrollTop = win.pageYOffset || docElem.scrollTop;
9096
9267
  scrollLeft = win.pageXOffset || docElem.scrollLeft;
9097
- top = box.top + scrollTop - clientTop;
9098
- left = box.left + scrollLeft - clientLeft;
9099
-
9100
- return { top: top, left: left };
9268
+ return {
9269
+ top: box.top + scrollTop - clientTop,
9270
+ left: box.left + scrollLeft - clientLeft
9271
+ };
9101
9272
  };
9102
9273
 
9103
9274
  jQuery.offset = {