Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | /*! |
| 2 | * Sizzle CSS Selector Engine v2.3.4 |
| 3 | * https://sizzlejs.com/ |
| 4 | * |
| 5 | * Copyright JS Foundation and other contributors |
| 6 | * Released under the MIT license |
| 7 | * https://js.foundation/ |
| 8 | * |
| 9 | * Date: 2019-04-08 |
| 10 | */ |
| 11 | (function( window ) { |
| 12 | |
| 13 | var i, |
| 14 | support, |
| 15 | Expr, |
| 16 | getText, |
| 17 | isXML, |
| 18 | tokenize, |
| 19 | compile, |
| 20 | select, |
| 21 | outermostContext, |
| 22 | sortInput, |
| 23 | hasDuplicate, |
| 24 | |
| 25 | // Local document vars |
| 26 | setDocument, |
| 27 | document, |
| 28 | docElem, |
| 29 | documentIsHTML, |
| 30 | rbuggyQSA, |
| 31 | rbuggyMatches, |
| 32 | matches, |
| 33 | contains, |
| 34 | |
| 35 | // Instance-specific data |
| 36 | expando = "sizzle" + 1 * new Date(), |
| 37 | preferredDoc = window.document, |
| 38 | dirruns = 0, |
| 39 | done = 0, |
| 40 | classCache = createCache(), |
| 41 | tokenCache = createCache(), |
| 42 | compilerCache = createCache(), |
| 43 | nonnativeSelectorCache = createCache(), |
| 44 | sortOrder = function( a, b ) { |
| 45 | if ( a === b ) { |
| 46 | hasDuplicate = true; |
| 47 | } |
| 48 | return 0; |
| 49 | }, |
| 50 | |
| 51 | // Instance methods |
| 52 | hasOwn = ({}).hasOwnProperty, |
| 53 | arr = [], |
| 54 | pop = arr.pop, |
| 55 | push_native = arr.push, |
| 56 | push = arr.push, |
| 57 | slice = arr.slice, |
| 58 | // Use a stripped-down indexOf as it's faster than native |
| 59 | // https://jsperf.com/thor-indexof-vs-for/5 |
| 60 | indexOf = function( list, elem ) { |
| 61 | var i = 0, |
| 62 | len = list.length; |
| 63 | for ( ; i < len; i++ ) { |
| 64 | if ( list[i] === elem ) { |
| 65 | return i; |
| 66 | } |
| 67 | } |
| 68 | return -1; |
| 69 | }, |
| 70 | |
| 71 | booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", |
| 72 | |
| 73 | // Regular expressions |
| 74 | |
| 75 | // http://www.w3.org/TR/css3-selectors/#whitespace |
| 76 | whitespace = "[\\x20\\t\\r\\n\\f]", |
| 77 | |
| 78 | // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier |
| 79 | identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+", |
| 80 | |
| 81 | // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors |
| 82 | attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + |
| 83 | // Operator (capture 2) |
| 84 | "*([*^$|!~]?=)" + whitespace + |
| 85 | // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" |
| 86 | "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + |
| 87 | "*\\]", |
| 88 | |
| 89 | pseudos = ":(" + identifier + ")(?:\\((" + |
| 90 | // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: |
| 91 | // 1. quoted (capture 3; capture 4 or capture 5) |
| 92 | "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + |
| 93 | // 2. simple (capture 6) |
| 94 | "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + |
| 95 | // 3. anything else (capture 2) |
| 96 | ".*" + |
| 97 | ")\\)|)", |
| 98 | |
| 99 | // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter |
| 100 | rwhitespace = new RegExp( whitespace + "+", "g" ), |
| 101 | rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), |
| 102 | |
| 103 | rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), |
| 104 | rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), |
| 105 | rdescend = new RegExp( whitespace + "|>" ), |
| 106 | |
| 107 | rpseudo = new RegExp( pseudos ), |
| 108 | ridentifier = new RegExp( "^" + identifier + "$" ), |
| 109 | |
| 110 | matchExpr = { |
| 111 | "ID": new RegExp( "^#(" + identifier + ")" ), |
| 112 | "CLASS": new RegExp( "^\\.(" + identifier + ")" ), |
| 113 | "TAG": new RegExp( "^(" + identifier + "|[*])" ), |
| 114 | "ATTR": new RegExp( "^" + attributes ), |
| 115 | "PSEUDO": new RegExp( "^" + pseudos ), |
| 116 | "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + |
| 117 | "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + |
| 118 | "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), |
| 119 | "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), |
| 120 | // For use in libraries implementing .is() |
| 121 | // We use this for POS matching in `select` |
| 122 | "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + |
| 123 | whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) |
| 124 | }, |
| 125 | |
| 126 | rhtml = /HTML$/i, |
| 127 | rinputs = /^(?:input|select|textarea|button)$/i, |
| 128 | rheader = /^h\d$/i, |
| 129 | |
| 130 | rnative = /^[^{]+\{\s*\[native \w/, |
| 131 | |
| 132 | // Easily-parseable/retrievable ID or TAG or CLASS selectors |
| 133 | rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, |
| 134 | |
| 135 | rsibling = /[+~]/, |
| 136 | |
| 137 | // CSS escapes |
| 138 | // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters |
| 139 | runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), |
| 140 | funescape = function( _, escaped, escapedWhitespace ) { |
| 141 | var high = "0x" + escaped - 0x10000; |
| 142 | // NaN means non-codepoint |
| 143 | // Support: Firefox<24 |
| 144 | // Workaround erroneous numeric interpretation of +"0x" |
| 145 | return high !== high || escapedWhitespace ? |
| 146 | escaped : |
| 147 | high < 0 ? |
| 148 | // BMP codepoint |
| 149 | String.fromCharCode( high + 0x10000 ) : |
| 150 | // Supplemental Plane codepoint (surrogate pair) |
| 151 | String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); |
| 152 | }, |
| 153 | |
| 154 | // CSS string/identifier serialization |
| 155 | // https://drafts.csswg.org/cssom/#common-serializing-idioms |
| 156 | rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g, |
| 157 | fcssescape = function( ch, asCodePoint ) { |
| 158 | if ( asCodePoint ) { |
| 159 | |
| 160 | // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER |
| 161 | if ( ch === "\0" ) { |
| 162 | return "\uFFFD"; |
| 163 | } |
| 164 | |
| 165 | // Control characters and (dependent upon position) numbers get escaped as code points |
| 166 | return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; |
| 167 | } |
| 168 | |
| 169 | // Other potentially-special ASCII characters get backslash-escaped |
| 170 | return "\\" + ch; |
| 171 | }, |
| 172 | |
| 173 | // Used for iframes |
| 174 | // See setDocument() |
| 175 | // Removing the function wrapper causes a "Permission Denied" |
| 176 | // error in IE |
| 177 | unloadHandler = function() { |
| 178 | setDocument(); |
| 179 | }, |
| 180 | |
| 181 | inDisabledFieldset = addCombinator( |
| 182 | function( elem ) { |
| 183 | return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset"; |
| 184 | }, |
| 185 | { dir: "parentNode", next: "legend" } |
| 186 | ); |
| 187 | |
| 188 | // Optimize for push.apply( _, NodeList ) |
| 189 | try { |
| 190 | push.apply( |
| 191 | (arr = slice.call( preferredDoc.childNodes )), |
| 192 | preferredDoc.childNodes |
| 193 | ); |
| 194 | // Support: Android<4.0 |
| 195 | // Detect silently failing push.apply |
| 196 | arr[ preferredDoc.childNodes.length ].nodeType; |
| 197 | } catch ( e ) { |
| 198 | push = { apply: arr.length ? |
| 199 | |
| 200 | // Leverage slice if possible |
| 201 | function( target, els ) { |
| 202 | push_native.apply( target, slice.call(els) ); |
| 203 | } : |
| 204 | |
| 205 | // Support: IE<9 |
| 206 | // Otherwise append directly |
| 207 | function( target, els ) { |
| 208 | var j = target.length, |
| 209 | i = 0; |
| 210 | // Can't trust NodeList.length |
| 211 | while ( (target[j++] = els[i++]) ) {} |
| 212 | target.length = j - 1; |
| 213 | } |
| 214 | }; |
| 215 | } |
| 216 | |
| 217 | function Sizzle( selector, context, results, seed ) { |
| 218 | var m, i, elem, nid, match, groups, newSelector, |
| 219 | newContext = context && context.ownerDocument, |
| 220 | |
| 221 | // nodeType defaults to 9, since context defaults to document |
| 222 | nodeType = context ? context.nodeType : 9; |
| 223 | |
| 224 | results = results || []; |
| 225 | |
| 226 | // Return early from calls with invalid selector or context |
| 227 | if ( typeof selector !== "string" || !selector || |
| 228 | nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { |
| 229 | |
| 230 | return results; |
| 231 | } |
| 232 | |
| 233 | // Try to shortcut find operations (as opposed to filters) in HTML documents |
| 234 | if ( !seed ) { |
| 235 | |
| 236 | if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { |
| 237 | setDocument( context ); |
| 238 | } |
| 239 | context = context || document; |
| 240 | |
| 241 | if ( documentIsHTML ) { |
| 242 | |
| 243 | // If the selector is sufficiently simple, try using a "get*By*" DOM method |
| 244 | // (excepting DocumentFragment context, where the methods don't exist) |
| 245 | if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { |
| 246 | |
| 247 | // ID selector |
| 248 | if ( (m = match[1]) ) { |
| 249 | |
| 250 | // Document context |
| 251 | if ( nodeType === 9 ) { |
| 252 | if ( (elem = context.getElementById( m )) ) { |
| 253 | |
| 254 | // Support: IE, Opera, Webkit |
| 255 | // TODO: identify versions |
| 256 | // getElementById can match elements by name instead of ID |
| 257 | if ( elem.id === m ) { |
| 258 | results.push( elem ); |
| 259 | return results; |
| 260 | } |
| 261 | } else { |
| 262 | return results; |
| 263 | } |
| 264 | |
| 265 | // Element context |
| 266 | } else { |
| 267 | |
| 268 | // Support: IE, Opera, Webkit |
| 269 | // TODO: identify versions |
| 270 | // getElementById can match elements by name instead of ID |
| 271 | if ( newContext && (elem = newContext.getElementById( m )) && |
| 272 | contains( context, elem ) && |
| 273 | elem.id === m ) { |
| 274 | |
| 275 | results.push( elem ); |
| 276 | return results; |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | // Type selector |
| 281 | } else if ( match[2] ) { |
| 282 | push.apply( results, context.getElementsByTagName( selector ) ); |
| 283 | return results; |
| 284 | |
| 285 | // Class selector |
| 286 | } else if ( (m = match[3]) && support.getElementsByClassName && |
| 287 | context.getElementsByClassName ) { |
| 288 | |
| 289 | push.apply( results, context.getElementsByClassName( m ) ); |
| 290 | return results; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | // Take advantage of querySelectorAll |
| 295 | if ( support.qsa && |
| 296 | !nonnativeSelectorCache[ selector + " " ] && |
| 297 | (!rbuggyQSA || !rbuggyQSA.test( selector )) && |
| 298 | |
| 299 | // Support: IE 8 only |
| 300 | // Exclude object elements |
| 301 | (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) { |
| 302 | |
| 303 | newSelector = selector; |
| 304 | newContext = context; |
| 305 | |
| 306 | // qSA considers elements outside a scoping root when evaluating child or |
| 307 | // descendant combinators, which is not what we want. |
| 308 | // In such cases, we work around the behavior by prefixing every selector in the |
| 309 | // list with an ID selector referencing the scope context. |
| 310 | // Thanks to Andrew Dupont for this technique. |
| 311 | if ( nodeType === 1 && rdescend.test( selector ) ) { |
| 312 | |
| 313 | // Capture the context ID, setting it first if necessary |
| 314 | if ( (nid = context.getAttribute( "id" )) ) { |
| 315 | nid = nid.replace( rcssescape, fcssescape ); |
| 316 | } else { |
| 317 | context.setAttribute( "id", (nid = expando) ); |
| 318 | } |
| 319 | |
| 320 | // Prefix every selector in the list |
| 321 | groups = tokenize( selector ); |
| 322 | i = groups.length; |
| 323 | while ( i-- ) { |
| 324 | groups[i] = "#" + nid + " " + toSelector( groups[i] ); |
| 325 | } |
| 326 | newSelector = groups.join( "," ); |
| 327 | |
| 328 | // Expand context for sibling selectors |
| 329 | newContext = rsibling.test( selector ) && testContext( context.parentNode ) || |
| 330 | context; |
| 331 | } |
| 332 | |
| 333 | try { |
| 334 | push.apply( results, |
| 335 | newContext.querySelectorAll( newSelector ) |
| 336 | ); |
| 337 | return results; |
| 338 | } catch ( qsaError ) { |
| 339 | nonnativeSelectorCache( selector, true ); |
| 340 | } finally { |
| 341 | if ( nid === expando ) { |
| 342 | context.removeAttribute( "id" ); |
| 343 | } |
| 344 | } |
| 345 | } |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | // All others |
| 350 | return select( selector.replace( rtrim, "$1" ), context, results, seed ); |
| 351 | } |
| 352 | |
| 353 | /** |
| 354 | * Create key-value caches of limited size |
| 355 | * @returns {function(string, object)} Returns the Object data after storing it on itself with |
| 356 | * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) |
| 357 | * deleting the oldest entry |
| 358 | */ |
| 359 | function createCache() { |
| 360 | var keys = []; |
| 361 | |
| 362 | function cache( key, value ) { |
| 363 | // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) |
| 364 | if ( keys.push( key + " " ) > Expr.cacheLength ) { |
| 365 | // Only keep the most recent entries |
| 366 | delete cache[ keys.shift() ]; |
| 367 | } |
| 368 | return (cache[ key + " " ] = value); |
| 369 | } |
| 370 | return cache; |
| 371 | } |
| 372 | |
| 373 | /** |
| 374 | * Mark a function for special use by Sizzle |
| 375 | * @param {Function} fn The function to mark |
| 376 | */ |
| 377 | function markFunction( fn ) { |
| 378 | fn[ expando ] = true; |
| 379 | return fn; |
| 380 | } |
| 381 | |
| 382 | /** |
| 383 | * Support testing using an element |
| 384 | * @param {Function} fn Passed the created element and returns a boolean result |
| 385 | */ |
| 386 | function assert( fn ) { |
| 387 | var el = document.createElement("fieldset"); |
| 388 | |
| 389 | try { |
| 390 | return !!fn( el ); |
| 391 | } catch (e) { |
| 392 | return false; |
| 393 | } finally { |
| 394 | // Remove from its parent by default |
| 395 | if ( el.parentNode ) { |
| 396 | el.parentNode.removeChild( el ); |
| 397 | } |
| 398 | // release memory in IE |
| 399 | el = null; |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | /** |
| 404 | * Adds the same handler for all of the specified attrs |
| 405 | * @param {String} attrs Pipe-separated list of attributes |
| 406 | * @param {Function} handler The method that will be applied |
| 407 | */ |
| 408 | function addHandle( attrs, handler ) { |
| 409 | var arr = attrs.split("|"), |
| 410 | i = arr.length; |
| 411 | |
| 412 | while ( i-- ) { |
| 413 | Expr.attrHandle[ arr[i] ] = handler; |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | /** |
| 418 | * Checks document order of two siblings |
| 419 | * @param {Element} a |
| 420 | * @param {Element} b |
| 421 | * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b |
| 422 | */ |
| 423 | function siblingCheck( a, b ) { |
| 424 | var cur = b && a, |
| 425 | diff = cur && a.nodeType === 1 && b.nodeType === 1 && |
| 426 | a.sourceIndex - b.sourceIndex; |
| 427 | |
| 428 | // Use IE sourceIndex if available on both nodes |
| 429 | if ( diff ) { |
| 430 | return diff; |
| 431 | } |
| 432 | |
| 433 | // Check if b follows a |
| 434 | if ( cur ) { |
| 435 | while ( (cur = cur.nextSibling) ) { |
| 436 | if ( cur === b ) { |
| 437 | return -1; |
| 438 | } |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | return a ? 1 : -1; |
| 443 | } |
| 444 | |
| 445 | /** |
| 446 | * Returns a function to use in pseudos for input types |
| 447 | * @param {String} type |
| 448 | */ |
| 449 | function createInputPseudo( type ) { |
| 450 | return function( elem ) { |
| 451 | var name = elem.nodeName.toLowerCase(); |
| 452 | return name === "input" && elem.type === type; |
| 453 | }; |
| 454 | } |
| 455 | |
| 456 | /** |
| 457 | * Returns a function to use in pseudos for buttons |
| 458 | * @param {String} type |
| 459 | */ |
| 460 | function createButtonPseudo( type ) { |
| 461 | return function( elem ) { |
| 462 | var name = elem.nodeName.toLowerCase(); |
| 463 | return (name === "input" || name === "button") && elem.type === type; |
| 464 | }; |
| 465 | } |
| 466 | |
| 467 | /** |
| 468 | * Returns a function to use in pseudos for :enabled/:disabled |
| 469 | * @param {Boolean} disabled true for :disabled; false for :enabled |
| 470 | */ |
| 471 | function createDisabledPseudo( disabled ) { |
| 472 | |
| 473 | // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable |
| 474 | return function( elem ) { |
| 475 | |
| 476 | // Only certain elements can match :enabled or :disabled |
| 477 | // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled |
| 478 | // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled |
| 479 | if ( "form" in elem ) { |
| 480 | |
| 481 | // Check for inherited disabledness on relevant non-disabled elements: |
| 482 | // * listed form-associated elements in a disabled fieldset |
| 483 | // https://html.spec.whatwg.org/multipage/forms.html#category-listed |
| 484 | // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled |
| 485 | // * option elements in a disabled optgroup |
| 486 | // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled |
| 487 | // All such elements have a "form" property. |
| 488 | if ( elem.parentNode && elem.disabled === false ) { |
| 489 | |
| 490 | // Option elements defer to a parent optgroup if present |
| 491 | if ( "label" in elem ) { |
| 492 | if ( "label" in elem.parentNode ) { |
| 493 | return elem.parentNode.disabled === disabled; |
| 494 | } else { |
| 495 | return elem.disabled === disabled; |
| 496 | } |
| 497 | } |
| 498 | |
| 499 | // Support: IE 6 - 11 |
| 500 | // Use the isDisabled shortcut property to check for disabled fieldset ancestors |
| 501 | return elem.isDisabled === disabled || |
| 502 | |
| 503 | // Where there is no isDisabled, check manually |
| 504 | /* jshint -W018 */ |
| 505 | elem.isDisabled !== !disabled && |
| 506 | inDisabledFieldset( elem ) === disabled; |
| 507 | } |
| 508 | |
| 509 | return elem.disabled === disabled; |
| 510 | |
| 511 | // Try to winnow out elements that can't be disabled before trusting the disabled property. |
| 512 | // Some victims get caught in our net (label, legend, menu, track), but it shouldn't |
| 513 | // even exist on them, let alone have a boolean value. |
| 514 | } else if ( "label" in elem ) { |
| 515 | return elem.disabled === disabled; |
| 516 | } |
| 517 | |
| 518 | // Remaining elements are neither :enabled nor :disabled |
| 519 | return false; |
| 520 | }; |
| 521 | } |
| 522 | |
| 523 | /** |
| 524 | * Returns a function to use in pseudos for positionals |
| 525 | * @param {Function} fn |
| 526 | */ |
| 527 | function createPositionalPseudo( fn ) { |
| 528 | return markFunction(function( argument ) { |
| 529 | argument = +argument; |
| 530 | return markFunction(function( seed, matches ) { |
| 531 | var j, |
| 532 | matchIndexes = fn( [], seed.length, argument ), |
| 533 | i = matchIndexes.length; |
| 534 | |
| 535 | // Match elements found at the specified indexes |
| 536 | while ( i-- ) { |
| 537 | if ( seed[ (j = matchIndexes[i]) ] ) { |
| 538 | seed[j] = !(matches[j] = seed[j]); |
| 539 | } |
| 540 | } |
| 541 | }); |
| 542 | }); |
| 543 | } |
| 544 | |
| 545 | /** |
| 546 | * Checks a node for validity as a Sizzle context |
| 547 | * @param {Element|Object=} context |
| 548 | * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value |
| 549 | */ |
| 550 | function testContext( context ) { |
| 551 | return context && typeof context.getElementsByTagName !== "undefined" && context; |
| 552 | } |
| 553 | |
| 554 | // Expose support vars for convenience |
| 555 | support = Sizzle.support = {}; |
| 556 | |
| 557 | /** |
| 558 | * Detects XML nodes |
| 559 | * @param {Element|Object} elem An element or a document |
| 560 | * @returns {Boolean} True iff elem is a non-HTML XML node |
| 561 | */ |
| 562 | isXML = Sizzle.isXML = function( elem ) { |
| 563 | var namespace = elem.namespaceURI, |
| 564 | docElem = (elem.ownerDocument || elem).documentElement; |
| 565 | |
| 566 | // Support: IE <=8 |
| 567 | // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes |
| 568 | // https://bugs.jquery.com/ticket/4833 |
| 569 | return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" ); |
| 570 | }; |
| 571 | |
| 572 | /** |
| 573 | * Sets document-related variables once based on the current document |
| 574 | * @param {Element|Object} [doc] An element or document object to use to set the document |
| 575 | * @returns {Object} Returns the current document |
| 576 | */ |
| 577 | setDocument = Sizzle.setDocument = function( node ) { |
| 578 | var hasCompare, subWindow, |
| 579 | doc = node ? node.ownerDocument || node : preferredDoc; |
| 580 | |
| 581 | // Return early if doc is invalid or already selected |
| 582 | if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { |
| 583 | return document; |
| 584 | } |
| 585 | |
| 586 | // Update global variables |
| 587 | document = doc; |
| 588 | docElem = document.documentElement; |
| 589 | documentIsHTML = !isXML( document ); |
| 590 | |
| 591 | // Support: IE 9-11, Edge |
| 592 | // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) |
| 593 | if ( preferredDoc !== document && |
| 594 | (subWindow = document.defaultView) && subWindow.top !== subWindow ) { |
| 595 | |
| 596 | // Support: IE 11, Edge |
| 597 | if ( subWindow.addEventListener ) { |
| 598 | subWindow.addEventListener( "unload", unloadHandler, false ); |
| 599 | |
| 600 | // Support: IE 9 - 10 only |
| 601 | } else if ( subWindow.attachEvent ) { |
| 602 | subWindow.attachEvent( "onunload", unloadHandler ); |
| 603 | } |
| 604 | } |
| 605 | |
| 606 | /* Attributes |
| 607 | ---------------------------------------------------------------------- */ |
| 608 | |
| 609 | // Support: IE<8 |
| 610 | // Verify that getAttribute really returns attributes and not properties |
| 611 | // (excepting IE8 booleans) |
| 612 | support.attributes = assert(function( el ) { |
| 613 | el.className = "i"; |
| 614 | return !el.getAttribute("className"); |
| 615 | }); |
| 616 | |
| 617 | /* getElement(s)By* |
| 618 | ---------------------------------------------------------------------- */ |
| 619 | |
| 620 | // Check if getElementsByTagName("*") returns only elements |
| 621 | support.getElementsByTagName = assert(function( el ) { |
| 622 | el.appendChild( document.createComment("") ); |
| 623 | return !el.getElementsByTagName("*").length; |
| 624 | }); |
| 625 | |
| 626 | // Support: IE<9 |
| 627 | support.getElementsByClassName = rnative.test( document.getElementsByClassName ); |
| 628 | |
| 629 | // Support: IE<10 |
| 630 | // Check if getElementById returns elements by name |
| 631 | // The broken getElementById methods don't pick up programmatically-set names, |
| 632 | // so use a roundabout getElementsByName test |
| 633 | support.getById = assert(function( el ) { |
| 634 | docElem.appendChild( el ).id = expando; |
| 635 | return !document.getElementsByName || !document.getElementsByName( expando ).length; |
| 636 | }); |
| 637 | |
| 638 | // ID filter and find |
| 639 | if ( support.getById ) { |
| 640 | Expr.filter["ID"] = function( id ) { |
| 641 | var attrId = id.replace( runescape, funescape ); |
| 642 | return function( elem ) { |
| 643 | return elem.getAttribute("id") === attrId; |
| 644 | }; |
| 645 | }; |
| 646 | Expr.find["ID"] = function( id, context ) { |
| 647 | if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { |
| 648 | var elem = context.getElementById( id ); |
| 649 | return elem ? [ elem ] : []; |
| 650 | } |
| 651 | }; |
| 652 | } else { |
| 653 | Expr.filter["ID"] = function( id ) { |
| 654 | var attrId = id.replace( runescape, funescape ); |
| 655 | return function( elem ) { |
| 656 | var node = typeof elem.getAttributeNode !== "undefined" && |
| 657 | elem.getAttributeNode("id"); |
| 658 | return node && node.value === attrId; |
| 659 | }; |
| 660 | }; |
| 661 | |
| 662 | // Support: IE 6 - 7 only |
| 663 | // getElementById is not reliable as a find shortcut |
| 664 | Expr.find["ID"] = function( id, context ) { |
| 665 | if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { |
| 666 | var node, i, elems, |
| 667 | elem = context.getElementById( id ); |
| 668 | |
| 669 | if ( elem ) { |
| 670 | |
| 671 | // Verify the id attribute |
| 672 | node = elem.getAttributeNode("id"); |
| 673 | if ( node && node.value === id ) { |
| 674 | return [ elem ]; |
| 675 | } |
| 676 | |
| 677 | // Fall back on getElementsByName |
| 678 | elems = context.getElementsByName( id ); |
| 679 | i = 0; |
| 680 | while ( (elem = elems[i++]) ) { |
| 681 | node = elem.getAttributeNode("id"); |
| 682 | if ( node && node.value === id ) { |
| 683 | return [ elem ]; |
| 684 | } |
| 685 | } |
| 686 | } |
| 687 | |
| 688 | return []; |
| 689 | } |
| 690 | }; |
| 691 | } |
| 692 | |
| 693 | // Tag |
| 694 | Expr.find["TAG"] = support.getElementsByTagName ? |
| 695 | function( tag, context ) { |
| 696 | if ( typeof context.getElementsByTagName !== "undefined" ) { |
| 697 | return context.getElementsByTagName( tag ); |
| 698 | |
| 699 | // DocumentFragment nodes don't have gEBTN |
| 700 | } else if ( support.qsa ) { |
| 701 | return context.querySelectorAll( tag ); |
| 702 | } |
| 703 | } : |
| 704 | |
| 705 | function( tag, context ) { |
| 706 | var elem, |
| 707 | tmp = [], |
| 708 | i = 0, |
| 709 | // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too |
| 710 | results = context.getElementsByTagName( tag ); |
| 711 | |
| 712 | // Filter out possible comments |
| 713 | if ( tag === "*" ) { |
| 714 | while ( (elem = results[i++]) ) { |
| 715 | if ( elem.nodeType === 1 ) { |
| 716 | tmp.push( elem ); |
| 717 | } |
| 718 | } |
| 719 | |
| 720 | return tmp; |
| 721 | } |
| 722 | return results; |
| 723 | }; |
| 724 | |
| 725 | // Class |
| 726 | Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { |
| 727 | if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { |
| 728 | return context.getElementsByClassName( className ); |
| 729 | } |
| 730 | }; |
| 731 | |
| 732 | /* QSA/matchesSelector |
| 733 | ---------------------------------------------------------------------- */ |
| 734 | |
| 735 | // QSA and matchesSelector support |
| 736 | |
| 737 | // matchesSelector(:active) reports false when true (IE9/Opera 11.5) |
| 738 | rbuggyMatches = []; |
| 739 | |
| 740 | // qSa(:focus) reports false when true (Chrome 21) |
| 741 | // We allow this because of a bug in IE8/9 that throws an error |
| 742 | // whenever `document.activeElement` is accessed on an iframe |
| 743 | // So, we allow :focus to pass through QSA all the time to avoid the IE error |
| 744 | // See https://bugs.jquery.com/ticket/13378 |
| 745 | rbuggyQSA = []; |
| 746 | |
| 747 | if ( (support.qsa = rnative.test( document.querySelectorAll )) ) { |
| 748 | // Build QSA regex |
| 749 | // Regex strategy adopted from Diego Perini |
| 750 | assert(function( el ) { |
| 751 | // Select is set to empty string on purpose |
| 752 | // This is to test IE's treatment of not explicitly |
| 753 | // setting a boolean content attribute, |
| 754 | // since its presence should be enough |
| 755 | // https://bugs.jquery.com/ticket/12359 |
| 756 | docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" + |
| 757 | "<select id='" + expando + "-\r\\' msallowcapture=''>" + |
| 758 | "<option selected=''></option></select>"; |
| 759 | |
| 760 | // Support: IE8, Opera 11-12.16 |
| 761 | // Nothing should be selected when empty strings follow ^= or $= or *= |
| 762 | // The test attribute must be unknown in Opera but "safe" for WinRT |
| 763 | // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section |
| 764 | if ( el.querySelectorAll("[msallowcapture^='']").length ) { |
| 765 | rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); |
| 766 | } |
| 767 | |
| 768 | // Support: IE8 |
| 769 | // Boolean attributes and "value" are not treated correctly |
| 770 | if ( !el.querySelectorAll("[selected]").length ) { |
| 771 | rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); |
| 772 | } |
| 773 | |
| 774 | // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ |
| 775 | if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) { |
| 776 | rbuggyQSA.push("~="); |
| 777 | } |
| 778 | |
| 779 | // Webkit/Opera - :checked should return selected option elements |
| 780 | // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked |
| 781 | // IE8 throws error here and will not see later tests |
| 782 | if ( !el.querySelectorAll(":checked").length ) { |
| 783 | rbuggyQSA.push(":checked"); |
| 784 | } |
| 785 | |
| 786 | // Support: Safari 8+, iOS 8+ |
| 787 | // https://bugs.webkit.org/show_bug.cgi?id=136851 |
| 788 | // In-page `selector#id sibling-combinator selector` fails |
| 789 | if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) { |
| 790 | rbuggyQSA.push(".#.+[+~]"); |
| 791 | } |
| 792 | }); |
| 793 | |
| 794 | assert(function( el ) { |
| 795 | el.innerHTML = "<a href='' disabled='disabled'></a>" + |
| 796 | "<select disabled='disabled'><option/></select>"; |
| 797 | |
| 798 | // Support: Windows 8 Native Apps |
| 799 | // The type and name attributes are restricted during .innerHTML assignment |
| 800 | var input = document.createElement("input"); |
| 801 | input.setAttribute( "type", "hidden" ); |
| 802 | el.appendChild( input ).setAttribute( "name", "D" ); |
| 803 | |
| 804 | // Support: IE8 |
| 805 | // Enforce case-sensitivity of name attribute |
| 806 | if ( el.querySelectorAll("[name=d]").length ) { |
| 807 | rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); |
| 808 | } |
| 809 | |
| 810 | // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) |
| 811 | // IE8 throws error here and will not see later tests |
| 812 | if ( el.querySelectorAll(":enabled").length !== 2 ) { |
| 813 | rbuggyQSA.push( ":enabled", ":disabled" ); |
| 814 | } |
| 815 | |
| 816 | // Support: IE9-11+ |
| 817 | // IE's :disabled selector does not pick up the children of disabled fieldsets |
| 818 | docElem.appendChild( el ).disabled = true; |
| 819 | if ( el.querySelectorAll(":disabled").length !== 2 ) { |
| 820 | rbuggyQSA.push( ":enabled", ":disabled" ); |
| 821 | } |
| 822 | |
| 823 | // Opera 10-11 does not throw on post-comma invalid pseudos |
| 824 | el.querySelectorAll("*,:x"); |
| 825 | rbuggyQSA.push(",.*:"); |
| 826 | }); |
| 827 | } |
| 828 | |
| 829 | if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || |
| 830 | docElem.webkitMatchesSelector || |
| 831 | docElem.mozMatchesSelector || |
| 832 | docElem.oMatchesSelector || |
| 833 | docElem.msMatchesSelector) )) ) { |
| 834 | |
| 835 | assert(function( el ) { |
| 836 | // Check to see if it's possible to do matchesSelector |
| 837 | // on a disconnected node (IE 9) |
| 838 | support.disconnectedMatch = matches.call( el, "*" ); |
| 839 | |
| 840 | // This should fail with an exception |
| 841 | // Gecko does not error, returns false instead |
| 842 | matches.call( el, "[s!='']:x" ); |
| 843 | rbuggyMatches.push( "!=", pseudos ); |
| 844 | }); |
| 845 | } |
| 846 | |
| 847 | rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); |
| 848 | rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); |
| 849 | |
| 850 | /* Contains |
| 851 | ---------------------------------------------------------------------- */ |
| 852 | hasCompare = rnative.test( docElem.compareDocumentPosition ); |
| 853 | |
| 854 | // Element contains another |
| 855 | // Purposefully self-exclusive |
| 856 | // As in, an element does not contain itself |
| 857 | contains = hasCompare || rnative.test( docElem.contains ) ? |
| 858 | function( a, b ) { |
| 859 | var adown = a.nodeType === 9 ? a.documentElement : a, |
| 860 | bup = b && b.parentNode; |
| 861 | return a === bup || !!( bup && bup.nodeType === 1 && ( |
| 862 | adown.contains ? |
| 863 | adown.contains( bup ) : |
| 864 | a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 |
| 865 | )); |
| 866 | } : |
| 867 | function( a, b ) { |
| 868 | if ( b ) { |
| 869 | while ( (b = b.parentNode) ) { |
| 870 | if ( b === a ) { |
| 871 | return true; |
| 872 | } |
| 873 | } |
| 874 | } |
| 875 | return false; |
| 876 | }; |
| 877 | |
| 878 | /* Sorting |
| 879 | ---------------------------------------------------------------------- */ |
| 880 | |
| 881 | // Document order sorting |
| 882 | sortOrder = hasCompare ? |
| 883 | function( a, b ) { |
| 884 | |
| 885 | // Flag for duplicate removal |
| 886 | if ( a === b ) { |
| 887 | hasDuplicate = true; |
| 888 | return 0; |
| 889 | } |
| 890 | |
| 891 | // Sort on method existence if only one input has compareDocumentPosition |
| 892 | var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; |
| 893 | if ( compare ) { |
| 894 | return compare; |
| 895 | } |
| 896 | |
| 897 | // Calculate position if both inputs belong to the same document |
| 898 | compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? |
| 899 | a.compareDocumentPosition( b ) : |
| 900 | |
| 901 | // Otherwise we know they are disconnected |
| 902 | 1; |
| 903 | |
| 904 | // Disconnected nodes |
| 905 | if ( compare & 1 || |
| 906 | (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { |
| 907 | |
| 908 | // Choose the first element that is related to our preferred document |
| 909 | if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { |
| 910 | return -1; |
| 911 | } |
| 912 | if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { |
| 913 | return 1; |
| 914 | } |
| 915 | |
| 916 | // Maintain original order |
| 917 | return sortInput ? |
| 918 | ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : |
| 919 | 0; |
| 920 | } |
| 921 | |
| 922 | return compare & 4 ? -1 : 1; |
| 923 | } : |
| 924 | function( a, b ) { |
| 925 | // Exit early if the nodes are identical |
| 926 | if ( a === b ) { |
| 927 | hasDuplicate = true; |
| 928 | return 0; |
| 929 | } |
| 930 | |
| 931 | var cur, |
| 932 | i = 0, |
| 933 | aup = a.parentNode, |
| 934 | bup = b.parentNode, |
| 935 | ap = [ a ], |
| 936 | bp = [ b ]; |
| 937 | |
| 938 | // Parentless nodes are either documents or disconnected |
| 939 | if ( !aup || !bup ) { |
| 940 | return a === document ? -1 : |
| 941 | b === document ? 1 : |
| 942 | aup ? -1 : |
| 943 | bup ? 1 : |
| 944 | sortInput ? |
| 945 | ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : |
| 946 | 0; |
| 947 | |
| 948 | // If the nodes are siblings, we can do a quick check |
| 949 | } else if ( aup === bup ) { |
| 950 | return siblingCheck( a, b ); |
| 951 | } |
| 952 | |
| 953 | // Otherwise we need full lists of their ancestors for comparison |
| 954 | cur = a; |
| 955 | while ( (cur = cur.parentNode) ) { |
| 956 | ap.unshift( cur ); |
| 957 | } |
| 958 | cur = b; |
| 959 | while ( (cur = cur.parentNode) ) { |
| 960 | bp.unshift( cur ); |
| 961 | } |
| 962 | |
| 963 | // Walk down the tree looking for a discrepancy |
| 964 | while ( ap[i] === bp[i] ) { |
| 965 | i++; |
| 966 | } |
| 967 | |
| 968 | return i ? |
| 969 | // Do a sibling check if the nodes have a common ancestor |
| 970 | siblingCheck( ap[i], bp[i] ) : |
| 971 | |
| 972 | // Otherwise nodes in our document sort first |
| 973 | ap[i] === preferredDoc ? -1 : |
| 974 | bp[i] === preferredDoc ? 1 : |
| 975 | 0; |
| 976 | }; |
| 977 | |
| 978 | return document; |
| 979 | }; |
| 980 | |
| 981 | Sizzle.matches = function( expr, elements ) { |
| 982 | return Sizzle( expr, null, null, elements ); |
| 983 | }; |
| 984 | |
| 985 | Sizzle.matchesSelector = function( elem, expr ) { |
| 986 | // Set document vars if needed |
| 987 | if ( ( elem.ownerDocument || elem ) !== document ) { |
| 988 | setDocument( elem ); |
| 989 | } |
| 990 | |
| 991 | if ( support.matchesSelector && documentIsHTML && |
| 992 | !nonnativeSelectorCache[ expr + " " ] && |
| 993 | ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && |
| 994 | ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { |
| 995 | |
| 996 | try { |
| 997 | var ret = matches.call( elem, expr ); |
| 998 | |
| 999 | // IE 9's matchesSelector returns false on disconnected nodes |
| 1000 | if ( ret || support.disconnectedMatch || |
| 1001 | // As well, disconnected nodes are said to be in a document |
| 1002 | // fragment in IE 9 |
| 1003 | elem.document && elem.document.nodeType !== 11 ) { |
| 1004 | return ret; |
| 1005 | } |
| 1006 | } catch (e) { |
| 1007 | nonnativeSelectorCache( expr, true ); |
| 1008 | } |
| 1009 | } |
| 1010 | |
| 1011 | return Sizzle( expr, document, null, [ elem ] ).length > 0; |
| 1012 | }; |
| 1013 | |
| 1014 | Sizzle.contains = function( context, elem ) { |
| 1015 | // Set document vars if needed |
| 1016 | if ( ( context.ownerDocument || context ) !== document ) { |
| 1017 | setDocument( context ); |
| 1018 | } |
| 1019 | return contains( context, elem ); |
| 1020 | }; |
| 1021 | |
| 1022 | Sizzle.attr = function( elem, name ) { |
| 1023 | // Set document vars if needed |
| 1024 | if ( ( elem.ownerDocument || elem ) !== document ) { |
| 1025 | setDocument( elem ); |
| 1026 | } |
| 1027 | |
| 1028 | var fn = Expr.attrHandle[ name.toLowerCase() ], |
| 1029 | // Don't get fooled by Object.prototype properties (jQuery #13807) |
| 1030 | val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? |
| 1031 | fn( elem, name, !documentIsHTML ) : |
| 1032 | undefined; |
| 1033 | |
| 1034 | return val !== undefined ? |
| 1035 | val : |
| 1036 | support.attributes || !documentIsHTML ? |
| 1037 | elem.getAttribute( name ) : |
| 1038 | (val = elem.getAttributeNode(name)) && val.specified ? |
| 1039 | val.value : |
| 1040 | null; |
| 1041 | }; |
| 1042 | |
| 1043 | Sizzle.escape = function( sel ) { |
| 1044 | return (sel + "").replace( rcssescape, fcssescape ); |
| 1045 | }; |
| 1046 | |
| 1047 | Sizzle.error = function( msg ) { |
| 1048 | throw new Error( "Syntax error, unrecognized expression: " + msg ); |
| 1049 | }; |
| 1050 | |
| 1051 | /** |
| 1052 | * Document sorting and removing duplicates |
| 1053 | * @param {ArrayLike} results |
| 1054 | */ |
| 1055 | Sizzle.uniqueSort = function( results ) { |
| 1056 | var elem, |
| 1057 | duplicates = [], |
| 1058 | j = 0, |
| 1059 | i = 0; |
| 1060 | |
| 1061 | // Unless we *know* we can detect duplicates, assume their presence |
| 1062 | hasDuplicate = !support.detectDuplicates; |
| 1063 | sortInput = !support.sortStable && results.slice( 0 ); |
| 1064 | results.sort( sortOrder ); |
| 1065 | |
| 1066 | if ( hasDuplicate ) { |
| 1067 | while ( (elem = results[i++]) ) { |
| 1068 | if ( elem === results[ i ] ) { |
| 1069 | j = duplicates.push( i ); |
| 1070 | } |
| 1071 | } |
| 1072 | while ( j-- ) { |
| 1073 | results.splice( duplicates[ j ], 1 ); |
| 1074 | } |
| 1075 | } |
| 1076 | |
| 1077 | // Clear input after sorting to release objects |
| 1078 | // See https://github.com/jquery/sizzle/pull/225 |
| 1079 | sortInput = null; |
| 1080 | |
| 1081 | return results; |
| 1082 | }; |
| 1083 | |
| 1084 | /** |
| 1085 | * Utility function for retrieving the text value of an array of DOM nodes |
| 1086 | * @param {Array|Element} elem |
| 1087 | */ |
| 1088 | getText = Sizzle.getText = function( elem ) { |
| 1089 | var node, |
| 1090 | ret = "", |
| 1091 | i = 0, |
| 1092 | nodeType = elem.nodeType; |
| 1093 | |
| 1094 | if ( !nodeType ) { |
| 1095 | // If no nodeType, this is expected to be an array |
| 1096 | while ( (node = elem[i++]) ) { |
| 1097 | // Do not traverse comment nodes |
| 1098 | ret += getText( node ); |
| 1099 | } |
| 1100 | } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { |
| 1101 | // Use textContent for elements |
| 1102 | // innerText usage removed for consistency of new lines (jQuery #11153) |
| 1103 | if ( typeof elem.textContent === "string" ) { |
| 1104 | return elem.textContent; |
| 1105 | } else { |
| 1106 | // Traverse its children |
| 1107 | for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { |
| 1108 | ret += getText( elem ); |
| 1109 | } |
| 1110 | } |
| 1111 | } else if ( nodeType === 3 || nodeType === 4 ) { |
| 1112 | return elem.nodeValue; |
| 1113 | } |
| 1114 | // Do not include comment or processing instruction nodes |
| 1115 | |
| 1116 | return ret; |
| 1117 | }; |
| 1118 | |
| 1119 | Expr = Sizzle.selectors = { |
| 1120 | |
| 1121 | // Can be adjusted by the user |
| 1122 | cacheLength: 50, |
| 1123 | |
| 1124 | createPseudo: markFunction, |
| 1125 | |
| 1126 | match: matchExpr, |
| 1127 | |
| 1128 | attrHandle: {}, |
| 1129 | |
| 1130 | find: {}, |
| 1131 | |
| 1132 | relative: { |
| 1133 | ">": { dir: "parentNode", first: true }, |
| 1134 | " ": { dir: "parentNode" }, |
| 1135 | "+": { dir: "previousSibling", first: true }, |
| 1136 | "~": { dir: "previousSibling" } |
| 1137 | }, |
| 1138 | |
| 1139 | preFilter: { |
| 1140 | "ATTR": function( match ) { |
| 1141 | match[1] = match[1].replace( runescape, funescape ); |
| 1142 | |
| 1143 | // Move the given value to match[3] whether quoted or unquoted |
| 1144 | match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape ); |
| 1145 | |
| 1146 | if ( match[2] === "~=" ) { |
| 1147 | match[3] = " " + match[3] + " "; |
| 1148 | } |
| 1149 | |
| 1150 | return match.slice( 0, 4 ); |
| 1151 | }, |
| 1152 | |
| 1153 | "CHILD": function( match ) { |
| 1154 | /* matches from matchExpr["CHILD"] |
| 1155 | 1 type (only|nth|...) |
| 1156 | 2 what (child|of-type) |
| 1157 | 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) |
| 1158 | 4 xn-component of xn+y argument ([+-]?\d*n|) |
| 1159 | 5 sign of xn-component |
| 1160 | 6 x of xn-component |
| 1161 | 7 sign of y-component |
| 1162 | 8 y of y-component |
| 1163 | */ |
| 1164 | match[1] = match[1].toLowerCase(); |
| 1165 | |
| 1166 | if ( match[1].slice( 0, 3 ) === "nth" ) { |
| 1167 | // nth-* requires argument |
| 1168 | if ( !match[3] ) { |
| 1169 | Sizzle.error( match[0] ); |
| 1170 | } |
| 1171 | |
| 1172 | // numeric x and y parameters for Expr.filter.CHILD |
| 1173 | // remember that false/true cast respectively to 0/1 |
| 1174 | match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); |
| 1175 | match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); |
| 1176 | |
| 1177 | // other types prohibit arguments |
| 1178 | } else if ( match[3] ) { |
| 1179 | Sizzle.error( match[0] ); |
| 1180 | } |
| 1181 | |
| 1182 | return match; |
| 1183 | }, |
| 1184 | |
| 1185 | "PSEUDO": function( match ) { |
| 1186 | var excess, |
| 1187 | unquoted = !match[6] && match[2]; |
| 1188 | |
| 1189 | if ( matchExpr["CHILD"].test( match[0] ) ) { |
| 1190 | return null; |
| 1191 | } |
| 1192 | |
| 1193 | // Accept quoted arguments as-is |
| 1194 | if ( match[3] ) { |
| 1195 | match[2] = match[4] || match[5] || ""; |
| 1196 | |
| 1197 | // Strip excess characters from unquoted arguments |
| 1198 | } else if ( unquoted && rpseudo.test( unquoted ) && |
| 1199 | // Get excess from tokenize (recursively) |
| 1200 | (excess = tokenize( unquoted, true )) && |
| 1201 | // advance to the next closing parenthesis |
| 1202 | (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { |
| 1203 | |
| 1204 | // excess is a negative index |
| 1205 | match[0] = match[0].slice( 0, excess ); |
| 1206 | match[2] = unquoted.slice( 0, excess ); |
| 1207 | } |
| 1208 | |
| 1209 | // Return only captures needed by the pseudo filter method (type and argument) |
| 1210 | return match.slice( 0, 3 ); |
| 1211 | } |
| 1212 | }, |
| 1213 | |
| 1214 | filter: { |
| 1215 | |
| 1216 | "TAG": function( nodeNameSelector ) { |
| 1217 | var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); |
| 1218 | return nodeNameSelector === "*" ? |
| 1219 | function() { return true; } : |
| 1220 | function( elem ) { |
| 1221 | return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; |
| 1222 | }; |
| 1223 | }, |
| 1224 | |
| 1225 | "CLASS": function( className ) { |
| 1226 | var pattern = classCache[ className + " " ]; |
| 1227 | |
| 1228 | return pattern || |
| 1229 | (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && |
| 1230 | classCache( className, function( elem ) { |
| 1231 | return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" ); |
| 1232 | }); |
| 1233 | }, |
| 1234 | |
| 1235 | "ATTR": function( name, operator, check ) { |
| 1236 | return function( elem ) { |
| 1237 | var result = Sizzle.attr( elem, name ); |
| 1238 | |
| 1239 | if ( result == null ) { |
| 1240 | return operator === "!="; |
| 1241 | } |
| 1242 | if ( !operator ) { |
| 1243 | return true; |
| 1244 | } |
| 1245 | |
| 1246 | result += ""; |
| 1247 | |
| 1248 | return operator === "=" ? result === check : |
| 1249 | operator === "!=" ? result !== check : |
| 1250 | operator === "^=" ? check && result.indexOf( check ) === 0 : |
| 1251 | operator === "*=" ? check && result.indexOf( check ) > -1 : |
| 1252 | operator === "$=" ? check && result.slice( -check.length ) === check : |
| 1253 | operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : |
| 1254 | operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : |
| 1255 | false; |
| 1256 | }; |
| 1257 | }, |
| 1258 | |
| 1259 | "CHILD": function( type, what, argument, first, last ) { |
| 1260 | var simple = type.slice( 0, 3 ) !== "nth", |
| 1261 | forward = type.slice( -4 ) !== "last", |
| 1262 | ofType = what === "of-type"; |
| 1263 | |
| 1264 | return first === 1 && last === 0 ? |
| 1265 | |
| 1266 | // Shortcut for :nth-*(n) |
| 1267 | function( elem ) { |
| 1268 | return !!elem.parentNode; |
| 1269 | } : |
| 1270 | |
| 1271 | function( elem, context, xml ) { |
| 1272 | var cache, uniqueCache, outerCache, node, nodeIndex, start, |
| 1273 | dir = simple !== forward ? "nextSibling" : "previousSibling", |
| 1274 | parent = elem.parentNode, |
| 1275 | name = ofType && elem.nodeName.toLowerCase(), |
| 1276 | useCache = !xml && !ofType, |
| 1277 | diff = false; |
| 1278 | |
| 1279 | if ( parent ) { |
| 1280 | |
| 1281 | // :(first|last|only)-(child|of-type) |
| 1282 | if ( simple ) { |
| 1283 | while ( dir ) { |
| 1284 | node = elem; |
| 1285 | while ( (node = node[ dir ]) ) { |
| 1286 | if ( ofType ? |
| 1287 | node.nodeName.toLowerCase() === name : |
| 1288 | node.nodeType === 1 ) { |
| 1289 | |
| 1290 | return false; |
| 1291 | } |
| 1292 | } |
| 1293 | // Reverse direction for :only-* (if we haven't yet done so) |
| 1294 | start = dir = type === "only" && !start && "nextSibling"; |
| 1295 | } |
| 1296 | return true; |
| 1297 | } |
| 1298 | |
| 1299 | start = [ forward ? parent.firstChild : parent.lastChild ]; |
| 1300 | |
| 1301 | // non-xml :nth-child(...) stores cache data on `parent` |
| 1302 | if ( forward && useCache ) { |
| 1303 | |
| 1304 | // Seek `elem` from a previously-cached index |
| 1305 | |
| 1306 | // ...in a gzip-friendly way |
| 1307 | node = parent; |
| 1308 | outerCache = node[ expando ] || (node[ expando ] = {}); |
| 1309 | |
| 1310 | // Support: IE <9 only |
| 1311 | // Defend against cloned attroperties (jQuery gh-1709) |
| 1312 | uniqueCache = outerCache[ node.uniqueID ] || |
| 1313 | (outerCache[ node.uniqueID ] = {}); |
| 1314 | |
| 1315 | cache = uniqueCache[ type ] || []; |
| 1316 | nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; |
| 1317 | diff = nodeIndex && cache[ 2 ]; |
| 1318 | node = nodeIndex && parent.childNodes[ nodeIndex ]; |
| 1319 | |
| 1320 | while ( (node = ++nodeIndex && node && node[ dir ] || |
| 1321 | |
| 1322 | // Fallback to seeking `elem` from the start |
| 1323 | (diff = nodeIndex = 0) || start.pop()) ) { |
| 1324 | |
| 1325 | // When found, cache indexes on `parent` and break |
| 1326 | if ( node.nodeType === 1 && ++diff && node === elem ) { |
| 1327 | uniqueCache[ type ] = [ dirruns, nodeIndex, diff ]; |
| 1328 | break; |
| 1329 | } |
| 1330 | } |
| 1331 | |
| 1332 | } else { |
| 1333 | // Use previously-cached element index if available |
| 1334 | if ( useCache ) { |
| 1335 | // ...in a gzip-friendly way |
| 1336 | node = elem; |
| 1337 | outerCache = node[ expando ] || (node[ expando ] = {}); |
| 1338 | |
| 1339 | // Support: IE <9 only |
| 1340 | // Defend against cloned attroperties (jQuery gh-1709) |
| 1341 | uniqueCache = outerCache[ node.uniqueID ] || |
| 1342 | (outerCache[ node.uniqueID ] = {}); |
| 1343 | |
| 1344 | cache = uniqueCache[ type ] || []; |
| 1345 | nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; |
| 1346 | diff = nodeIndex; |
| 1347 | } |
| 1348 | |
| 1349 | // xml :nth-child(...) |
| 1350 | // or :nth-last-child(...) or :nth(-last)?-of-type(...) |
| 1351 | if ( diff === false ) { |
| 1352 | // Use the same loop as above to seek `elem` from the start |
| 1353 | while ( (node = ++nodeIndex && node && node[ dir ] || |
| 1354 | (diff = nodeIndex = 0) || start.pop()) ) { |
| 1355 | |
| 1356 | if ( ( ofType ? |
| 1357 | node.nodeName.toLowerCase() === name : |
| 1358 | node.nodeType === 1 ) && |
| 1359 | ++diff ) { |
| 1360 | |
| 1361 | // Cache the index of each encountered element |
| 1362 | if ( useCache ) { |
| 1363 | outerCache = node[ expando ] || (node[ expando ] = {}); |
| 1364 | |
| 1365 | // Support: IE <9 only |
| 1366 | // Defend against cloned attroperties (jQuery gh-1709) |
| 1367 | uniqueCache = outerCache[ node.uniqueID ] || |
| 1368 | (outerCache[ node.uniqueID ] = {}); |
| 1369 | |
| 1370 | uniqueCache[ type ] = [ dirruns, diff ]; |
| 1371 | } |
| 1372 | |
| 1373 | if ( node === elem ) { |
| 1374 | break; |
| 1375 | } |
| 1376 | } |
| 1377 | } |
| 1378 | } |
| 1379 | } |
| 1380 | |
| 1381 | // Incorporate the offset, then check against cycle size |
| 1382 | diff -= last; |
| 1383 | return diff === first || ( diff % first === 0 && diff / first >= 0 ); |
| 1384 | } |
| 1385 | }; |
| 1386 | }, |
| 1387 | |
| 1388 | "PSEUDO": function( pseudo, argument ) { |
| 1389 | // pseudo-class names are case-insensitive |
| 1390 | // http://www.w3.org/TR/selectors/#pseudo-classes |
| 1391 | // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters |
| 1392 | // Remember that setFilters inherits from pseudos |
| 1393 | var args, |
| 1394 | fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || |
| 1395 | Sizzle.error( "unsupported pseudo: " + pseudo ); |
| 1396 | |
| 1397 | // The user may use createPseudo to indicate that |
| 1398 | // arguments are needed to create the filter function |
| 1399 | // just as Sizzle does |
| 1400 | if ( fn[ expando ] ) { |
| 1401 | return fn( argument ); |
| 1402 | } |
| 1403 | |
| 1404 | // But maintain support for old signatures |
| 1405 | if ( fn.length > 1 ) { |
| 1406 | args = [ pseudo, pseudo, "", argument ]; |
| 1407 | return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? |
| 1408 | markFunction(function( seed, matches ) { |
| 1409 | var idx, |
| 1410 | matched = fn( seed, argument ), |
| 1411 | i = matched.length; |
| 1412 | while ( i-- ) { |
| 1413 | idx = indexOf( seed, matched[i] ); |
| 1414 | seed[ idx ] = !( matches[ idx ] = matched[i] ); |
| 1415 | } |
| 1416 | }) : |
| 1417 | function( elem ) { |
| 1418 | return fn( elem, 0, args ); |
| 1419 | }; |
| 1420 | } |
| 1421 | |
| 1422 | return fn; |
| 1423 | } |
| 1424 | }, |
| 1425 | |
| 1426 | pseudos: { |
| 1427 | // Potentially complex pseudos |
| 1428 | "not": markFunction(function( selector ) { |
| 1429 | // Trim the selector passed to compile |
| 1430 | // to avoid treating leading and trailing |
| 1431 | // spaces as combinators |
| 1432 | var input = [], |
| 1433 | results = [], |
| 1434 | matcher = compile( selector.replace( rtrim, "$1" ) ); |
| 1435 | |
| 1436 | return matcher[ expando ] ? |
| 1437 | markFunction(function( seed, matches, context, xml ) { |
| 1438 | var elem, |
| 1439 | unmatched = matcher( seed, null, xml, [] ), |
| 1440 | i = seed.length; |
| 1441 | |
| 1442 | // Match elements unmatched by `matcher` |
| 1443 | while ( i-- ) { |
| 1444 | if ( (elem = unmatched[i]) ) { |
| 1445 | seed[i] = !(matches[i] = elem); |
| 1446 | } |
| 1447 | } |
| 1448 | }) : |
| 1449 | function( elem, context, xml ) { |
| 1450 | input[0] = elem; |
| 1451 | matcher( input, null, xml, results ); |
| 1452 | // Don't keep the element (issue #299) |
| 1453 | input[0] = null; |
| 1454 | return !results.pop(); |
| 1455 | }; |
| 1456 | }), |
| 1457 | |
| 1458 | "has": markFunction(function( selector ) { |
| 1459 | return function( elem ) { |
| 1460 | return Sizzle( selector, elem ).length > 0; |
| 1461 | }; |
| 1462 | }), |
| 1463 | |
| 1464 | "contains": markFunction(function( text ) { |
| 1465 | text = text.replace( runescape, funescape ); |
| 1466 | return function( elem ) { |
| 1467 | return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1; |
| 1468 | }; |
| 1469 | }), |
| 1470 | |
| 1471 | // "Whether an element is represented by a :lang() selector |
| 1472 | // is based solely on the element's language value |
| 1473 | // being equal to the identifier C, |
| 1474 | // or beginning with the identifier C immediately followed by "-". |
| 1475 | // The matching of C against the element's language value is performed case-insensitively. |
| 1476 | // The identifier C does not have to be a valid language name." |
| 1477 | // http://www.w3.org/TR/selectors/#lang-pseudo |
| 1478 | "lang": markFunction( function( lang ) { |
| 1479 | // lang value must be a valid identifier |
| 1480 | if ( !ridentifier.test(lang || "") ) { |
| 1481 | Sizzle.error( "unsupported lang: " + lang ); |
| 1482 | } |
| 1483 | lang = lang.replace( runescape, funescape ).toLowerCase(); |
| 1484 | return function( elem ) { |
| 1485 | var elemLang; |
| 1486 | do { |
| 1487 | if ( (elemLang = documentIsHTML ? |
| 1488 | elem.lang : |
| 1489 | elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { |
| 1490 | |
| 1491 | elemLang = elemLang.toLowerCase(); |
| 1492 | return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; |
| 1493 | } |
| 1494 | } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); |
| 1495 | return false; |
| 1496 | }; |
| 1497 | }), |
| 1498 | |
| 1499 | // Miscellaneous |
| 1500 | "target": function( elem ) { |
| 1501 | var hash = window.location && window.location.hash; |
| 1502 | return hash && hash.slice( 1 ) === elem.id; |
| 1503 | }, |
| 1504 | |
| 1505 | "root": function( elem ) { |
| 1506 | return elem === docElem; |
| 1507 | }, |
| 1508 | |
| 1509 | "focus": function( elem ) { |
| 1510 | return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); |
| 1511 | }, |
| 1512 | |
| 1513 | // Boolean properties |
| 1514 | "enabled": createDisabledPseudo( false ), |
| 1515 | "disabled": createDisabledPseudo( true ), |
| 1516 | |
| 1517 | "checked": function( elem ) { |
| 1518 | // In CSS3, :checked should return both checked and selected elements |
| 1519 | // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked |
| 1520 | var nodeName = elem.nodeName.toLowerCase(); |
| 1521 | return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); |
| 1522 | }, |
| 1523 | |
| 1524 | "selected": function( elem ) { |
| 1525 | // Accessing this property makes selected-by-default |
| 1526 | // options in Safari work properly |
| 1527 | if ( elem.parentNode ) { |
| 1528 | elem.parentNode.selectedIndex; |
| 1529 | } |
| 1530 | |
| 1531 | return elem.selected === true; |
| 1532 | }, |
| 1533 | |
| 1534 | // Contents |
| 1535 | "empty": function( elem ) { |
| 1536 | // http://www.w3.org/TR/selectors/#empty-pseudo |
| 1537 | // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), |
| 1538 | // but not by others (comment: 8; processing instruction: 7; etc.) |
| 1539 | // nodeType < 6 works because attributes (2) do not appear as children |
| 1540 | for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { |
| 1541 | if ( elem.nodeType < 6 ) { |
| 1542 | return false; |
| 1543 | } |
| 1544 | } |
| 1545 | return true; |
| 1546 | }, |
| 1547 | |
| 1548 | "parent": function( elem ) { |
| 1549 | return !Expr.pseudos["empty"]( elem ); |
| 1550 | }, |
| 1551 | |
| 1552 | // Element/input types |
| 1553 | "header": function( elem ) { |
| 1554 | return rheader.test( elem.nodeName ); |
| 1555 | }, |
| 1556 | |
| 1557 | "input": function( elem ) { |
| 1558 | return rinputs.test( elem.nodeName ); |
| 1559 | }, |
| 1560 | |
| 1561 | "button": function( elem ) { |
| 1562 | var name = elem.nodeName.toLowerCase(); |
| 1563 | return name === "input" && elem.type === "button" || name === "button"; |
| 1564 | }, |
| 1565 | |
| 1566 | "text": function( elem ) { |
| 1567 | var attr; |
| 1568 | return elem.nodeName.toLowerCase() === "input" && |
| 1569 | elem.type === "text" && |
| 1570 | |
| 1571 | // Support: IE<8 |
| 1572 | // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" |
| 1573 | ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); |
| 1574 | }, |
| 1575 | |
| 1576 | // Position-in-collection |
| 1577 | "first": createPositionalPseudo(function() { |
| 1578 | return [ 0 ]; |
| 1579 | }), |
| 1580 | |
| 1581 | "last": createPositionalPseudo(function( matchIndexes, length ) { |
| 1582 | return [ length - 1 ]; |
| 1583 | }), |
| 1584 | |
| 1585 | "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { |
| 1586 | return [ argument < 0 ? argument + length : argument ]; |
| 1587 | }), |
| 1588 | |
| 1589 | "even": createPositionalPseudo(function( matchIndexes, length ) { |
| 1590 | var i = 0; |
| 1591 | for ( ; i < length; i += 2 ) { |
| 1592 | matchIndexes.push( i ); |
| 1593 | } |
| 1594 | return matchIndexes; |
| 1595 | }), |
| 1596 | |
| 1597 | "odd": createPositionalPseudo(function( matchIndexes, length ) { |
| 1598 | var i = 1; |
| 1599 | for ( ; i < length; i += 2 ) { |
| 1600 | matchIndexes.push( i ); |
| 1601 | } |
| 1602 | return matchIndexes; |
| 1603 | }), |
| 1604 | |
| 1605 | "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { |
| 1606 | var i = argument < 0 ? |
| 1607 | argument + length : |
| 1608 | argument > length ? |
| 1609 | length : |
| 1610 | argument; |
| 1611 | for ( ; --i >= 0; ) { |
| 1612 | matchIndexes.push( i ); |
| 1613 | } |
| 1614 | return matchIndexes; |
| 1615 | }), |
| 1616 | |
| 1617 | "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { |
| 1618 | var i = argument < 0 ? argument + length : argument; |
| 1619 | for ( ; ++i < length; ) { |
| 1620 | matchIndexes.push( i ); |
| 1621 | } |
| 1622 | return matchIndexes; |
| 1623 | }) |
| 1624 | } |
| 1625 | }; |
| 1626 | |
| 1627 | Expr.pseudos["nth"] = Expr.pseudos["eq"]; |
| 1628 | |
| 1629 | // Add button/input type pseudos |
| 1630 | for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { |
| 1631 | Expr.pseudos[ i ] = createInputPseudo( i ); |
| 1632 | } |
| 1633 | for ( i in { submit: true, reset: true } ) { |
| 1634 | Expr.pseudos[ i ] = createButtonPseudo( i ); |
| 1635 | } |
| 1636 | |
| 1637 | // Easy API for creating new setFilters |
| 1638 | function setFilters() {} |
| 1639 | setFilters.prototype = Expr.filters = Expr.pseudos; |
| 1640 | Expr.setFilters = new setFilters(); |
| 1641 | |
| 1642 | tokenize = Sizzle.tokenize = function( selector, parseOnly ) { |
| 1643 | var matched, match, tokens, type, |
| 1644 | soFar, groups, preFilters, |
| 1645 | cached = tokenCache[ selector + " " ]; |
| 1646 | |
| 1647 | if ( cached ) { |
| 1648 | return parseOnly ? 0 : cached.slice( 0 ); |
| 1649 | } |
| 1650 | |
| 1651 | soFar = selector; |
| 1652 | groups = []; |
| 1653 | preFilters = Expr.preFilter; |
| 1654 | |
| 1655 | while ( soFar ) { |
| 1656 | |
| 1657 | // Comma and first run |
| 1658 | if ( !matched || (match = rcomma.exec( soFar )) ) { |
| 1659 | if ( match ) { |
| 1660 | // Don't consume trailing commas as valid |
| 1661 | soFar = soFar.slice( match[0].length ) || soFar; |
| 1662 | } |
| 1663 | groups.push( (tokens = []) ); |
| 1664 | } |
| 1665 | |
| 1666 | matched = false; |
| 1667 | |
| 1668 | // Combinators |
| 1669 | if ( (match = rcombinators.exec( soFar )) ) { |
| 1670 | matched = match.shift(); |
| 1671 | tokens.push({ |
| 1672 | value: matched, |
| 1673 | // Cast descendant combinators to space |
| 1674 | type: match[0].replace( rtrim, " " ) |
| 1675 | }); |
| 1676 | soFar = soFar.slice( matched.length ); |
| 1677 | } |
| 1678 | |
| 1679 | // Filters |
| 1680 | for ( type in Expr.filter ) { |
| 1681 | if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || |
| 1682 | (match = preFilters[ type ]( match ))) ) { |
| 1683 | matched = match.shift(); |
| 1684 | tokens.push({ |
| 1685 | value: matched, |
| 1686 | type: type, |
| 1687 | matches: match |
| 1688 | }); |
| 1689 | soFar = soFar.slice( matched.length ); |
| 1690 | } |
| 1691 | } |
| 1692 | |
| 1693 | if ( !matched ) { |
| 1694 | break; |
| 1695 | } |
| 1696 | } |
| 1697 | |
| 1698 | // Return the length of the invalid excess |
| 1699 | // if we're just parsing |
| 1700 | // Otherwise, throw an error or return tokens |
| 1701 | return parseOnly ? |
| 1702 | soFar.length : |
| 1703 | soFar ? |
| 1704 | Sizzle.error( selector ) : |
| 1705 | // Cache the tokens |
| 1706 | tokenCache( selector, groups ).slice( 0 ); |
| 1707 | }; |
| 1708 | |
| 1709 | function toSelector( tokens ) { |
| 1710 | var i = 0, |
| 1711 | len = tokens.length, |
| 1712 | selector = ""; |
| 1713 | for ( ; i < len; i++ ) { |
| 1714 | selector += tokens[i].value; |
| 1715 | } |
| 1716 | return selector; |
| 1717 | } |
| 1718 | |
| 1719 | function addCombinator( matcher, combinator, base ) { |
| 1720 | var dir = combinator.dir, |
| 1721 | skip = combinator.next, |
| 1722 | key = skip || dir, |
| 1723 | checkNonElements = base && key === "parentNode", |
| 1724 | doneName = done++; |
| 1725 | |
| 1726 | return combinator.first ? |
| 1727 | // Check against closest ancestor/preceding element |
| 1728 | function( elem, context, xml ) { |
| 1729 | while ( (elem = elem[ dir ]) ) { |
| 1730 | if ( elem.nodeType === 1 || checkNonElements ) { |
| 1731 | return matcher( elem, context, xml ); |
| 1732 | } |
| 1733 | } |
| 1734 | return false; |
| 1735 | } : |
| 1736 | |
| 1737 | // Check against all ancestor/preceding elements |
| 1738 | function( elem, context, xml ) { |
| 1739 | var oldCache, uniqueCache, outerCache, |
| 1740 | newCache = [ dirruns, doneName ]; |
| 1741 | |
| 1742 | // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching |
| 1743 | if ( xml ) { |
| 1744 | while ( (elem = elem[ dir ]) ) { |
| 1745 | if ( elem.nodeType === 1 || checkNonElements ) { |
| 1746 | if ( matcher( elem, context, xml ) ) { |
| 1747 | return true; |
| 1748 | } |
| 1749 | } |
| 1750 | } |
| 1751 | } else { |
| 1752 | while ( (elem = elem[ dir ]) ) { |
| 1753 | if ( elem.nodeType === 1 || checkNonElements ) { |
| 1754 | outerCache = elem[ expando ] || (elem[ expando ] = {}); |
| 1755 | |
| 1756 | // Support: IE <9 only |
| 1757 | // Defend against cloned attroperties (jQuery gh-1709) |
| 1758 | uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {}); |
| 1759 | |
| 1760 | if ( skip && skip === elem.nodeName.toLowerCase() ) { |
| 1761 | elem = elem[ dir ] || elem; |
| 1762 | } else if ( (oldCache = uniqueCache[ key ]) && |
| 1763 | oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { |
| 1764 | |
| 1765 | // Assign to newCache so results back-propagate to previous elements |
| 1766 | return (newCache[ 2 ] = oldCache[ 2 ]); |
| 1767 | } else { |
| 1768 | // Reuse newcache so results back-propagate to previous elements |
| 1769 | uniqueCache[ key ] = newCache; |
| 1770 | |
| 1771 | // A match means we're done; a fail means we have to keep checking |
| 1772 | if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { |
| 1773 | return true; |
| 1774 | } |
| 1775 | } |
| 1776 | } |
| 1777 | } |
| 1778 | } |
| 1779 | return false; |
| 1780 | }; |
| 1781 | } |
| 1782 | |
| 1783 | function elementMatcher( matchers ) { |
| 1784 | return matchers.length > 1 ? |
| 1785 | function( elem, context, xml ) { |
| 1786 | var i = matchers.length; |
| 1787 | while ( i-- ) { |
| 1788 | if ( !matchers[i]( elem, context, xml ) ) { |
| 1789 | return false; |
| 1790 | } |
| 1791 | } |
| 1792 | return true; |
| 1793 | } : |
| 1794 | matchers[0]; |
| 1795 | } |
| 1796 | |
| 1797 | function multipleContexts( selector, contexts, results ) { |
| 1798 | var i = 0, |
| 1799 | len = contexts.length; |
| 1800 | for ( ; i < len; i++ ) { |
| 1801 | Sizzle( selector, contexts[i], results ); |
| 1802 | } |
| 1803 | return results; |
| 1804 | } |
| 1805 | |
| 1806 | function condense( unmatched, map, filter, context, xml ) { |
| 1807 | var elem, |
| 1808 | newUnmatched = [], |
| 1809 | i = 0, |
| 1810 | len = unmatched.length, |
| 1811 | mapped = map != null; |
| 1812 | |
| 1813 | for ( ; i < len; i++ ) { |
| 1814 | if ( (elem = unmatched[i]) ) { |
| 1815 | if ( !filter || filter( elem, context, xml ) ) { |
| 1816 | newUnmatched.push( elem ); |
| 1817 | if ( mapped ) { |
| 1818 | map.push( i ); |
| 1819 | } |
| 1820 | } |
| 1821 | } |
| 1822 | } |
| 1823 | |
| 1824 | return newUnmatched; |
| 1825 | } |
| 1826 | |
| 1827 | function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { |
| 1828 | if ( postFilter && !postFilter[ expando ] ) { |
| 1829 | postFilter = setMatcher( postFilter ); |
| 1830 | } |
| 1831 | if ( postFinder && !postFinder[ expando ] ) { |
| 1832 | postFinder = setMatcher( postFinder, postSelector ); |
| 1833 | } |
| 1834 | return markFunction(function( seed, results, context, xml ) { |
| 1835 | var temp, i, elem, |
| 1836 | preMap = [], |
| 1837 | postMap = [], |
| 1838 | preexisting = results.length, |
| 1839 | |
| 1840 | // Get initial elements from seed or context |
| 1841 | elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), |
| 1842 | |
| 1843 | // Prefilter to get matcher input, preserving a map for seed-results synchronization |
| 1844 | matcherIn = preFilter && ( seed || !selector ) ? |
| 1845 | condense( elems, preMap, preFilter, context, xml ) : |
| 1846 | elems, |
| 1847 | |
| 1848 | matcherOut = matcher ? |
| 1849 | // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, |
| 1850 | postFinder || ( seed ? preFilter : preexisting || postFilter ) ? |
| 1851 | |
| 1852 | // ...intermediate processing is necessary |
| 1853 | [] : |
| 1854 | |
| 1855 | // ...otherwise use results directly |
| 1856 | results : |
| 1857 | matcherIn; |
| 1858 | |
| 1859 | // Find primary matches |
| 1860 | if ( matcher ) { |
| 1861 | matcher( matcherIn, matcherOut, context, xml ); |
| 1862 | } |
| 1863 | |
| 1864 | // Apply postFilter |
| 1865 | if ( postFilter ) { |
| 1866 | temp = condense( matcherOut, postMap ); |
| 1867 | postFilter( temp, [], context, xml ); |
| 1868 | |
| 1869 | // Un-match failing elements by moving them back to matcherIn |
| 1870 | i = temp.length; |
| 1871 | while ( i-- ) { |
| 1872 | if ( (elem = temp[i]) ) { |
| 1873 | matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); |
| 1874 | } |
| 1875 | } |
| 1876 | } |
| 1877 | |
| 1878 | if ( seed ) { |
| 1879 | if ( postFinder || preFilter ) { |
| 1880 | if ( postFinder ) { |
| 1881 | // Get the final matcherOut by condensing this intermediate into postFinder contexts |
| 1882 | temp = []; |
| 1883 | i = matcherOut.length; |
| 1884 | while ( i-- ) { |
| 1885 | if ( (elem = matcherOut[i]) ) { |
| 1886 | // Restore matcherIn since elem is not yet a final match |
| 1887 | temp.push( (matcherIn[i] = elem) ); |
| 1888 | } |
| 1889 | } |
| 1890 | postFinder( null, (matcherOut = []), temp, xml ); |
| 1891 | } |
| 1892 | |
| 1893 | // Move matched elements from seed to results to keep them synchronized |
| 1894 | i = matcherOut.length; |
| 1895 | while ( i-- ) { |
| 1896 | if ( (elem = matcherOut[i]) && |
| 1897 | (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) { |
| 1898 | |
| 1899 | seed[temp] = !(results[temp] = elem); |
| 1900 | } |
| 1901 | } |
| 1902 | } |
| 1903 | |
| 1904 | // Add elements to results, through postFinder if defined |
| 1905 | } else { |
| 1906 | matcherOut = condense( |
| 1907 | matcherOut === results ? |
| 1908 | matcherOut.splice( preexisting, matcherOut.length ) : |
| 1909 | matcherOut |
| 1910 | ); |
| 1911 | if ( postFinder ) { |
| 1912 | postFinder( null, results, matcherOut, xml ); |
| 1913 | } else { |
| 1914 | push.apply( results, matcherOut ); |
| 1915 | } |
| 1916 | } |
| 1917 | }); |
| 1918 | } |
| 1919 | |
| 1920 | function matcherFromTokens( tokens ) { |
| 1921 | var checkContext, matcher, j, |
| 1922 | len = tokens.length, |
| 1923 | leadingRelative = Expr.relative[ tokens[0].type ], |
| 1924 | implicitRelative = leadingRelative || Expr.relative[" "], |
| 1925 | i = leadingRelative ? 1 : 0, |
| 1926 | |
| 1927 | // The foundational matcher ensures that elements are reachable from top-level context(s) |
| 1928 | matchContext = addCombinator( function( elem ) { |
| 1929 | return elem === checkContext; |
| 1930 | }, implicitRelative, true ), |
| 1931 | matchAnyContext = addCombinator( function( elem ) { |
| 1932 | return indexOf( checkContext, elem ) > -1; |
| 1933 | }, implicitRelative, true ), |
| 1934 | matchers = [ function( elem, context, xml ) { |
| 1935 | var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( |
| 1936 | (checkContext = context).nodeType ? |
| 1937 | matchContext( elem, context, xml ) : |
| 1938 | matchAnyContext( elem, context, xml ) ); |
| 1939 | // Avoid hanging onto element (issue #299) |
| 1940 | checkContext = null; |
| 1941 | return ret; |
| 1942 | } ]; |
| 1943 | |
| 1944 | for ( ; i < len; i++ ) { |
| 1945 | if ( (matcher = Expr.relative[ tokens[i].type ]) ) { |
| 1946 | matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; |
| 1947 | } else { |
| 1948 | matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); |
| 1949 | |
| 1950 | // Return special upon seeing a positional matcher |
| 1951 | if ( matcher[ expando ] ) { |
| 1952 | // Find the next relative operator (if any) for proper handling |
| 1953 | j = ++i; |
| 1954 | for ( ; j < len; j++ ) { |
| 1955 | if ( Expr.relative[ tokens[j].type ] ) { |
| 1956 | break; |
| 1957 | } |
| 1958 | } |
| 1959 | return setMatcher( |
| 1960 | i > 1 && elementMatcher( matchers ), |
| 1961 | i > 1 && toSelector( |
| 1962 | // If the preceding token was a descendant combinator, insert an implicit any-element `*` |
| 1963 | tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) |
| 1964 | ).replace( rtrim, "$1" ), |
| 1965 | matcher, |
| 1966 | i < j && matcherFromTokens( tokens.slice( i, j ) ), |
| 1967 | j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), |
| 1968 | j < len && toSelector( tokens ) |
| 1969 | ); |
| 1970 | } |
| 1971 | matchers.push( matcher ); |
| 1972 | } |
| 1973 | } |
| 1974 | |
| 1975 | return elementMatcher( matchers ); |
| 1976 | } |
| 1977 | |
| 1978 | function matcherFromGroupMatchers( elementMatchers, setMatchers ) { |
| 1979 | var bySet = setMatchers.length > 0, |
| 1980 | byElement = elementMatchers.length > 0, |
| 1981 | superMatcher = function( seed, context, xml, results, outermost ) { |
| 1982 | var elem, j, matcher, |
| 1983 | matchedCount = 0, |
| 1984 | i = "0", |
| 1985 | unmatched = seed && [], |
| 1986 | setMatched = [], |
| 1987 | contextBackup = outermostContext, |
| 1988 | // We must always have either seed elements or outermost context |
| 1989 | elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), |
| 1990 | // Use integer dirruns iff this is the outermost matcher |
| 1991 | dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), |
| 1992 | len = elems.length; |
| 1993 | |
| 1994 | if ( outermost ) { |
| 1995 | outermostContext = context === document || context || outermost; |
| 1996 | } |
| 1997 | |
| 1998 | // Add elements passing elementMatchers directly to results |
| 1999 | // Support: IE<9, Safari |
| 2000 | // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id |
| 2001 | for ( ; i !== len && (elem = elems[i]) != null; i++ ) { |
| 2002 | if ( byElement && elem ) { |
| 2003 | j = 0; |
| 2004 | if ( !context && elem.ownerDocument !== document ) { |
| 2005 | setDocument( elem ); |
| 2006 | xml = !documentIsHTML; |
| 2007 | } |
| 2008 | while ( (matcher = elementMatchers[j++]) ) { |
| 2009 | if ( matcher( elem, context || document, xml) ) { |
| 2010 | results.push( elem ); |
| 2011 | break; |
| 2012 | } |
| 2013 | } |
| 2014 | if ( outermost ) { |
| 2015 | dirruns = dirrunsUnique; |
| 2016 | } |
| 2017 | } |
| 2018 | |
| 2019 | // Track unmatched elements for set filters |
| 2020 | if ( bySet ) { |
| 2021 | // They will have gone through all possible matchers |
| 2022 | if ( (elem = !matcher && elem) ) { |
| 2023 | matchedCount--; |
| 2024 | } |
| 2025 | |
| 2026 | // Lengthen the array for every element, matched or not |
| 2027 | if ( seed ) { |
| 2028 | unmatched.push( elem ); |
| 2029 | } |
| 2030 | } |
| 2031 | } |
| 2032 | |
| 2033 | // `i` is now the count of elements visited above, and adding it to `matchedCount` |
| 2034 | // makes the latter nonnegative. |
| 2035 | matchedCount += i; |
| 2036 | |
| 2037 | // Apply set filters to unmatched elements |
| 2038 | // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` |
| 2039 | // equals `i`), unless we didn't visit _any_ elements in the above loop because we have |
| 2040 | // no element matchers and no seed. |
| 2041 | // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that |
| 2042 | // case, which will result in a "00" `matchedCount` that differs from `i` but is also |
| 2043 | // numerically zero. |
| 2044 | if ( bySet && i !== matchedCount ) { |
| 2045 | j = 0; |
| 2046 | while ( (matcher = setMatchers[j++]) ) { |
| 2047 | matcher( unmatched, setMatched, context, xml ); |
| 2048 | } |
| 2049 | |
| 2050 | if ( seed ) { |
| 2051 | // Reintegrate element matches to eliminate the need for sorting |
| 2052 | if ( matchedCount > 0 ) { |
| 2053 | while ( i-- ) { |
| 2054 | if ( !(unmatched[i] || setMatched[i]) ) { |
| 2055 | setMatched[i] = pop.call( results ); |
| 2056 | } |
| 2057 | } |
| 2058 | } |
| 2059 | |
| 2060 | // Discard index placeholder values to get only actual matches |
| 2061 | setMatched = condense( setMatched ); |
| 2062 | } |
| 2063 | |
| 2064 | // Add matches to results |
| 2065 | push.apply( results, setMatched ); |
| 2066 | |
| 2067 | // Seedless set matches succeeding multiple successful matchers stipulate sorting |
| 2068 | if ( outermost && !seed && setMatched.length > 0 && |
| 2069 | ( matchedCount + setMatchers.length ) > 1 ) { |
| 2070 | |
| 2071 | Sizzle.uniqueSort( results ); |
| 2072 | } |
| 2073 | } |
| 2074 | |
| 2075 | // Override manipulation of globals by nested matchers |
| 2076 | if ( outermost ) { |
| 2077 | dirruns = dirrunsUnique; |
| 2078 | outermostContext = contextBackup; |
| 2079 | } |
| 2080 | |
| 2081 | return unmatched; |
| 2082 | }; |
| 2083 | |
| 2084 | return bySet ? |
| 2085 | markFunction( superMatcher ) : |
| 2086 | superMatcher; |
| 2087 | } |
| 2088 | |
| 2089 | compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { |
| 2090 | var i, |
| 2091 | setMatchers = [], |
| 2092 | elementMatchers = [], |
| 2093 | cached = compilerCache[ selector + " " ]; |
| 2094 | |
| 2095 | if ( !cached ) { |
| 2096 | // Generate a function of recursive functions that can be used to check each element |
| 2097 | if ( !match ) { |
| 2098 | match = tokenize( selector ); |
| 2099 | } |
| 2100 | i = match.length; |
| 2101 | while ( i-- ) { |
| 2102 | cached = matcherFromTokens( match[i] ); |
| 2103 | if ( cached[ expando ] ) { |
| 2104 | setMatchers.push( cached ); |
| 2105 | } else { |
| 2106 | elementMatchers.push( cached ); |
| 2107 | } |
| 2108 | } |
| 2109 | |
| 2110 | // Cache the compiled function |
| 2111 | cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); |
| 2112 | |
| 2113 | // Save selector and tokenization |
| 2114 | cached.selector = selector; |
| 2115 | } |
| 2116 | return cached; |
| 2117 | }; |
| 2118 | |
| 2119 | /** |
| 2120 | * A low-level selection function that works with Sizzle's compiled |
| 2121 | * selector functions |
| 2122 | * @param {String|Function} selector A selector or a pre-compiled |
| 2123 | * selector function built with Sizzle.compile |
| 2124 | * @param {Element} context |
| 2125 | * @param {Array} [results] |
| 2126 | * @param {Array} [seed] A set of elements to match against |
| 2127 | */ |
| 2128 | select = Sizzle.select = function( selector, context, results, seed ) { |
| 2129 | var i, tokens, token, type, find, |
| 2130 | compiled = typeof selector === "function" && selector, |
| 2131 | match = !seed && tokenize( (selector = compiled.selector || selector) ); |
| 2132 | |
| 2133 | results = results || []; |
| 2134 | |
| 2135 | // Try to minimize operations if there is only one selector in the list and no seed |
| 2136 | // (the latter of which guarantees us context) |
| 2137 | if ( match.length === 1 ) { |
| 2138 | |
| 2139 | // Reduce context if the leading compound selector is an ID |
| 2140 | tokens = match[0] = match[0].slice( 0 ); |
| 2141 | if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && |
| 2142 | context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) { |
| 2143 | |
| 2144 | context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; |
| 2145 | if ( !context ) { |
| 2146 | return results; |
| 2147 | |
| 2148 | // Precompiled matchers will still verify ancestry, so step up a level |
| 2149 | } else if ( compiled ) { |
| 2150 | context = context.parentNode; |
| 2151 | } |
| 2152 | |
| 2153 | selector = selector.slice( tokens.shift().value.length ); |
| 2154 | } |
| 2155 | |
| 2156 | // Fetch a seed set for right-to-left matching |
| 2157 | i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; |
| 2158 | while ( i-- ) { |
| 2159 | token = tokens[i]; |
| 2160 | |
| 2161 | // Abort if we hit a combinator |
| 2162 | if ( Expr.relative[ (type = token.type) ] ) { |
| 2163 | break; |
| 2164 | } |
| 2165 | if ( (find = Expr.find[ type ]) ) { |
| 2166 | // Search, expanding context for leading sibling combinators |
| 2167 | if ( (seed = find( |
| 2168 | token.matches[0].replace( runescape, funescape ), |
| 2169 | rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context |
| 2170 | )) ) { |
| 2171 | |
| 2172 | // If seed is empty or no tokens remain, we can return early |
| 2173 | tokens.splice( i, 1 ); |
| 2174 | selector = seed.length && toSelector( tokens ); |
| 2175 | if ( !selector ) { |
| 2176 | push.apply( results, seed ); |
| 2177 | return results; |
| 2178 | } |
| 2179 | |
| 2180 | break; |
| 2181 | } |
| 2182 | } |
| 2183 | } |
| 2184 | } |
| 2185 | |
| 2186 | // Compile and execute a filtering function if one is not provided |
| 2187 | // Provide `match` to avoid retokenization if we modified the selector above |
| 2188 | ( compiled || compile( selector, match ) )( |
| 2189 | seed, |
| 2190 | context, |
| 2191 | !documentIsHTML, |
| 2192 | results, |
| 2193 | !context || rsibling.test( selector ) && testContext( context.parentNode ) || context |
| 2194 | ); |
| 2195 | return results; |
| 2196 | }; |
| 2197 | |
| 2198 | // One-time assignments |
| 2199 | |
| 2200 | // Sort stability |
| 2201 | support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; |
| 2202 | |
| 2203 | // Support: Chrome 14-35+ |
| 2204 | // Always assume duplicates if they aren't passed to the comparison function |
| 2205 | support.detectDuplicates = !!hasDuplicate; |
| 2206 | |
| 2207 | // Initialize against the default document |
| 2208 | setDocument(); |
| 2209 | |
| 2210 | // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) |
| 2211 | // Detached nodes confoundingly follow *each other* |
| 2212 | support.sortDetached = assert(function( el ) { |
| 2213 | // Should return 1, but returns 4 (following) |
| 2214 | return el.compareDocumentPosition( document.createElement("fieldset") ) & 1; |
| 2215 | }); |
| 2216 | |
| 2217 | // Support: IE<8 |
| 2218 | // Prevent attribute/property "interpolation" |
| 2219 | // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx |
| 2220 | if ( !assert(function( el ) { |
| 2221 | el.innerHTML = "<a href='#'></a>"; |
| 2222 | return el.firstChild.getAttribute("href") === "#" ; |
| 2223 | }) ) { |
| 2224 | addHandle( "type|href|height|width", function( elem, name, isXML ) { |
| 2225 | if ( !isXML ) { |
| 2226 | return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); |
| 2227 | } |
| 2228 | }); |
| 2229 | } |
| 2230 | |
| 2231 | // Support: IE<9 |
| 2232 | // Use defaultValue in place of getAttribute("value") |
| 2233 | if ( !support.attributes || !assert(function( el ) { |
| 2234 | el.innerHTML = "<input/>"; |
| 2235 | el.firstChild.setAttribute( "value", "" ); |
| 2236 | return el.firstChild.getAttribute( "value" ) === ""; |
| 2237 | }) ) { |
| 2238 | addHandle( "value", function( elem, name, isXML ) { |
| 2239 | if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { |
| 2240 | return elem.defaultValue; |
| 2241 | } |
| 2242 | }); |
| 2243 | } |
| 2244 | |
| 2245 | // Support: IE<9 |
| 2246 | // Use getAttributeNode to fetch booleans when getAttribute lies |
| 2247 | if ( !assert(function( el ) { |
| 2248 | return el.getAttribute("disabled") == null; |
| 2249 | }) ) { |
| 2250 | addHandle( booleans, function( elem, name, isXML ) { |
| 2251 | var val; |
| 2252 | if ( !isXML ) { |
| 2253 | return elem[ name ] === true ? name.toLowerCase() : |
| 2254 | (val = elem.getAttributeNode( name )) && val.specified ? |
| 2255 | val.value : |
| 2256 | null; |
| 2257 | } |
| 2258 | }); |
| 2259 | } |
| 2260 | |
| 2261 | // EXPOSE |
| 2262 | var _sizzle = window.Sizzle; |
| 2263 | |
| 2264 | Sizzle.noConflict = function() { |
| 2265 | if ( window.Sizzle === Sizzle ) { |
| 2266 | window.Sizzle = _sizzle; |
| 2267 | } |
| 2268 | |
| 2269 | return Sizzle; |
| 2270 | }; |
| 2271 | |
| 2272 | if ( typeof define === "function" && define.amd ) { |
| 2273 | define(function() { return Sizzle; }); |
| 2274 | // Sizzle requires that there be a global window in Common-JS like environments |
| 2275 | } else if ( typeof module !== "undefined" && module.exports ) { |
| 2276 | module.exports = Sizzle; |
| 2277 | } else { |
| 2278 | window.Sizzle = Sizzle; |
| 2279 | } |
| 2280 | // EXPOSE |
| 2281 | |
| 2282 | })( window ); |