| @@ 590-2713 (lines=2124) @@ | ||
| 587 | * |
|
| 588 | * Date: 2015-10-17 |
|
| 589 | */ |
|
| 590 | (function( window ) { |
|
| 591 | ||
| 592 | var i, |
|
| 593 | support, |
|
| 594 | Expr, |
|
| 595 | getText, |
|
| 596 | isXML, |
|
| 597 | tokenize, |
|
| 598 | compile, |
|
| 599 | select, |
|
| 600 | outermostContext, |
|
| 601 | sortInput, |
|
| 602 | hasDuplicate, |
|
| 603 | ||
| 604 | // Local document vars |
|
| 605 | setDocument, |
|
| 606 | document, |
|
| 607 | docElem, |
|
| 608 | documentIsHTML, |
|
| 609 | rbuggyQSA, |
|
| 610 | rbuggyMatches, |
|
| 611 | matches, |
|
| 612 | contains, |
|
| 613 | ||
| 614 | // Instance-specific data |
|
| 615 | expando = "sizzle" + 1 * new Date(), |
|
| 616 | preferredDoc = window.document, |
|
| 617 | dirruns = 0, |
|
| 618 | done = 0, |
|
| 619 | classCache = createCache(), |
|
| 620 | tokenCache = createCache(), |
|
| 621 | compilerCache = createCache(), |
|
| 622 | sortOrder = function( a, b ) { |
|
| 623 | if ( a === b ) { |
|
| 624 | hasDuplicate = true; |
|
| 625 | } |
|
| 626 | return 0; |
|
| 627 | }, |
|
| 628 | ||
| 629 | // General-purpose constants |
|
| 630 | MAX_NEGATIVE = 1 << 31, |
|
| 631 | ||
| 632 | // Instance methods |
|
| 633 | hasOwn = ({}).hasOwnProperty, |
|
| 634 | arr = [], |
|
| 635 | pop = arr.pop, |
|
| 636 | push_native = arr.push, |
|
| 637 | push = arr.push, |
|
| 638 | slice = arr.slice, |
|
| 639 | // Use a stripped-down indexOf as it's faster than native |
|
| 640 | // http://jsperf.com/thor-indexof-vs-for/5 |
|
| 641 | indexOf = function( list, elem ) { |
|
| 642 | var i = 0, |
|
| 643 | len = list.length; |
|
| 644 | for ( ; i < len; i++ ) { |
|
| 645 | if ( list[i] === elem ) { |
|
| 646 | return i; |
|
| 647 | } |
|
| 648 | } |
|
| 649 | return -1; |
|
| 650 | }, |
|
| 651 | ||
| 652 | booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", |
|
| 653 | ||
| 654 | // Regular expressions |
|
| 655 | ||
| 656 | // http://www.w3.org/TR/css3-selectors/#whitespace |
|
| 657 | whitespace = "[\\x20\\t\\r\\n\\f]", |
|
| 658 | ||
| 659 | // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier |
|
| 660 | identifier = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", |
|
| 661 | ||
| 662 | // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors |
|
| 663 | attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + |
|
| 664 | // Operator (capture 2) |
|
| 665 | "*([*^$|!~]?=)" + whitespace + |
|
| 666 | // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" |
|
| 667 | "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + |
|
| 668 | "*\\]", |
|
| 669 | ||
| 670 | pseudos = ":(" + identifier + ")(?:\\((" + |
|
| 671 | // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: |
|
| 672 | // 1. quoted (capture 3; capture 4 or capture 5) |
|
| 673 | "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + |
|
| 674 | // 2. simple (capture 6) |
|
| 675 | "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + |
|
| 676 | // 3. anything else (capture 2) |
|
| 677 | ".*" + |
|
| 678 | ")\\)|)", |
|
| 679 | ||
| 680 | // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter |
|
| 681 | rwhitespace = new RegExp( whitespace + "+", "g" ), |
|
| 682 | rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), |
|
| 683 | ||
| 684 | rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), |
|
| 685 | rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), |
|
| 686 | ||
| 687 | rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), |
|
| 688 | ||
| 689 | rpseudo = new RegExp( pseudos ), |
|
| 690 | ridentifier = new RegExp( "^" + identifier + "$" ), |
|
| 691 | ||
| 692 | matchExpr = { |
|
| 693 | "ID": new RegExp( "^#(" + identifier + ")" ), |
|
| 694 | "CLASS": new RegExp( "^\\.(" + identifier + ")" ), |
|
| 695 | "TAG": new RegExp( "^(" + identifier + "|[*])" ), |
|
| 696 | "ATTR": new RegExp( "^" + attributes ), |
|
| 697 | "PSEUDO": new RegExp( "^" + pseudos ), |
|
| 698 | "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + |
|
| 699 | "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + |
|
| 700 | "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), |
|
| 701 | "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), |
|
| 702 | // For use in libraries implementing .is() |
|
| 703 | // We use this for POS matching in `select` |
|
| 704 | "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + |
|
| 705 | whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) |
|
| 706 | }, |
|
| 707 | ||
| 708 | rinputs = /^(?:input|select|textarea|button)$/i, |
|
| 709 | rheader = /^h\d$/i, |
|
| 710 | ||
| 711 | rnative = /^[^{]+\{\s*\[native \w/, |
|
| 712 | ||
| 713 | // Easily-parseable/retrievable ID or TAG or CLASS selectors |
|
| 714 | rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, |
|
| 715 | ||
| 716 | rsibling = /[+~]/, |
|
| 717 | rescape = /'|\\/g, |
|
| 718 | ||
| 719 | // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters |
|
| 720 | runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), |
|
| 721 | funescape = function( _, escaped, escapedWhitespace ) { |
|
| 722 | var high = "0x" + escaped - 0x10000; |
|
| 723 | // NaN means non-codepoint |
|
| 724 | // Support: Firefox<24 |
|
| 725 | // Workaround erroneous numeric interpretation of +"0x" |
|
| 726 | return high !== high || escapedWhitespace ? |
|
| 727 | escaped : |
|
| 728 | high < 0 ? |
|
| 729 | // BMP codepoint |
|
| 730 | String.fromCharCode( high + 0x10000 ) : |
|
| 731 | // Supplemental Plane codepoint (surrogate pair) |
|
| 732 | String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); |
|
| 733 | }, |
|
| 734 | ||
| 735 | // Used for iframes |
|
| 736 | // See setDocument() |
|
| 737 | // Removing the function wrapper causes a "Permission Denied" |
|
| 738 | // error in IE |
|
| 739 | unloadHandler = function() { |
|
| 740 | setDocument(); |
|
| 741 | }; |
|
| 742 | ||
| 743 | // Optimize for push.apply( _, NodeList ) |
|
| 744 | try { |
|
| 745 | push.apply( |
|
| 746 | (arr = slice.call( preferredDoc.childNodes )), |
|
| 747 | preferredDoc.childNodes |
|
| 748 | ); |
|
| 749 | // Support: Android<4.0 |
|
| 750 | // Detect silently failing push.apply |
|
| 751 | arr[ preferredDoc.childNodes.length ].nodeType; |
|
| 752 | } catch ( e ) { |
|
| 753 | push = { apply: arr.length ? |
|
| 754 | ||
| 755 | // Leverage slice if possible |
|
| 756 | function( target, els ) { |
|
| 757 | push_native.apply( target, slice.call(els) ); |
|
| 758 | } : |
|
| 759 | ||
| 760 | // Support: IE<9 |
|
| 761 | // Otherwise append directly |
|
| 762 | function( target, els ) { |
|
| 763 | var j = target.length, |
|
| 764 | i = 0; |
|
| 765 | // Can't trust NodeList.length |
|
| 766 | while ( (target[j++] = els[i++]) ) {} |
|
| 767 | target.length = j - 1; |
|
| 768 | } |
|
| 769 | }; |
|
| 770 | } |
|
| 771 | ||
| 772 | function Sizzle( selector, context, results, seed ) { |
|
| 773 | var m, i, elem, nid, nidselect, match, groups, newSelector, |
|
| 774 | newContext = context && context.ownerDocument, |
|
| 775 | ||
| 776 | // nodeType defaults to 9, since context defaults to document |
|
| 777 | nodeType = context ? context.nodeType : 9; |
|
| 778 | ||
| 779 | results = results || []; |
|
| 780 | ||
| 781 | // Return early from calls with invalid selector or context |
|
| 782 | if ( typeof selector !== "string" || !selector || |
|
| 783 | nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { |
|
| 784 | ||
| 785 | return results; |
|
| 786 | } |
|
| 787 | ||
| 788 | // Try to shortcut find operations (as opposed to filters) in HTML documents |
|
| 789 | if ( !seed ) { |
|
| 790 | ||
| 791 | if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { |
|
| 792 | setDocument( context ); |
|
| 793 | } |
|
| 794 | context = context || document; |
|
| 795 | ||
| 796 | if ( documentIsHTML ) { |
|
| 797 | ||
| 798 | // If the selector is sufficiently simple, try using a "get*By*" DOM method |
|
| 799 | // (excepting DocumentFragment context, where the methods don't exist) |
|
| 800 | if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { |
|
| 801 | ||
| 802 | // ID selector |
|
| 803 | if ( (m = match[1]) ) { |
|
| 804 | ||
| 805 | // Document context |
|
| 806 | if ( nodeType === 9 ) { |
|
| 807 | if ( (elem = context.getElementById( m )) ) { |
|
| 808 | ||
| 809 | // Support: IE, Opera, Webkit |
|
| 810 | // TODO: identify versions |
|
| 811 | // getElementById can match elements by name instead of ID |
|
| 812 | if ( elem.id === m ) { |
|
| 813 | results.push( elem ); |
|
| 814 | return results; |
|
| 815 | } |
|
| 816 | } else { |
|
| 817 | return results; |
|
| 818 | } |
|
| 819 | ||
| 820 | // Element context |
|
| 821 | } else { |
|
| 822 | ||
| 823 | // Support: IE, Opera, Webkit |
|
| 824 | // TODO: identify versions |
|
| 825 | // getElementById can match elements by name instead of ID |
|
| 826 | if ( newContext && (elem = newContext.getElementById( m )) && |
|
| 827 | contains( context, elem ) && |
|
| 828 | elem.id === m ) { |
|
| 829 | ||
| 830 | results.push( elem ); |
|
| 831 | return results; |
|
| 832 | } |
|
| 833 | } |
|
| 834 | ||
| 835 | // Type selector |
|
| 836 | } else if ( match[2] ) { |
|
| 837 | push.apply( results, context.getElementsByTagName( selector ) ); |
|
| 838 | return results; |
|
| 839 | ||
| 840 | // Class selector |
|
| 841 | } else if ( (m = match[3]) && support.getElementsByClassName && |
|
| 842 | context.getElementsByClassName ) { |
|
| 843 | ||
| 844 | push.apply( results, context.getElementsByClassName( m ) ); |
|
| 845 | return results; |
|
| 846 | } |
|
| 847 | } |
|
| 848 | ||
| 849 | // Take advantage of querySelectorAll |
|
| 850 | if ( support.qsa && |
|
| 851 | !compilerCache[ selector + " " ] && |
|
| 852 | (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { |
|
| 853 | ||
| 854 | if ( nodeType !== 1 ) { |
|
| 855 | newContext = context; |
|
| 856 | newSelector = selector; |
|
| 857 | ||
| 858 | // qSA looks outside Element context, which is not what we want |
|
| 859 | // Thanks to Andrew Dupont for this workaround technique |
|
| 860 | // Support: IE <=8 |
|
| 861 | // Exclude object elements |
|
| 862 | } else if ( context.nodeName.toLowerCase() !== "object" ) { |
|
| 863 | ||
| 864 | // Capture the context ID, setting it first if necessary |
|
| 865 | if ( (nid = context.getAttribute( "id" )) ) { |
|
| 866 | nid = nid.replace( rescape, "\\$&" ); |
|
| 867 | } else { |
|
| 868 | context.setAttribute( "id", (nid = expando) ); |
|
| 869 | } |
|
| 870 | ||
| 871 | // Prefix every selector in the list |
|
| 872 | groups = tokenize( selector ); |
|
| 873 | i = groups.length; |
|
| 874 | nidselect = ridentifier.test( nid ) ? "#" + nid : "[id='" + nid + "']"; |
|
| 875 | while ( i-- ) { |
|
| 876 | groups[i] = nidselect + " " + toSelector( groups[i] ); |
|
| 877 | } |
|
| 878 | newSelector = groups.join( "," ); |
|
| 879 | ||
| 880 | // Expand context for sibling selectors |
|
| 881 | newContext = rsibling.test( selector ) && testContext( context.parentNode ) || |
|
| 882 | context; |
|
| 883 | } |
|
| 884 | ||
| 885 | if ( newSelector ) { |
|
| 886 | try { |
|
| 887 | push.apply( results, |
|
| 888 | newContext.querySelectorAll( newSelector ) |
|
| 889 | ); |
|
| 890 | return results; |
|
| 891 | } catch ( qsaError ) { |
|
| 892 | } finally { |
|
| 893 | if ( nid === expando ) { |
|
| 894 | context.removeAttribute( "id" ); |
|
| 895 | } |
|
| 896 | } |
|
| 897 | } |
|
| 898 | } |
|
| 899 | } |
|
| 900 | } |
|
| 901 | ||
| 902 | // All others |
|
| 903 | return select( selector.replace( rtrim, "$1" ), context, results, seed ); |
|
| 904 | } |
|
| 905 | ||
| 906 | /** |
|
| 907 | * Create key-value caches of limited size |
|
| 908 | * @returns {function(string, object)} Returns the Object data after storing it on itself with |
|
| 909 | * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) |
|
| 910 | * deleting the oldest entry |
|
| 911 | */ |
|
| 912 | function createCache() { |
|
| 913 | var keys = []; |
|
| 914 | ||
| 915 | function cache( key, value ) { |
|
| 916 | // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) |
|
| 917 | if ( keys.push( key + " " ) > Expr.cacheLength ) { |
|
| 918 | // Only keep the most recent entries |
|
| 919 | delete cache[ keys.shift() ]; |
|
| 920 | } |
|
| 921 | return (cache[ key + " " ] = value); |
|
| 922 | } |
|
| 923 | return cache; |
|
| 924 | } |
|
| 925 | ||
| 926 | /** |
|
| 927 | * Mark a function for special use by Sizzle |
|
| 928 | * @param {Function} fn The function to mark |
|
| 929 | */ |
|
| 930 | function markFunction( fn ) { |
|
| 931 | fn[ expando ] = true; |
|
| 932 | return fn; |
|
| 933 | } |
|
| 934 | ||
| 935 | /** |
|
| 936 | * Support testing using an element |
|
| 937 | * @param {Function} fn Passed the created div and expects a boolean result |
|
| 938 | */ |
|
| 939 | function assert( fn ) { |
|
| 940 | var div = document.createElement("div"); |
|
| 941 | ||
| 942 | try { |
|
| 943 | return !!fn( div ); |
|
| 944 | } catch (e) { |
|
| 945 | return false; |
|
| 946 | } finally { |
|
| 947 | // Remove from its parent by default |
|
| 948 | if ( div.parentNode ) { |
|
| 949 | div.parentNode.removeChild( div ); |
|
| 950 | } |
|
| 951 | // release memory in IE |
|
| 952 | div = null; |
|
| 953 | } |
|
| 954 | } |
|
| 955 | ||
| 956 | /** |
|
| 957 | * Adds the same handler for all of the specified attrs |
|
| 958 | * @param {String} attrs Pipe-separated list of attributes |
|
| 959 | * @param {Function} handler The method that will be applied |
|
| 960 | */ |
|
| 961 | function addHandle( attrs, handler ) { |
|
| 962 | var arr = attrs.split("|"), |
|
| 963 | i = arr.length; |
|
| 964 | ||
| 965 | while ( i-- ) { |
|
| 966 | Expr.attrHandle[ arr[i] ] = handler; |
|
| 967 | } |
|
| 968 | } |
|
| 969 | ||
| 970 | /** |
|
| 971 | * Checks document order of two siblings |
|
| 972 | * @param {Element} a |
|
| 973 | * @param {Element} b |
|
| 974 | * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b |
|
| 975 | */ |
|
| 976 | function siblingCheck( a, b ) { |
|
| 977 | var cur = b && a, |
|
| 978 | diff = cur && a.nodeType === 1 && b.nodeType === 1 && |
|
| 979 | ( ~b.sourceIndex || MAX_NEGATIVE ) - |
|
| 980 | ( ~a.sourceIndex || MAX_NEGATIVE ); |
|
| 981 | ||
| 982 | // Use IE sourceIndex if available on both nodes |
|
| 983 | if ( diff ) { |
|
| 984 | return diff; |
|
| 985 | } |
|
| 986 | ||
| 987 | // Check if b follows a |
|
| 988 | if ( cur ) { |
|
| 989 | while ( (cur = cur.nextSibling) ) { |
|
| 990 | if ( cur === b ) { |
|
| 991 | return -1; |
|
| 992 | } |
|
| 993 | } |
|
| 994 | } |
|
| 995 | ||
| 996 | return a ? 1 : -1; |
|
| 997 | } |
|
| 998 | ||
| 999 | /** |
|
| 1000 | * Returns a function to use in pseudos for input types |
|
| 1001 | * @param {String} type |
|
| 1002 | */ |
|
| 1003 | function createInputPseudo( type ) { |
|
| 1004 | return function( elem ) { |
|
| 1005 | var name = elem.nodeName.toLowerCase(); |
|
| 1006 | return name === "input" && elem.type === type; |
|
| 1007 | }; |
|
| 1008 | } |
|
| 1009 | ||
| 1010 | /** |
|
| 1011 | * Returns a function to use in pseudos for buttons |
|
| 1012 | * @param {String} type |
|
| 1013 | */ |
|
| 1014 | function createButtonPseudo( type ) { |
|
| 1015 | return function( elem ) { |
|
| 1016 | var name = elem.nodeName.toLowerCase(); |
|
| 1017 | return (name === "input" || name === "button") && elem.type === type; |
|
| 1018 | }; |
|
| 1019 | } |
|
| 1020 | ||
| 1021 | /** |
|
| 1022 | * Returns a function to use in pseudos for positionals |
|
| 1023 | * @param {Function} fn |
|
| 1024 | */ |
|
| 1025 | function createPositionalPseudo( fn ) { |
|
| 1026 | return markFunction(function( argument ) { |
|
| 1027 | argument = +argument; |
|
| 1028 | return markFunction(function( seed, matches ) { |
|
| 1029 | var j, |
|
| 1030 | matchIndexes = fn( [], seed.length, argument ), |
|
| 1031 | i = matchIndexes.length; |
|
| 1032 | ||
| 1033 | // Match elements found at the specified indexes |
|
| 1034 | while ( i-- ) { |
|
| 1035 | if ( seed[ (j = matchIndexes[i]) ] ) { |
|
| 1036 | seed[j] = !(matches[j] = seed[j]); |
|
| 1037 | } |
|
| 1038 | } |
|
| 1039 | }); |
|
| 1040 | }); |
|
| 1041 | } |
|
| 1042 | ||
| 1043 | /** |
|
| 1044 | * Checks a node for validity as a Sizzle context |
|
| 1045 | * @param {Element|Object=} context |
|
| 1046 | * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value |
|
| 1047 | */ |
|
| 1048 | function testContext( context ) { |
|
| 1049 | return context && typeof context.getElementsByTagName !== "undefined" && context; |
|
| 1050 | } |
|
| 1051 | ||
| 1052 | // Expose support vars for convenience |
|
| 1053 | support = Sizzle.support = {}; |
|
| 1054 | ||
| 1055 | /** |
|
| 1056 | * Detects XML nodes |
|
| 1057 | * @param {Element|Object} elem An element or a document |
|
| 1058 | * @returns {Boolean} True iff elem is a non-HTML XML node |
|
| 1059 | */ |
|
| 1060 | isXML = Sizzle.isXML = function( elem ) { |
|
| 1061 | // documentElement is verified for cases where it doesn't yet exist |
|
| 1062 | // (such as loading iframes in IE - #4833) |
|
| 1063 | var documentElement = elem && (elem.ownerDocument || elem).documentElement; |
|
| 1064 | return documentElement ? documentElement.nodeName !== "HTML" : false; |
|
| 1065 | }; |
|
| 1066 | ||
| 1067 | /** |
|
| 1068 | * Sets document-related variables once based on the current document |
|
| 1069 | * @param {Element|Object} [doc] An element or document object to use to set the document |
|
| 1070 | * @returns {Object} Returns the current document |
|
| 1071 | */ |
|
| 1072 | setDocument = Sizzle.setDocument = function( node ) { |
|
| 1073 | var hasCompare, parent, |
|
| 1074 | doc = node ? node.ownerDocument || node : preferredDoc; |
|
| 1075 | ||
| 1076 | // Return early if doc is invalid or already selected |
|
| 1077 | if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { |
|
| 1078 | return document; |
|
| 1079 | } |
|
| 1080 | ||
| 1081 | // Update global variables |
|
| 1082 | document = doc; |
|
| 1083 | docElem = document.documentElement; |
|
| 1084 | documentIsHTML = !isXML( document ); |
|
| 1085 | ||
| 1086 | // Support: IE 9-11, Edge |
|
| 1087 | // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) |
|
| 1088 | if ( (parent = document.defaultView) && parent.top !== parent ) { |
|
| 1089 | // Support: IE 11 |
|
| 1090 | if ( parent.addEventListener ) { |
|
| 1091 | parent.addEventListener( "unload", unloadHandler, false ); |
|
| 1092 | ||
| 1093 | // Support: IE 9 - 10 only |
|
| 1094 | } else if ( parent.attachEvent ) { |
|
| 1095 | parent.attachEvent( "onunload", unloadHandler ); |
|
| 1096 | } |
|
| 1097 | } |
|
| 1098 | ||
| 1099 | /* Attributes |
|
| 1100 | ---------------------------------------------------------------------- */ |
|
| 1101 | ||
| 1102 | // Support: IE<8 |
|
| 1103 | // Verify that getAttribute really returns attributes and not properties |
|
| 1104 | // (excepting IE8 booleans) |
|
| 1105 | support.attributes = assert(function( div ) { |
|
| 1106 | div.className = "i"; |
|
| 1107 | return !div.getAttribute("className"); |
|
| 1108 | }); |
|
| 1109 | ||
| 1110 | /* getElement(s)By* |
|
| 1111 | ---------------------------------------------------------------------- */ |
|
| 1112 | ||
| 1113 | // Check if getElementsByTagName("*") returns only elements |
|
| 1114 | support.getElementsByTagName = assert(function( div ) { |
|
| 1115 | div.appendChild( document.createComment("") ); |
|
| 1116 | return !div.getElementsByTagName("*").length; |
|
| 1117 | }); |
|
| 1118 | ||
| 1119 | // Support: IE<9 |
|
| 1120 | support.getElementsByClassName = rnative.test( document.getElementsByClassName ); |
|
| 1121 | ||
| 1122 | // Support: IE<10 |
|
| 1123 | // Check if getElementById returns elements by name |
|
| 1124 | // The broken getElementById methods don't pick up programatically-set names, |
|
| 1125 | // so use a roundabout getElementsByName test |
|
| 1126 | support.getById = assert(function( div ) { |
|
| 1127 | docElem.appendChild( div ).id = expando; |
|
| 1128 | return !document.getElementsByName || !document.getElementsByName( expando ).length; |
|
| 1129 | }); |
|
| 1130 | ||
| 1131 | // ID find and filter |
|
| 1132 | if ( support.getById ) { |
|
| 1133 | Expr.find["ID"] = function( id, context ) { |
|
| 1134 | if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { |
|
| 1135 | var m = context.getElementById( id ); |
|
| 1136 | return m ? [ m ] : []; |
|
| 1137 | } |
|
| 1138 | }; |
|
| 1139 | Expr.filter["ID"] = function( id ) { |
|
| 1140 | var attrId = id.replace( runescape, funescape ); |
|
| 1141 | return function( elem ) { |
|
| 1142 | return elem.getAttribute("id") === attrId; |
|
| 1143 | }; |
|
| 1144 | }; |
|
| 1145 | } else { |
|
| 1146 | // Support: IE6/7 |
|
| 1147 | // getElementById is not reliable as a find shortcut |
|
| 1148 | delete Expr.find["ID"]; |
|
| 1149 | ||
| 1150 | Expr.filter["ID"] = function( id ) { |
|
| 1151 | var attrId = id.replace( runescape, funescape ); |
|
| 1152 | return function( elem ) { |
|
| 1153 | var node = typeof elem.getAttributeNode !== "undefined" && |
|
| 1154 | elem.getAttributeNode("id"); |
|
| 1155 | return node && node.value === attrId; |
|
| 1156 | }; |
|
| 1157 | }; |
|
| 1158 | } |
|
| 1159 | ||
| 1160 | // Tag |
|
| 1161 | Expr.find["TAG"] = support.getElementsByTagName ? |
|
| 1162 | function( tag, context ) { |
|
| 1163 | if ( typeof context.getElementsByTagName !== "undefined" ) { |
|
| 1164 | return context.getElementsByTagName( tag ); |
|
| 1165 | ||
| 1166 | // DocumentFragment nodes don't have gEBTN |
|
| 1167 | } else if ( support.qsa ) { |
|
| 1168 | return context.querySelectorAll( tag ); |
|
| 1169 | } |
|
| 1170 | } : |
|
| 1171 | ||
| 1172 | function( tag, context ) { |
|
| 1173 | var elem, |
|
| 1174 | tmp = [], |
|
| 1175 | i = 0, |
|
| 1176 | // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too |
|
| 1177 | results = context.getElementsByTagName( tag ); |
|
| 1178 | ||
| 1179 | // Filter out possible comments |
|
| 1180 | if ( tag === "*" ) { |
|
| 1181 | while ( (elem = results[i++]) ) { |
|
| 1182 | if ( elem.nodeType === 1 ) { |
|
| 1183 | tmp.push( elem ); |
|
| 1184 | } |
|
| 1185 | } |
|
| 1186 | ||
| 1187 | return tmp; |
|
| 1188 | } |
|
| 1189 | return results; |
|
| 1190 | }; |
|
| 1191 | ||
| 1192 | // Class |
|
| 1193 | Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { |
|
| 1194 | if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { |
|
| 1195 | return context.getElementsByClassName( className ); |
|
| 1196 | } |
|
| 1197 | }; |
|
| 1198 | ||
| 1199 | /* QSA/matchesSelector |
|
| 1200 | ---------------------------------------------------------------------- */ |
|
| 1201 | ||
| 1202 | // QSA and matchesSelector support |
|
| 1203 | ||
| 1204 | // matchesSelector(:active) reports false when true (IE9/Opera 11.5) |
|
| 1205 | rbuggyMatches = []; |
|
| 1206 | ||
| 1207 | // qSa(:focus) reports false when true (Chrome 21) |
|
| 1208 | // We allow this because of a bug in IE8/9 that throws an error |
|
| 1209 | // whenever `document.activeElement` is accessed on an iframe |
|
| 1210 | // So, we allow :focus to pass through QSA all the time to avoid the IE error |
|
| 1211 | // See http://bugs.jquery.com/ticket/13378 |
|
| 1212 | rbuggyQSA = []; |
|
| 1213 | ||
| 1214 | if ( (support.qsa = rnative.test( document.querySelectorAll )) ) { |
|
| 1215 | // Build QSA regex |
|
| 1216 | // Regex strategy adopted from Diego Perini |
|
| 1217 | assert(function( div ) { |
|
| 1218 | // Select is set to empty string on purpose |
|
| 1219 | // This is to test IE's treatment of not explicitly |
|
| 1220 | // setting a boolean content attribute, |
|
| 1221 | // since its presence should be enough |
|
| 1222 | // http://bugs.jquery.com/ticket/12359 |
|
| 1223 | docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" + |
|
| 1224 | "<select id='" + expando + "-\r\\' msallowcapture=''>" + |
|
| 1225 | "<option selected=''></option></select>"; |
|
| 1226 | ||
| 1227 | // Support: IE8, Opera 11-12.16 |
|
| 1228 | // Nothing should be selected when empty strings follow ^= or $= or *= |
|
| 1229 | // The test attribute must be unknown in Opera but "safe" for WinRT |
|
| 1230 | // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section |
|
| 1231 | if ( div.querySelectorAll("[msallowcapture^='']").length ) { |
|
| 1232 | rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); |
|
| 1233 | } |
|
| 1234 | ||
| 1235 | // Support: IE8 |
|
| 1236 | // Boolean attributes and "value" are not treated correctly |
|
| 1237 | if ( !div.querySelectorAll("[selected]").length ) { |
|
| 1238 | rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); |
|
| 1239 | } |
|
| 1240 | ||
| 1241 | // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ |
|
| 1242 | if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) { |
|
| 1243 | rbuggyQSA.push("~="); |
|
| 1244 | } |
|
| 1245 | ||
| 1246 | // Webkit/Opera - :checked should return selected option elements |
|
| 1247 | // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked |
|
| 1248 | // IE8 throws error here and will not see later tests |
|
| 1249 | if ( !div.querySelectorAll(":checked").length ) { |
|
| 1250 | rbuggyQSA.push(":checked"); |
|
| 1251 | } |
|
| 1252 | ||
| 1253 | // Support: Safari 8+, iOS 8+ |
|
| 1254 | // https://bugs.webkit.org/show_bug.cgi?id=136851 |
|
| 1255 | // In-page `selector#id sibing-combinator selector` fails |
|
| 1256 | if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) { |
|
| 1257 | rbuggyQSA.push(".#.+[+~]"); |
|
| 1258 | } |
|
| 1259 | }); |
|
| 1260 | ||
| 1261 | assert(function( div ) { |
|
| 1262 | // Support: Windows 8 Native Apps |
|
| 1263 | // The type and name attributes are restricted during .innerHTML assignment |
|
| 1264 | var input = document.createElement("input"); |
|
| 1265 | input.setAttribute( "type", "hidden" ); |
|
| 1266 | div.appendChild( input ).setAttribute( "name", "D" ); |
|
| 1267 | ||
| 1268 | // Support: IE8 |
|
| 1269 | // Enforce case-sensitivity of name attribute |
|
| 1270 | if ( div.querySelectorAll("[name=d]").length ) { |
|
| 1271 | rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); |
|
| 1272 | } |
|
| 1273 | ||
| 1274 | // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) |
|
| 1275 | // IE8 throws error here and will not see later tests |
|
| 1276 | if ( !div.querySelectorAll(":enabled").length ) { |
|
| 1277 | rbuggyQSA.push( ":enabled", ":disabled" ); |
|
| 1278 | } |
|
| 1279 | ||
| 1280 | // Opera 10-11 does not throw on post-comma invalid pseudos |
|
| 1281 | div.querySelectorAll("*,:x"); |
|
| 1282 | rbuggyQSA.push(",.*:"); |
|
| 1283 | }); |
|
| 1284 | } |
|
| 1285 | ||
| 1286 | if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || |
|
| 1287 | docElem.webkitMatchesSelector || |
|
| 1288 | docElem.mozMatchesSelector || |
|
| 1289 | docElem.oMatchesSelector || |
|
| 1290 | docElem.msMatchesSelector) )) ) { |
|
| 1291 | ||
| 1292 | assert(function( div ) { |
|
| 1293 | // Check to see if it's possible to do matchesSelector |
|
| 1294 | // on a disconnected node (IE 9) |
|
| 1295 | support.disconnectedMatch = matches.call( div, "div" ); |
|
| 1296 | ||
| 1297 | // This should fail with an exception |
|
| 1298 | // Gecko does not error, returns false instead |
|
| 1299 | matches.call( div, "[s!='']:x" ); |
|
| 1300 | rbuggyMatches.push( "!=", pseudos ); |
|
| 1301 | }); |
|
| 1302 | } |
|
| 1303 | ||
| 1304 | rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); |
|
| 1305 | rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); |
|
| 1306 | ||
| 1307 | /* Contains |
|
| 1308 | ---------------------------------------------------------------------- */ |
|
| 1309 | hasCompare = rnative.test( docElem.compareDocumentPosition ); |
|
| 1310 | ||
| 1311 | // Element contains another |
|
| 1312 | // Purposefully self-exclusive |
|
| 1313 | // As in, an element does not contain itself |
|
| 1314 | contains = hasCompare || rnative.test( docElem.contains ) ? |
|
| 1315 | function( a, b ) { |
|
| 1316 | var adown = a.nodeType === 9 ? a.documentElement : a, |
|
| 1317 | bup = b && b.parentNode; |
|
| 1318 | return a === bup || !!( bup && bup.nodeType === 1 && ( |
|
| 1319 | adown.contains ? |
|
| 1320 | adown.contains( bup ) : |
|
| 1321 | a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 |
|
| 1322 | )); |
|
| 1323 | } : |
|
| 1324 | function( a, b ) { |
|
| 1325 | if ( b ) { |
|
| 1326 | while ( (b = b.parentNode) ) { |
|
| 1327 | if ( b === a ) { |
|
| 1328 | return true; |
|
| 1329 | } |
|
| 1330 | } |
|
| 1331 | } |
|
| 1332 | return false; |
|
| 1333 | }; |
|
| 1334 | ||
| 1335 | /* Sorting |
|
| 1336 | ---------------------------------------------------------------------- */ |
|
| 1337 | ||
| 1338 | // Document order sorting |
|
| 1339 | sortOrder = hasCompare ? |
|
| 1340 | function( a, b ) { |
|
| 1341 | ||
| 1342 | // Flag for duplicate removal |
|
| 1343 | if ( a === b ) { |
|
| 1344 | hasDuplicate = true; |
|
| 1345 | return 0; |
|
| 1346 | } |
|
| 1347 | ||
| 1348 | // Sort on method existence if only one input has compareDocumentPosition |
|
| 1349 | var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; |
|
| 1350 | if ( compare ) { |
|
| 1351 | return compare; |
|
| 1352 | } |
|
| 1353 | ||
| 1354 | // Calculate position if both inputs belong to the same document |
|
| 1355 | compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? |
|
| 1356 | a.compareDocumentPosition( b ) : |
|
| 1357 | ||
| 1358 | // Otherwise we know they are disconnected |
|
| 1359 | 1; |
|
| 1360 | ||
| 1361 | // Disconnected nodes |
|
| 1362 | if ( compare & 1 || |
|
| 1363 | (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { |
|
| 1364 | ||
| 1365 | // Choose the first element that is related to our preferred document |
|
| 1366 | if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { |
|
| 1367 | return -1; |
|
| 1368 | } |
|
| 1369 | if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { |
|
| 1370 | return 1; |
|
| 1371 | } |
|
| 1372 | ||
| 1373 | // Maintain original order |
|
| 1374 | return sortInput ? |
|
| 1375 | ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : |
|
| 1376 | 0; |
|
| 1377 | } |
|
| 1378 | ||
| 1379 | return compare & 4 ? -1 : 1; |
|
| 1380 | } : |
|
| 1381 | function( a, b ) { |
|
| 1382 | // Exit early if the nodes are identical |
|
| 1383 | if ( a === b ) { |
|
| 1384 | hasDuplicate = true; |
|
| 1385 | return 0; |
|
| 1386 | } |
|
| 1387 | ||
| 1388 | var cur, |
|
| 1389 | i = 0, |
|
| 1390 | aup = a.parentNode, |
|
| 1391 | bup = b.parentNode, |
|
| 1392 | ap = [ a ], |
|
| 1393 | bp = [ b ]; |
|
| 1394 | ||
| 1395 | // Parentless nodes are either documents or disconnected |
|
| 1396 | if ( !aup || !bup ) { |
|
| 1397 | return a === document ? -1 : |
|
| 1398 | b === document ? 1 : |
|
| 1399 | aup ? -1 : |
|
| 1400 | bup ? 1 : |
|
| 1401 | sortInput ? |
|
| 1402 | ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : |
|
| 1403 | 0; |
|
| 1404 | ||
| 1405 | // If the nodes are siblings, we can do a quick check |
|
| 1406 | } else if ( aup === bup ) { |
|
| 1407 | return siblingCheck( a, b ); |
|
| 1408 | } |
|
| 1409 | ||
| 1410 | // Otherwise we need full lists of their ancestors for comparison |
|
| 1411 | cur = a; |
|
| 1412 | while ( (cur = cur.parentNode) ) { |
|
| 1413 | ap.unshift( cur ); |
|
| 1414 | } |
|
| 1415 | cur = b; |
|
| 1416 | while ( (cur = cur.parentNode) ) { |
|
| 1417 | bp.unshift( cur ); |
|
| 1418 | } |
|
| 1419 | ||
| 1420 | // Walk down the tree looking for a discrepancy |
|
| 1421 | while ( ap[i] === bp[i] ) { |
|
| 1422 | i++; |
|
| 1423 | } |
|
| 1424 | ||
| 1425 | return i ? |
|
| 1426 | // Do a sibling check if the nodes have a common ancestor |
|
| 1427 | siblingCheck( ap[i], bp[i] ) : |
|
| 1428 | ||
| 1429 | // Otherwise nodes in our document sort first |
|
| 1430 | ap[i] === preferredDoc ? -1 : |
|
| 1431 | bp[i] === preferredDoc ? 1 : |
|
| 1432 | 0; |
|
| 1433 | }; |
|
| 1434 | ||
| 1435 | return document; |
|
| 1436 | }; |
|
| 1437 | ||
| 1438 | Sizzle.matches = function( expr, elements ) { |
|
| 1439 | return Sizzle( expr, null, null, elements ); |
|
| 1440 | }; |
|
| 1441 | ||
| 1442 | Sizzle.matchesSelector = function( elem, expr ) { |
|
| 1443 | // Set document vars if needed |
|
| 1444 | if ( ( elem.ownerDocument || elem ) !== document ) { |
|
| 1445 | setDocument( elem ); |
|
| 1446 | } |
|
| 1447 | ||
| 1448 | // Make sure that attribute selectors are quoted |
|
| 1449 | expr = expr.replace( rattributeQuotes, "='$1']" ); |
|
| 1450 | ||
| 1451 | if ( support.matchesSelector && documentIsHTML && |
|
| 1452 | !compilerCache[ expr + " " ] && |
|
| 1453 | ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && |
|
| 1454 | ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { |
|
| 1455 | ||
| 1456 | try { |
|
| 1457 | var ret = matches.call( elem, expr ); |
|
| 1458 | ||
| 1459 | // IE 9's matchesSelector returns false on disconnected nodes |
|
| 1460 | if ( ret || support.disconnectedMatch || |
|
| 1461 | // As well, disconnected nodes are said to be in a document |
|
| 1462 | // fragment in IE 9 |
|
| 1463 | elem.document && elem.document.nodeType !== 11 ) { |
|
| 1464 | return ret; |
|
| 1465 | } |
|
| 1466 | } catch (e) {} |
|
| 1467 | } |
|
| 1468 | ||
| 1469 | return Sizzle( expr, document, null, [ elem ] ).length > 0; |
|
| 1470 | }; |
|
| 1471 | ||
| 1472 | Sizzle.contains = function( context, elem ) { |
|
| 1473 | // Set document vars if needed |
|
| 1474 | if ( ( context.ownerDocument || context ) !== document ) { |
|
| 1475 | setDocument( context ); |
|
| 1476 | } |
|
| 1477 | return contains( context, elem ); |
|
| 1478 | }; |
|
| 1479 | ||
| 1480 | Sizzle.attr = function( elem, name ) { |
|
| 1481 | // Set document vars if needed |
|
| 1482 | if ( ( elem.ownerDocument || elem ) !== document ) { |
|
| 1483 | setDocument( elem ); |
|
| 1484 | } |
|
| 1485 | ||
| 1486 | var fn = Expr.attrHandle[ name.toLowerCase() ], |
|
| 1487 | // Don't get fooled by Object.prototype properties (jQuery #13807) |
|
| 1488 | val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? |
|
| 1489 | fn( elem, name, !documentIsHTML ) : |
|
| 1490 | undefined; |
|
| 1491 | ||
| 1492 | return val !== undefined ? |
|
| 1493 | val : |
|
| 1494 | support.attributes || !documentIsHTML ? |
|
| 1495 | elem.getAttribute( name ) : |
|
| 1496 | (val = elem.getAttributeNode(name)) && val.specified ? |
|
| 1497 | val.value : |
|
| 1498 | null; |
|
| 1499 | }; |
|
| 1500 | ||
| 1501 | Sizzle.error = function( msg ) { |
|
| 1502 | throw new Error( "Syntax error, unrecognized expression: " + msg ); |
|
| 1503 | }; |
|
| 1504 | ||
| 1505 | /** |
|
| 1506 | * Document sorting and removing duplicates |
|
| 1507 | * @param {ArrayLike} results |
|
| 1508 | */ |
|
| 1509 | Sizzle.uniqueSort = function( results ) { |
|
| 1510 | var elem, |
|
| 1511 | duplicates = [], |
|
| 1512 | j = 0, |
|
| 1513 | i = 0; |
|
| 1514 | ||
| 1515 | // Unless we *know* we can detect duplicates, assume their presence |
|
| 1516 | hasDuplicate = !support.detectDuplicates; |
|
| 1517 | sortInput = !support.sortStable && results.slice( 0 ); |
|
| 1518 | results.sort( sortOrder ); |
|
| 1519 | ||
| 1520 | if ( hasDuplicate ) { |
|
| 1521 | while ( (elem = results[i++]) ) { |
|
| 1522 | if ( elem === results[ i ] ) { |
|
| 1523 | j = duplicates.push( i ); |
|
| 1524 | } |
|
| 1525 | } |
|
| 1526 | while ( j-- ) { |
|
| 1527 | results.splice( duplicates[ j ], 1 ); |
|
| 1528 | } |
|
| 1529 | } |
|
| 1530 | ||
| 1531 | // Clear input after sorting to release objects |
|
| 1532 | // See https://github.com/jquery/sizzle/pull/225 |
|
| 1533 | sortInput = null; |
|
| 1534 | ||
| 1535 | return results; |
|
| 1536 | }; |
|
| 1537 | ||
| 1538 | /** |
|
| 1539 | * Utility function for retrieving the text value of an array of DOM nodes |
|
| 1540 | * @param {Array|Element} elem |
|
| 1541 | */ |
|
| 1542 | getText = Sizzle.getText = function( elem ) { |
|
| 1543 | var node, |
|
| 1544 | ret = "", |
|
| 1545 | i = 0, |
|
| 1546 | nodeType = elem.nodeType; |
|
| 1547 | ||
| 1548 | if ( !nodeType ) { |
|
| 1549 | // If no nodeType, this is expected to be an array |
|
| 1550 | while ( (node = elem[i++]) ) { |
|
| 1551 | // Do not traverse comment nodes |
|
| 1552 | ret += getText( node ); |
|
| 1553 | } |
|
| 1554 | } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { |
|
| 1555 | // Use textContent for elements |
|
| 1556 | // innerText usage removed for consistency of new lines (jQuery #11153) |
|
| 1557 | if ( typeof elem.textContent === "string" ) { |
|
| 1558 | return elem.textContent; |
|
| 1559 | } else { |
|
| 1560 | // Traverse its children |
|
| 1561 | for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { |
|
| 1562 | ret += getText( elem ); |
|
| 1563 | } |
|
| 1564 | } |
|
| 1565 | } else if ( nodeType === 3 || nodeType === 4 ) { |
|
| 1566 | return elem.nodeValue; |
|
| 1567 | } |
|
| 1568 | // Do not include comment or processing instruction nodes |
|
| 1569 | ||
| 1570 | return ret; |
|
| 1571 | }; |
|
| 1572 | ||
| 1573 | Expr = Sizzle.selectors = { |
|
| 1574 | ||
| 1575 | // Can be adjusted by the user |
|
| 1576 | cacheLength: 50, |
|
| 1577 | ||
| 1578 | createPseudo: markFunction, |
|
| 1579 | ||
| 1580 | match: matchExpr, |
|
| 1581 | ||
| 1582 | attrHandle: {}, |
|
| 1583 | ||
| 1584 | find: {}, |
|
| 1585 | ||
| 1586 | relative: { |
|
| 1587 | ">": { dir: "parentNode", first: true }, |
|
| 1588 | " ": { dir: "parentNode" }, |
|
| 1589 | "+": { dir: "previousSibling", first: true }, |
|
| 1590 | "~": { dir: "previousSibling" } |
|
| 1591 | }, |
|
| 1592 | ||
| 1593 | preFilter: { |
|
| 1594 | "ATTR": function( match ) { |
|
| 1595 | match[1] = match[1].replace( runescape, funescape ); |
|
| 1596 | ||
| 1597 | // Move the given value to match[3] whether quoted or unquoted |
|
| 1598 | match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape ); |
|
| 1599 | ||
| 1600 | if ( match[2] === "~=" ) { |
|
| 1601 | match[3] = " " + match[3] + " "; |
|
| 1602 | } |
|
| 1603 | ||
| 1604 | return match.slice( 0, 4 ); |
|
| 1605 | }, |
|
| 1606 | ||
| 1607 | "CHILD": function( match ) { |
|
| 1608 | /* matches from matchExpr["CHILD"] |
|
| 1609 | 1 type (only|nth|...) |
|
| 1610 | 2 what (child|of-type) |
|
| 1611 | 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) |
|
| 1612 | 4 xn-component of xn+y argument ([+-]?\d*n|) |
|
| 1613 | 5 sign of xn-component |
|
| 1614 | 6 x of xn-component |
|
| 1615 | 7 sign of y-component |
|
| 1616 | 8 y of y-component |
|
| 1617 | */ |
|
| 1618 | match[1] = match[1].toLowerCase(); |
|
| 1619 | ||
| 1620 | if ( match[1].slice( 0, 3 ) === "nth" ) { |
|
| 1621 | // nth-* requires argument |
|
| 1622 | if ( !match[3] ) { |
|
| 1623 | Sizzle.error( match[0] ); |
|
| 1624 | } |
|
| 1625 | ||
| 1626 | // numeric x and y parameters for Expr.filter.CHILD |
|
| 1627 | // remember that false/true cast respectively to 0/1 |
|
| 1628 | match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); |
|
| 1629 | match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); |
|
| 1630 | ||
| 1631 | // other types prohibit arguments |
|
| 1632 | } else if ( match[3] ) { |
|
| 1633 | Sizzle.error( match[0] ); |
|
| 1634 | } |
|
| 1635 | ||
| 1636 | return match; |
|
| 1637 | }, |
|
| 1638 | ||
| 1639 | "PSEUDO": function( match ) { |
|
| 1640 | var excess, |
|
| 1641 | unquoted = !match[6] && match[2]; |
|
| 1642 | ||
| 1643 | if ( matchExpr["CHILD"].test( match[0] ) ) { |
|
| 1644 | return null; |
|
| 1645 | } |
|
| 1646 | ||
| 1647 | // Accept quoted arguments as-is |
|
| 1648 | if ( match[3] ) { |
|
| 1649 | match[2] = match[4] || match[5] || ""; |
|
| 1650 | ||
| 1651 | // Strip excess characters from unquoted arguments |
|
| 1652 | } else if ( unquoted && rpseudo.test( unquoted ) && |
|
| 1653 | // Get excess from tokenize (recursively) |
|
| 1654 | (excess = tokenize( unquoted, true )) && |
|
| 1655 | // advance to the next closing parenthesis |
|
| 1656 | (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { |
|
| 1657 | ||
| 1658 | // excess is a negative index |
|
| 1659 | match[0] = match[0].slice( 0, excess ); |
|
| 1660 | match[2] = unquoted.slice( 0, excess ); |
|
| 1661 | } |
|
| 1662 | ||
| 1663 | // Return only captures needed by the pseudo filter method (type and argument) |
|
| 1664 | return match.slice( 0, 3 ); |
|
| 1665 | } |
|
| 1666 | }, |
|
| 1667 | ||
| 1668 | filter: { |
|
| 1669 | ||
| 1670 | "TAG": function( nodeNameSelector ) { |
|
| 1671 | var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); |
|
| 1672 | return nodeNameSelector === "*" ? |
|
| 1673 | function() { return true; } : |
|
| 1674 | function( elem ) { |
|
| 1675 | return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; |
|
| 1676 | }; |
|
| 1677 | }, |
|
| 1678 | ||
| 1679 | "CLASS": function( className ) { |
|
| 1680 | var pattern = classCache[ className + " " ]; |
|
| 1681 | ||
| 1682 | return pattern || |
|
| 1683 | (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && |
|
| 1684 | classCache( className, function( elem ) { |
|
| 1685 | return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" ); |
|
| 1686 | }); |
|
| 1687 | }, |
|
| 1688 | ||
| 1689 | "ATTR": function( name, operator, check ) { |
|
| 1690 | return function( elem ) { |
|
| 1691 | var result = Sizzle.attr( elem, name ); |
|
| 1692 | ||
| 1693 | if ( result == null ) { |
|
| 1694 | return operator === "!="; |
|
| 1695 | } |
|
| 1696 | if ( !operator ) { |
|
| 1697 | return true; |
|
| 1698 | } |
|
| 1699 | ||
| 1700 | result += ""; |
|
| 1701 | ||
| 1702 | return operator === "=" ? result === check : |
|
| 1703 | operator === "!=" ? result !== check : |
|
| 1704 | operator === "^=" ? check && result.indexOf( check ) === 0 : |
|
| 1705 | operator === "*=" ? check && result.indexOf( check ) > -1 : |
|
| 1706 | operator === "$=" ? check && result.slice( -check.length ) === check : |
|
| 1707 | operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : |
|
| 1708 | operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : |
|
| 1709 | false; |
|
| 1710 | }; |
|
| 1711 | }, |
|
| 1712 | ||
| 1713 | "CHILD": function( type, what, argument, first, last ) { |
|
| 1714 | var simple = type.slice( 0, 3 ) !== "nth", |
|
| 1715 | forward = type.slice( -4 ) !== "last", |
|
| 1716 | ofType = what === "of-type"; |
|
| 1717 | ||
| 1718 | return first === 1 && last === 0 ? |
|
| 1719 | ||
| 1720 | // Shortcut for :nth-*(n) |
|
| 1721 | function( elem ) { |
|
| 1722 | return !!elem.parentNode; |
|
| 1723 | } : |
|
| 1724 | ||
| 1725 | function( elem, context, xml ) { |
|
| 1726 | var cache, uniqueCache, outerCache, node, nodeIndex, start, |
|
| 1727 | dir = simple !== forward ? "nextSibling" : "previousSibling", |
|
| 1728 | parent = elem.parentNode, |
|
| 1729 | name = ofType && elem.nodeName.toLowerCase(), |
|
| 1730 | useCache = !xml && !ofType, |
|
| 1731 | diff = false; |
|
| 1732 | ||
| 1733 | if ( parent ) { |
|
| 1734 | ||
| 1735 | // :(first|last|only)-(child|of-type) |
|
| 1736 | if ( simple ) { |
|
| 1737 | while ( dir ) { |
|
| 1738 | node = elem; |
|
| 1739 | while ( (node = node[ dir ]) ) { |
|
| 1740 | if ( ofType ? |
|
| 1741 | node.nodeName.toLowerCase() === name : |
|
| 1742 | node.nodeType === 1 ) { |
|
| 1743 | ||
| 1744 | return false; |
|
| 1745 | } |
|
| 1746 | } |
|
| 1747 | // Reverse direction for :only-* (if we haven't yet done so) |
|
| 1748 | start = dir = type === "only" && !start && "nextSibling"; |
|
| 1749 | } |
|
| 1750 | return true; |
|
| 1751 | } |
|
| 1752 | ||
| 1753 | start = [ forward ? parent.firstChild : parent.lastChild ]; |
|
| 1754 | ||
| 1755 | // non-xml :nth-child(...) stores cache data on `parent` |
|
| 1756 | if ( forward && useCache ) { |
|
| 1757 | ||
| 1758 | // Seek `elem` from a previously-cached index |
|
| 1759 | ||
| 1760 | // ...in a gzip-friendly way |
|
| 1761 | node = parent; |
|
| 1762 | outerCache = node[ expando ] || (node[ expando ] = {}); |
|
| 1763 | ||
| 1764 | // Support: IE <9 only |
|
| 1765 | // Defend against cloned attroperties (jQuery gh-1709) |
|
| 1766 | uniqueCache = outerCache[ node.uniqueID ] || |
|
| 1767 | (outerCache[ node.uniqueID ] = {}); |
|
| 1768 | ||
| 1769 | cache = uniqueCache[ type ] || []; |
|
| 1770 | nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; |
|
| 1771 | diff = nodeIndex && cache[ 2 ]; |
|
| 1772 | node = nodeIndex && parent.childNodes[ nodeIndex ]; |
|
| 1773 | ||
| 1774 | while ( (node = ++nodeIndex && node && node[ dir ] || |
|
| 1775 | ||
| 1776 | // Fallback to seeking `elem` from the start |
|
| 1777 | (diff = nodeIndex = 0) || start.pop()) ) { |
|
| 1778 | ||
| 1779 | // When found, cache indexes on `parent` and break |
|
| 1780 | if ( node.nodeType === 1 && ++diff && node === elem ) { |
|
| 1781 | uniqueCache[ type ] = [ dirruns, nodeIndex, diff ]; |
|
| 1782 | break; |
|
| 1783 | } |
|
| 1784 | } |
|
| 1785 | ||
| 1786 | } else { |
|
| 1787 | // Use previously-cached element index if available |
|
| 1788 | if ( useCache ) { |
|
| 1789 | // ...in a gzip-friendly way |
|
| 1790 | node = elem; |
|
| 1791 | outerCache = node[ expando ] || (node[ expando ] = {}); |
|
| 1792 | ||
| 1793 | // Support: IE <9 only |
|
| 1794 | // Defend against cloned attroperties (jQuery gh-1709) |
|
| 1795 | uniqueCache = outerCache[ node.uniqueID ] || |
|
| 1796 | (outerCache[ node.uniqueID ] = {}); |
|
| 1797 | ||
| 1798 | cache = uniqueCache[ type ] || []; |
|
| 1799 | nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; |
|
| 1800 | diff = nodeIndex; |
|
| 1801 | } |
|
| 1802 | ||
| 1803 | // xml :nth-child(...) |
|
| 1804 | // or :nth-last-child(...) or :nth(-last)?-of-type(...) |
|
| 1805 | if ( diff === false ) { |
|
| 1806 | // Use the same loop as above to seek `elem` from the start |
|
| 1807 | while ( (node = ++nodeIndex && node && node[ dir ] || |
|
| 1808 | (diff = nodeIndex = 0) || start.pop()) ) { |
|
| 1809 | ||
| 1810 | if ( ( ofType ? |
|
| 1811 | node.nodeName.toLowerCase() === name : |
|
| 1812 | node.nodeType === 1 ) && |
|
| 1813 | ++diff ) { |
|
| 1814 | ||
| 1815 | // Cache the index of each encountered element |
|
| 1816 | if ( useCache ) { |
|
| 1817 | outerCache = node[ expando ] || (node[ expando ] = {}); |
|
| 1818 | ||
| 1819 | // Support: IE <9 only |
|
| 1820 | // Defend against cloned attroperties (jQuery gh-1709) |
|
| 1821 | uniqueCache = outerCache[ node.uniqueID ] || |
|
| 1822 | (outerCache[ node.uniqueID ] = {}); |
|
| 1823 | ||
| 1824 | uniqueCache[ type ] = [ dirruns, diff ]; |
|
| 1825 | } |
|
| 1826 | ||
| 1827 | if ( node === elem ) { |
|
| 1828 | break; |
|
| 1829 | } |
|
| 1830 | } |
|
| 1831 | } |
|
| 1832 | } |
|
| 1833 | } |
|
| 1834 | ||
| 1835 | // Incorporate the offset, then check against cycle size |
|
| 1836 | diff -= last; |
|
| 1837 | return diff === first || ( diff % first === 0 && diff / first >= 0 ); |
|
| 1838 | } |
|
| 1839 | }; |
|
| 1840 | }, |
|
| 1841 | ||
| 1842 | "PSEUDO": function( pseudo, argument ) { |
|
| 1843 | // pseudo-class names are case-insensitive |
|
| 1844 | // http://www.w3.org/TR/selectors/#pseudo-classes |
|
| 1845 | // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters |
|
| 1846 | // Remember that setFilters inherits from pseudos |
|
| 1847 | var args, |
|
| 1848 | fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || |
|
| 1849 | Sizzle.error( "unsupported pseudo: " + pseudo ); |
|
| 1850 | ||
| 1851 | // The user may use createPseudo to indicate that |
|
| 1852 | // arguments are needed to create the filter function |
|
| 1853 | // just as Sizzle does |
|
| 1854 | if ( fn[ expando ] ) { |
|
| 1855 | return fn( argument ); |
|
| 1856 | } |
|
| 1857 | ||
| 1858 | // But maintain support for old signatures |
|
| 1859 | if ( fn.length > 1 ) { |
|
| 1860 | args = [ pseudo, pseudo, "", argument ]; |
|
| 1861 | return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? |
|
| 1862 | markFunction(function( seed, matches ) { |
|
| 1863 | var idx, |
|
| 1864 | matched = fn( seed, argument ), |
|
| 1865 | i = matched.length; |
|
| 1866 | while ( i-- ) { |
|
| 1867 | idx = indexOf( seed, matched[i] ); |
|
| 1868 | seed[ idx ] = !( matches[ idx ] = matched[i] ); |
|
| 1869 | } |
|
| 1870 | }) : |
|
| 1871 | function( elem ) { |
|
| 1872 | return fn( elem, 0, args ); |
|
| 1873 | }; |
|
| 1874 | } |
|
| 1875 | ||
| 1876 | return fn; |
|
| 1877 | } |
|
| 1878 | }, |
|
| 1879 | ||
| 1880 | pseudos: { |
|
| 1881 | // Potentially complex pseudos |
|
| 1882 | "not": markFunction(function( selector ) { |
|
| 1883 | // Trim the selector passed to compile |
|
| 1884 | // to avoid treating leading and trailing |
|
| 1885 | // spaces as combinators |
|
| 1886 | var input = [], |
|
| 1887 | results = [], |
|
| 1888 | matcher = compile( selector.replace( rtrim, "$1" ) ); |
|
| 1889 | ||
| 1890 | return matcher[ expando ] ? |
|
| 1891 | markFunction(function( seed, matches, context, xml ) { |
|
| 1892 | var elem, |
|
| 1893 | unmatched = matcher( seed, null, xml, [] ), |
|
| 1894 | i = seed.length; |
|
| 1895 | ||
| 1896 | // Match elements unmatched by `matcher` |
|
| 1897 | while ( i-- ) { |
|
| 1898 | if ( (elem = unmatched[i]) ) { |
|
| 1899 | seed[i] = !(matches[i] = elem); |
|
| 1900 | } |
|
| 1901 | } |
|
| 1902 | }) : |
|
| 1903 | function( elem, context, xml ) { |
|
| 1904 | input[0] = elem; |
|
| 1905 | matcher( input, null, xml, results ); |
|
| 1906 | // Don't keep the element (issue #299) |
|
| 1907 | input[0] = null; |
|
| 1908 | return !results.pop(); |
|
| 1909 | }; |
|
| 1910 | }), |
|
| 1911 | ||
| 1912 | "has": markFunction(function( selector ) { |
|
| 1913 | return function( elem ) { |
|
| 1914 | return Sizzle( selector, elem ).length > 0; |
|
| 1915 | }; |
|
| 1916 | }), |
|
| 1917 | ||
| 1918 | "contains": markFunction(function( text ) { |
|
| 1919 | text = text.replace( runescape, funescape ); |
|
| 1920 | return function( elem ) { |
|
| 1921 | return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; |
|
| 1922 | }; |
|
| 1923 | }), |
|
| 1924 | ||
| 1925 | // "Whether an element is represented by a :lang() selector |
|
| 1926 | // is based solely on the element's language value |
|
| 1927 | // being equal to the identifier C, |
|
| 1928 | // or beginning with the identifier C immediately followed by "-". |
|
| 1929 | // The matching of C against the element's language value is performed case-insensitively. |
|
| 1930 | // The identifier C does not have to be a valid language name." |
|
| 1931 | // http://www.w3.org/TR/selectors/#lang-pseudo |
|
| 1932 | "lang": markFunction( function( lang ) { |
|
| 1933 | // lang value must be a valid identifier |
|
| 1934 | if ( !ridentifier.test(lang || "") ) { |
|
| 1935 | Sizzle.error( "unsupported lang: " + lang ); |
|
| 1936 | } |
|
| 1937 | lang = lang.replace( runescape, funescape ).toLowerCase(); |
|
| 1938 | return function( elem ) { |
|
| 1939 | var elemLang; |
|
| 1940 | do { |
|
| 1941 | if ( (elemLang = documentIsHTML ? |
|
| 1942 | elem.lang : |
|
| 1943 | elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { |
|
| 1944 | ||
| 1945 | elemLang = elemLang.toLowerCase(); |
|
| 1946 | return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; |
|
| 1947 | } |
|
| 1948 | } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); |
|
| 1949 | return false; |
|
| 1950 | }; |
|
| 1951 | }), |
|
| 1952 | ||
| 1953 | // Miscellaneous |
|
| 1954 | "target": function( elem ) { |
|
| 1955 | var hash = window.location && window.location.hash; |
|
| 1956 | return hash && hash.slice( 1 ) === elem.id; |
|
| 1957 | }, |
|
| 1958 | ||
| 1959 | "root": function( elem ) { |
|
| 1960 | return elem === docElem; |
|
| 1961 | }, |
|
| 1962 | ||
| 1963 | "focus": function( elem ) { |
|
| 1964 | return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); |
|
| 1965 | }, |
|
| 1966 | ||
| 1967 | // Boolean properties |
|
| 1968 | "enabled": function( elem ) { |
|
| 1969 | return elem.disabled === false; |
|
| 1970 | }, |
|
| 1971 | ||
| 1972 | "disabled": function( elem ) { |
|
| 1973 | return elem.disabled === true; |
|
| 1974 | }, |
|
| 1975 | ||
| 1976 | "checked": function( elem ) { |
|
| 1977 | // In CSS3, :checked should return both checked and selected elements |
|
| 1978 | // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked |
|
| 1979 | var nodeName = elem.nodeName.toLowerCase(); |
|
| 1980 | return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); |
|
| 1981 | }, |
|
| 1982 | ||
| 1983 | "selected": function( elem ) { |
|
| 1984 | // Accessing this property makes selected-by-default |
|
| 1985 | // options in Safari work properly |
|
| 1986 | if ( elem.parentNode ) { |
|
| 1987 | elem.parentNode.selectedIndex; |
|
| 1988 | } |
|
| 1989 | ||
| 1990 | return elem.selected === true; |
|
| 1991 | }, |
|
| 1992 | ||
| 1993 | // Contents |
|
| 1994 | "empty": function( elem ) { |
|
| 1995 | // http://www.w3.org/TR/selectors/#empty-pseudo |
|
| 1996 | // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), |
|
| 1997 | // but not by others (comment: 8; processing instruction: 7; etc.) |
|
| 1998 | // nodeType < 6 works because attributes (2) do not appear as children |
|
| 1999 | for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { |
|
| 2000 | if ( elem.nodeType < 6 ) { |
|
| 2001 | return false; |
|
| 2002 | } |
|
| 2003 | } |
|
| 2004 | return true; |
|
| 2005 | }, |
|
| 2006 | ||
| 2007 | "parent": function( elem ) { |
|
| 2008 | return !Expr.pseudos["empty"]( elem ); |
|
| 2009 | }, |
|
| 2010 | ||
| 2011 | // Element/input types |
|
| 2012 | "header": function( elem ) { |
|
| 2013 | return rheader.test( elem.nodeName ); |
|
| 2014 | }, |
|
| 2015 | ||
| 2016 | "input": function( elem ) { |
|
| 2017 | return rinputs.test( elem.nodeName ); |
|
| 2018 | }, |
|
| 2019 | ||
| 2020 | "button": function( elem ) { |
|
| 2021 | var name = elem.nodeName.toLowerCase(); |
|
| 2022 | return name === "input" && elem.type === "button" || name === "button"; |
|
| 2023 | }, |
|
| 2024 | ||
| 2025 | "text": function( elem ) { |
|
| 2026 | var attr; |
|
| 2027 | return elem.nodeName.toLowerCase() === "input" && |
|
| 2028 | elem.type === "text" && |
|
| 2029 | ||
| 2030 | // Support: IE<8 |
|
| 2031 | // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" |
|
| 2032 | ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); |
|
| 2033 | }, |
|
| 2034 | ||
| 2035 | // Position-in-collection |
|
| 2036 | "first": createPositionalPseudo(function() { |
|
| 2037 | return [ 0 ]; |
|
| 2038 | }), |
|
| 2039 | ||
| 2040 | "last": createPositionalPseudo(function( matchIndexes, length ) { |
|
| 2041 | return [ length - 1 ]; |
|
| 2042 | }), |
|
| 2043 | ||
| 2044 | "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { |
|
| 2045 | return [ argument < 0 ? argument + length : argument ]; |
|
| 2046 | }), |
|
| 2047 | ||
| 2048 | "even": createPositionalPseudo(function( matchIndexes, length ) { |
|
| 2049 | var i = 0; |
|
| 2050 | for ( ; i < length; i += 2 ) { |
|
| 2051 | matchIndexes.push( i ); |
|
| 2052 | } |
|
| 2053 | return matchIndexes; |
|
| 2054 | }), |
|
| 2055 | ||
| 2056 | "odd": createPositionalPseudo(function( matchIndexes, length ) { |
|
| 2057 | var i = 1; |
|
| 2058 | for ( ; i < length; i += 2 ) { |
|
| 2059 | matchIndexes.push( i ); |
|
| 2060 | } |
|
| 2061 | return matchIndexes; |
|
| 2062 | }), |
|
| 2063 | ||
| 2064 | "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { |
|
| 2065 | var i = argument < 0 ? argument + length : argument; |
|
| 2066 | for ( ; --i >= 0; ) { |
|
| 2067 | matchIndexes.push( i ); |
|
| 2068 | } |
|
| 2069 | return matchIndexes; |
|
| 2070 | }), |
|
| 2071 | ||
| 2072 | "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { |
|
| 2073 | var i = argument < 0 ? argument + length : argument; |
|
| 2074 | for ( ; ++i < length; ) { |
|
| 2075 | matchIndexes.push( i ); |
|
| 2076 | } |
|
| 2077 | return matchIndexes; |
|
| 2078 | }) |
|
| 2079 | } |
|
| 2080 | }; |
|
| 2081 | ||
| 2082 | Expr.pseudos["nth"] = Expr.pseudos["eq"]; |
|
| 2083 | ||
| 2084 | // Add button/input type pseudos |
|
| 2085 | for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { |
|
| 2086 | Expr.pseudos[ i ] = createInputPseudo( i ); |
|
| 2087 | } |
|
| 2088 | for ( i in { submit: true, reset: true } ) { |
|
| 2089 | Expr.pseudos[ i ] = createButtonPseudo( i ); |
|
| 2090 | } |
|
| 2091 | ||
| 2092 | // Easy API for creating new setFilters |
|
| 2093 | function setFilters() {} |
|
| 2094 | setFilters.prototype = Expr.filters = Expr.pseudos; |
|
| 2095 | Expr.setFilters = new setFilters(); |
|
| 2096 | ||
| 2097 | tokenize = Sizzle.tokenize = function( selector, parseOnly ) { |
|
| 2098 | var matched, match, tokens, type, |
|
| 2099 | soFar, groups, preFilters, |
|
| 2100 | cached = tokenCache[ selector + " " ]; |
|
| 2101 | ||
| 2102 | if ( cached ) { |
|
| 2103 | return parseOnly ? 0 : cached.slice( 0 ); |
|
| 2104 | } |
|
| 2105 | ||
| 2106 | soFar = selector; |
|
| 2107 | groups = []; |
|
| 2108 | preFilters = Expr.preFilter; |
|
| 2109 | ||
| 2110 | while ( soFar ) { |
|
| 2111 | ||
| 2112 | // Comma and first run |
|
| 2113 | if ( !matched || (match = rcomma.exec( soFar )) ) { |
|
| 2114 | if ( match ) { |
|
| 2115 | // Don't consume trailing commas as valid |
|
| 2116 | soFar = soFar.slice( match[0].length ) || soFar; |
|
| 2117 | } |
|
| 2118 | groups.push( (tokens = []) ); |
|
| 2119 | } |
|
| 2120 | ||
| 2121 | matched = false; |
|
| 2122 | ||
| 2123 | // Combinators |
|
| 2124 | if ( (match = rcombinators.exec( soFar )) ) { |
|
| 2125 | matched = match.shift(); |
|
| 2126 | tokens.push({ |
|
| 2127 | value: matched, |
|
| 2128 | // Cast descendant combinators to space |
|
| 2129 | type: match[0].replace( rtrim, " " ) |
|
| 2130 | }); |
|
| 2131 | soFar = soFar.slice( matched.length ); |
|
| 2132 | } |
|
| 2133 | ||
| 2134 | // Filters |
|
| 2135 | for ( type in Expr.filter ) { |
|
| 2136 | if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || |
|
| 2137 | (match = preFilters[ type ]( match ))) ) { |
|
| 2138 | matched = match.shift(); |
|
| 2139 | tokens.push({ |
|
| 2140 | value: matched, |
|
| 2141 | type: type, |
|
| 2142 | matches: match |
|
| 2143 | }); |
|
| 2144 | soFar = soFar.slice( matched.length ); |
|
| 2145 | } |
|
| 2146 | } |
|
| 2147 | ||
| 2148 | if ( !matched ) { |
|
| 2149 | break; |
|
| 2150 | } |
|
| 2151 | } |
|
| 2152 | ||
| 2153 | // Return the length of the invalid excess |
|
| 2154 | // if we're just parsing |
|
| 2155 | // Otherwise, throw an error or return tokens |
|
| 2156 | return parseOnly ? |
|
| 2157 | soFar.length : |
|
| 2158 | soFar ? |
|
| 2159 | Sizzle.error( selector ) : |
|
| 2160 | // Cache the tokens |
|
| 2161 | tokenCache( selector, groups ).slice( 0 ); |
|
| 2162 | }; |
|
| 2163 | ||
| 2164 | function toSelector( tokens ) { |
|
| 2165 | var i = 0, |
|
| 2166 | len = tokens.length, |
|
| 2167 | selector = ""; |
|
| 2168 | for ( ; i < len; i++ ) { |
|
| 2169 | selector += tokens[i].value; |
|
| 2170 | } |
|
| 2171 | return selector; |
|
| 2172 | } |
|
| 2173 | ||
| 2174 | function addCombinator( matcher, combinator, base ) { |
|
| 2175 | var dir = combinator.dir, |
|
| 2176 | checkNonElements = base && dir === "parentNode", |
|
| 2177 | doneName = done++; |
|
| 2178 | ||
| 2179 | return combinator.first ? |
|
| 2180 | // Check against closest ancestor/preceding element |
|
| 2181 | function( elem, context, xml ) { |
|
| 2182 | while ( (elem = elem[ dir ]) ) { |
|
| 2183 | if ( elem.nodeType === 1 || checkNonElements ) { |
|
| 2184 | return matcher( elem, context, xml ); |
|
| 2185 | } |
|
| 2186 | } |
|
| 2187 | } : |
|
| 2188 | ||
| 2189 | // Check against all ancestor/preceding elements |
|
| 2190 | function( elem, context, xml ) { |
|
| 2191 | var oldCache, uniqueCache, outerCache, |
|
| 2192 | newCache = [ dirruns, doneName ]; |
|
| 2193 | ||
| 2194 | // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching |
|
| 2195 | if ( xml ) { |
|
| 2196 | while ( (elem = elem[ dir ]) ) { |
|
| 2197 | if ( elem.nodeType === 1 || checkNonElements ) { |
|
| 2198 | if ( matcher( elem, context, xml ) ) { |
|
| 2199 | return true; |
|
| 2200 | } |
|
| 2201 | } |
|
| 2202 | } |
|
| 2203 | } else { |
|
| 2204 | while ( (elem = elem[ dir ]) ) { |
|
| 2205 | if ( elem.nodeType === 1 || checkNonElements ) { |
|
| 2206 | outerCache = elem[ expando ] || (elem[ expando ] = {}); |
|
| 2207 | ||
| 2208 | // Support: IE <9 only |
|
| 2209 | // Defend against cloned attroperties (jQuery gh-1709) |
|
| 2210 | uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {}); |
|
| 2211 | ||
| 2212 | if ( (oldCache = uniqueCache[ dir ]) && |
|
| 2213 | oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { |
|
| 2214 | ||
| 2215 | // Assign to newCache so results back-propagate to previous elements |
|
| 2216 | return (newCache[ 2 ] = oldCache[ 2 ]); |
|
| 2217 | } else { |
|
| 2218 | // Reuse newcache so results back-propagate to previous elements |
|
| 2219 | uniqueCache[ dir ] = newCache; |
|
| 2220 | ||
| 2221 | // A match means we're done; a fail means we have to keep checking |
|
| 2222 | if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { |
|
| 2223 | return true; |
|
| 2224 | } |
|
| 2225 | } |
|
| 2226 | } |
|
| 2227 | } |
|
| 2228 | } |
|
| 2229 | }; |
|
| 2230 | } |
|
| 2231 | ||
| 2232 | function elementMatcher( matchers ) { |
|
| 2233 | return matchers.length > 1 ? |
|
| 2234 | function( elem, context, xml ) { |
|
| 2235 | var i = matchers.length; |
|
| 2236 | while ( i-- ) { |
|
| 2237 | if ( !matchers[i]( elem, context, xml ) ) { |
|
| 2238 | return false; |
|
| 2239 | } |
|
| 2240 | } |
|
| 2241 | return true; |
|
| 2242 | } : |
|
| 2243 | matchers[0]; |
|
| 2244 | } |
|
| 2245 | ||
| 2246 | function multipleContexts( selector, contexts, results ) { |
|
| 2247 | var i = 0, |
|
| 2248 | len = contexts.length; |
|
| 2249 | for ( ; i < len; i++ ) { |
|
| 2250 | Sizzle( selector, contexts[i], results ); |
|
| 2251 | } |
|
| 2252 | return results; |
|
| 2253 | } |
|
| 2254 | ||
| 2255 | function condense( unmatched, map, filter, context, xml ) { |
|
| 2256 | var elem, |
|
| 2257 | newUnmatched = [], |
|
| 2258 | i = 0, |
|
| 2259 | len = unmatched.length, |
|
| 2260 | mapped = map != null; |
|
| 2261 | ||
| 2262 | for ( ; i < len; i++ ) { |
|
| 2263 | if ( (elem = unmatched[i]) ) { |
|
| 2264 | if ( !filter || filter( elem, context, xml ) ) { |
|
| 2265 | newUnmatched.push( elem ); |
|
| 2266 | if ( mapped ) { |
|
| 2267 | map.push( i ); |
|
| 2268 | } |
|
| 2269 | } |
|
| 2270 | } |
|
| 2271 | } |
|
| 2272 | ||
| 2273 | return newUnmatched; |
|
| 2274 | } |
|
| 2275 | ||
| 2276 | function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { |
|
| 2277 | if ( postFilter && !postFilter[ expando ] ) { |
|
| 2278 | postFilter = setMatcher( postFilter ); |
|
| 2279 | } |
|
| 2280 | if ( postFinder && !postFinder[ expando ] ) { |
|
| 2281 | postFinder = setMatcher( postFinder, postSelector ); |
|
| 2282 | } |
|
| 2283 | return markFunction(function( seed, results, context, xml ) { |
|
| 2284 | var temp, i, elem, |
|
| 2285 | preMap = [], |
|
| 2286 | postMap = [], |
|
| 2287 | preexisting = results.length, |
|
| 2288 | ||
| 2289 | // Get initial elements from seed or context |
|
| 2290 | elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), |
|
| 2291 | ||
| 2292 | // Prefilter to get matcher input, preserving a map for seed-results synchronization |
|
| 2293 | matcherIn = preFilter && ( seed || !selector ) ? |
|
| 2294 | condense( elems, preMap, preFilter, context, xml ) : |
|
| 2295 | elems, |
|
| 2296 | ||
| 2297 | matcherOut = matcher ? |
|
| 2298 | // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, |
|
| 2299 | postFinder || ( seed ? preFilter : preexisting || postFilter ) ? |
|
| 2300 | ||
| 2301 | // ...intermediate processing is necessary |
|
| 2302 | [] : |
|
| 2303 | ||
| 2304 | // ...otherwise use results directly |
|
| 2305 | results : |
|
| 2306 | matcherIn; |
|
| 2307 | ||
| 2308 | // Find primary matches |
|
| 2309 | if ( matcher ) { |
|
| 2310 | matcher( matcherIn, matcherOut, context, xml ); |
|
| 2311 | } |
|
| 2312 | ||
| 2313 | // Apply postFilter |
|
| 2314 | if ( postFilter ) { |
|
| 2315 | temp = condense( matcherOut, postMap ); |
|
| 2316 | postFilter( temp, [], context, xml ); |
|
| 2317 | ||
| 2318 | // Un-match failing elements by moving them back to matcherIn |
|
| 2319 | i = temp.length; |
|
| 2320 | while ( i-- ) { |
|
| 2321 | if ( (elem = temp[i]) ) { |
|
| 2322 | matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); |
|
| 2323 | } |
|
| 2324 | } |
|
| 2325 | } |
|
| 2326 | ||
| 2327 | if ( seed ) { |
|
| 2328 | if ( postFinder || preFilter ) { |
|
| 2329 | if ( postFinder ) { |
|
| 2330 | // Get the final matcherOut by condensing this intermediate into postFinder contexts |
|
| 2331 | temp = []; |
|
| 2332 | i = matcherOut.length; |
|
| 2333 | while ( i-- ) { |
|
| 2334 | if ( (elem = matcherOut[i]) ) { |
|
| 2335 | // Restore matcherIn since elem is not yet a final match |
|
| 2336 | temp.push( (matcherIn[i] = elem) ); |
|
| 2337 | } |
|
| 2338 | } |
|
| 2339 | postFinder( null, (matcherOut = []), temp, xml ); |
|
| 2340 | } |
|
| 2341 | ||
| 2342 | // Move matched elements from seed to results to keep them synchronized |
|
| 2343 | i = matcherOut.length; |
|
| 2344 | while ( i-- ) { |
|
| 2345 | if ( (elem = matcherOut[i]) && |
|
| 2346 | (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) { |
|
| 2347 | ||
| 2348 | seed[temp] = !(results[temp] = elem); |
|
| 2349 | } |
|
| 2350 | } |
|
| 2351 | } |
|
| 2352 | ||
| 2353 | // Add elements to results, through postFinder if defined |
|
| 2354 | } else { |
|
| 2355 | matcherOut = condense( |
|
| 2356 | matcherOut === results ? |
|
| 2357 | matcherOut.splice( preexisting, matcherOut.length ) : |
|
| 2358 | matcherOut |
|
| 2359 | ); |
|
| 2360 | if ( postFinder ) { |
|
| 2361 | postFinder( null, results, matcherOut, xml ); |
|
| 2362 | } else { |
|
| 2363 | push.apply( results, matcherOut ); |
|
| 2364 | } |
|
| 2365 | } |
|
| 2366 | }); |
|
| 2367 | } |
|
| 2368 | ||
| 2369 | function matcherFromTokens( tokens ) { |
|
| 2370 | var checkContext, matcher, j, |
|
| 2371 | len = tokens.length, |
|
| 2372 | leadingRelative = Expr.relative[ tokens[0].type ], |
|
| 2373 | implicitRelative = leadingRelative || Expr.relative[" "], |
|
| 2374 | i = leadingRelative ? 1 : 0, |
|
| 2375 | ||
| 2376 | // The foundational matcher ensures that elements are reachable from top-level context(s) |
|
| 2377 | matchContext = addCombinator( function( elem ) { |
|
| 2378 | return elem === checkContext; |
|
| 2379 | }, implicitRelative, true ), |
|
| 2380 | matchAnyContext = addCombinator( function( elem ) { |
|
| 2381 | return indexOf( checkContext, elem ) > -1; |
|
| 2382 | }, implicitRelative, true ), |
|
| 2383 | matchers = [ function( elem, context, xml ) { |
|
| 2384 | var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( |
|
| 2385 | (checkContext = context).nodeType ? |
|
| 2386 | matchContext( elem, context, xml ) : |
|
| 2387 | matchAnyContext( elem, context, xml ) ); |
|
| 2388 | // Avoid hanging onto element (issue #299) |
|
| 2389 | checkContext = null; |
|
| 2390 | return ret; |
|
| 2391 | } ]; |
|
| 2392 | ||
| 2393 | for ( ; i < len; i++ ) { |
|
| 2394 | if ( (matcher = Expr.relative[ tokens[i].type ]) ) { |
|
| 2395 | matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; |
|
| 2396 | } else { |
|
| 2397 | matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); |
|
| 2398 | ||
| 2399 | // Return special upon seeing a positional matcher |
|
| 2400 | if ( matcher[ expando ] ) { |
|
| 2401 | // Find the next relative operator (if any) for proper handling |
|
| 2402 | j = ++i; |
|
| 2403 | for ( ; j < len; j++ ) { |
|
| 2404 | if ( Expr.relative[ tokens[j].type ] ) { |
|
| 2405 | break; |
|
| 2406 | } |
|
| 2407 | } |
|
| 2408 | return setMatcher( |
|
| 2409 | i > 1 && elementMatcher( matchers ), |
|
| 2410 | i > 1 && toSelector( |
|
| 2411 | // If the preceding token was a descendant combinator, insert an implicit any-element `*` |
|
| 2412 | tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) |
|
| 2413 | ).replace( rtrim, "$1" ), |
|
| 2414 | matcher, |
|
| 2415 | i < j && matcherFromTokens( tokens.slice( i, j ) ), |
|
| 2416 | j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), |
|
| 2417 | j < len && toSelector( tokens ) |
|
| 2418 | ); |
|
| 2419 | } |
|
| 2420 | matchers.push( matcher ); |
|
| 2421 | } |
|
| 2422 | } |
|
| 2423 | ||
| 2424 | return elementMatcher( matchers ); |
|
| 2425 | } |
|
| 2426 | ||
| 2427 | function matcherFromGroupMatchers( elementMatchers, setMatchers ) { |
|
| 2428 | var bySet = setMatchers.length > 0, |
|
| 2429 | byElement = elementMatchers.length > 0, |
|
| 2430 | superMatcher = function( seed, context, xml, results, outermost ) { |
|
| 2431 | var elem, j, matcher, |
|
| 2432 | matchedCount = 0, |
|
| 2433 | i = "0", |
|
| 2434 | unmatched = seed && [], |
|
| 2435 | setMatched = [], |
|
| 2436 | contextBackup = outermostContext, |
|
| 2437 | // We must always have either seed elements or outermost context |
|
| 2438 | elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), |
|
| 2439 | // Use integer dirruns iff this is the outermost matcher |
|
| 2440 | dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), |
|
| 2441 | len = elems.length; |
|
| 2442 | ||
| 2443 | if ( outermost ) { |
|
| 2444 | outermostContext = context === document || context || outermost; |
|
| 2445 | } |
|
| 2446 | ||
| 2447 | // Add elements passing elementMatchers directly to results |
|
| 2448 | // Support: IE<9, Safari |
|
| 2449 | // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id |
|
| 2450 | for ( ; i !== len && (elem = elems[i]) != null; i++ ) { |
|
| 2451 | if ( byElement && elem ) { |
|
| 2452 | j = 0; |
|
| 2453 | if ( !context && elem.ownerDocument !== document ) { |
|
| 2454 | setDocument( elem ); |
|
| 2455 | xml = !documentIsHTML; |
|
| 2456 | } |
|
| 2457 | while ( (matcher = elementMatchers[j++]) ) { |
|
| 2458 | if ( matcher( elem, context || document, xml) ) { |
|
| 2459 | results.push( elem ); |
|
| 2460 | break; |
|
| 2461 | } |
|
| 2462 | } |
|
| 2463 | if ( outermost ) { |
|
| 2464 | dirruns = dirrunsUnique; |
|
| 2465 | } |
|
| 2466 | } |
|
| 2467 | ||
| 2468 | // Track unmatched elements for set filters |
|
| 2469 | if ( bySet ) { |
|
| 2470 | // They will have gone through all possible matchers |
|
| 2471 | if ( (elem = !matcher && elem) ) { |
|
| 2472 | matchedCount--; |
|
| 2473 | } |
|
| 2474 | ||
| 2475 | // Lengthen the array for every element, matched or not |
|
| 2476 | if ( seed ) { |
|
| 2477 | unmatched.push( elem ); |
|
| 2478 | } |
|
| 2479 | } |
|
| 2480 | } |
|
| 2481 | ||
| 2482 | // `i` is now the count of elements visited above, and adding it to `matchedCount` |
|
| 2483 | // makes the latter nonnegative. |
|
| 2484 | matchedCount += i; |
|
| 2485 | ||
| 2486 | // Apply set filters to unmatched elements |
|
| 2487 | // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` |
|
| 2488 | // equals `i`), unless we didn't visit _any_ elements in the above loop because we have |
|
| 2489 | // no element matchers and no seed. |
|
| 2490 | // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that |
|
| 2491 | // case, which will result in a "00" `matchedCount` that differs from `i` but is also |
|
| 2492 | // numerically zero. |
|
| 2493 | if ( bySet && i !== matchedCount ) { |
|
| 2494 | j = 0; |
|
| 2495 | while ( (matcher = setMatchers[j++]) ) { |
|
| 2496 | matcher( unmatched, setMatched, context, xml ); |
|
| 2497 | } |
|
| 2498 | ||
| 2499 | if ( seed ) { |
|
| 2500 | // Reintegrate element matches to eliminate the need for sorting |
|
| 2501 | if ( matchedCount > 0 ) { |
|
| 2502 | while ( i-- ) { |
|
| 2503 | if ( !(unmatched[i] || setMatched[i]) ) { |
|
| 2504 | setMatched[i] = pop.call( results ); |
|
| 2505 | } |
|
| 2506 | } |
|
| 2507 | } |
|
| 2508 | ||
| 2509 | // Discard index placeholder values to get only actual matches |
|
| 2510 | setMatched = condense( setMatched ); |
|
| 2511 | } |
|
| 2512 | ||
| 2513 | // Add matches to results |
|
| 2514 | push.apply( results, setMatched ); |
|
| 2515 | ||
| 2516 | // Seedless set matches succeeding multiple successful matchers stipulate sorting |
|
| 2517 | if ( outermost && !seed && setMatched.length > 0 && |
|
| 2518 | ( matchedCount + setMatchers.length ) > 1 ) { |
|
| 2519 | ||
| 2520 | Sizzle.uniqueSort( results ); |
|
| 2521 | } |
|
| 2522 | } |
|
| 2523 | ||
| 2524 | // Override manipulation of globals by nested matchers |
|
| 2525 | if ( outermost ) { |
|
| 2526 | dirruns = dirrunsUnique; |
|
| 2527 | outermostContext = contextBackup; |
|
| 2528 | } |
|
| 2529 | ||
| 2530 | return unmatched; |
|
| 2531 | }; |
|
| 2532 | ||
| 2533 | return bySet ? |
|
| 2534 | markFunction( superMatcher ) : |
|
| 2535 | superMatcher; |
|
| 2536 | } |
|
| 2537 | ||
| 2538 | compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { |
|
| 2539 | var i, |
|
| 2540 | setMatchers = [], |
|
| 2541 | elementMatchers = [], |
|
| 2542 | cached = compilerCache[ selector + " " ]; |
|
| 2543 | ||
| 2544 | if ( !cached ) { |
|
| 2545 | // Generate a function of recursive functions that can be used to check each element |
|
| 2546 | if ( !match ) { |
|
| 2547 | match = tokenize( selector ); |
|
| 2548 | } |
|
| 2549 | i = match.length; |
|
| 2550 | while ( i-- ) { |
|
| 2551 | cached = matcherFromTokens( match[i] ); |
|
| 2552 | if ( cached[ expando ] ) { |
|
| 2553 | setMatchers.push( cached ); |
|
| 2554 | } else { |
|
| 2555 | elementMatchers.push( cached ); |
|
| 2556 | } |
|
| 2557 | } |
|
| 2558 | ||
| 2559 | // Cache the compiled function |
|
| 2560 | cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); |
|
| 2561 | ||
| 2562 | // Save selector and tokenization |
|
| 2563 | cached.selector = selector; |
|
| 2564 | } |
|
| 2565 | return cached; |
|
| 2566 | }; |
|
| 2567 | ||
| 2568 | /** |
|
| 2569 | * A low-level selection function that works with Sizzle's compiled |
|
| 2570 | * selector functions |
|
| 2571 | * @param {String|Function} selector A selector or a pre-compiled |
|
| 2572 | * selector function built with Sizzle.compile |
|
| 2573 | * @param {Element} context |
|
| 2574 | * @param {Array} [results] |
|
| 2575 | * @param {Array} [seed] A set of elements to match against |
|
| 2576 | */ |
|
| 2577 | select = Sizzle.select = function( selector, context, results, seed ) { |
|
| 2578 | var i, tokens, token, type, find, |
|
| 2579 | compiled = typeof selector === "function" && selector, |
|
| 2580 | match = !seed && tokenize( (selector = compiled.selector || selector) ); |
|
| 2581 | ||
| 2582 | results = results || []; |
|
| 2583 | ||
| 2584 | // Try to minimize operations if there is only one selector in the list and no seed |
|
| 2585 | // (the latter of which guarantees us context) |
|
| 2586 | if ( match.length === 1 ) { |
|
| 2587 | ||
| 2588 | // Reduce context if the leading compound selector is an ID |
|
| 2589 | tokens = match[0] = match[0].slice( 0 ); |
|
| 2590 | if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && |
|
| 2591 | support.getById && context.nodeType === 9 && documentIsHTML && |
|
| 2592 | Expr.relative[ tokens[1].type ] ) { |
|
| 2593 | ||
| 2594 | context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; |
|
| 2595 | if ( !context ) { |
|
| 2596 | return results; |
|
| 2597 | ||
| 2598 | // Precompiled matchers will still verify ancestry, so step up a level |
|
| 2599 | } else if ( compiled ) { |
|
| 2600 | context = context.parentNode; |
|
| 2601 | } |
|
| 2602 | ||
| 2603 | selector = selector.slice( tokens.shift().value.length ); |
|
| 2604 | } |
|
| 2605 | ||
| 2606 | // Fetch a seed set for right-to-left matching |
|
| 2607 | i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; |
|
| 2608 | while ( i-- ) { |
|
| 2609 | token = tokens[i]; |
|
| 2610 | ||
| 2611 | // Abort if we hit a combinator |
|
| 2612 | if ( Expr.relative[ (type = token.type) ] ) { |
|
| 2613 | break; |
|
| 2614 | } |
|
| 2615 | if ( (find = Expr.find[ type ]) ) { |
|
| 2616 | // Search, expanding context for leading sibling combinators |
|
| 2617 | if ( (seed = find( |
|
| 2618 | token.matches[0].replace( runescape, funescape ), |
|
| 2619 | rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context |
|
| 2620 | )) ) { |
|
| 2621 | ||
| 2622 | // If seed is empty or no tokens remain, we can return early |
|
| 2623 | tokens.splice( i, 1 ); |
|
| 2624 | selector = seed.length && toSelector( tokens ); |
|
| 2625 | if ( !selector ) { |
|
| 2626 | push.apply( results, seed ); |
|
| 2627 | return results; |
|
| 2628 | } |
|
| 2629 | ||
| 2630 | break; |
|
| 2631 | } |
|
| 2632 | } |
|
| 2633 | } |
|
| 2634 | } |
|
| 2635 | ||
| 2636 | // Compile and execute a filtering function if one is not provided |
|
| 2637 | // Provide `match` to avoid retokenization if we modified the selector above |
|
| 2638 | ( compiled || compile( selector, match ) )( |
|
| 2639 | seed, |
|
| 2640 | context, |
|
| 2641 | !documentIsHTML, |
|
| 2642 | results, |
|
| 2643 | !context || rsibling.test( selector ) && testContext( context.parentNode ) || context |
|
| 2644 | ); |
|
| 2645 | return results; |
|
| 2646 | }; |
|
| 2647 | ||
| 2648 | // One-time assignments |
|
| 2649 | ||
| 2650 | // Sort stability |
|
| 2651 | support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; |
|
| 2652 | ||
| 2653 | // Support: Chrome 14-35+ |
|
| 2654 | // Always assume duplicates if they aren't passed to the comparison function |
|
| 2655 | support.detectDuplicates = !!hasDuplicate; |
|
| 2656 | ||
| 2657 | // Initialize against the default document |
|
| 2658 | setDocument(); |
|
| 2659 | ||
| 2660 | // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) |
|
| 2661 | // Detached nodes confoundingly follow *each other* |
|
| 2662 | support.sortDetached = assert(function( div1 ) { |
|
| 2663 | // Should return 1, but returns 4 (following) |
|
| 2664 | return div1.compareDocumentPosition( document.createElement("div") ) & 1; |
|
| 2665 | }); |
|
| 2666 | ||
| 2667 | // Support: IE<8 |
|
| 2668 | // Prevent attribute/property "interpolation" |
|
| 2669 | // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx |
|
| 2670 | if ( !assert(function( div ) { |
|
| 2671 | div.innerHTML = "<a href='#'></a>"; |
|
| 2672 | return div.firstChild.getAttribute("href") === "#" ; |
|
| 2673 | }) ) { |
|
| 2674 | addHandle( "type|href|height|width", function( elem, name, isXML ) { |
|
| 2675 | if ( !isXML ) { |
|
| 2676 | return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); |
|
| 2677 | } |
|
| 2678 | }); |
|
| 2679 | } |
|
| 2680 | ||
| 2681 | // Support: IE<9 |
|
| 2682 | // Use defaultValue in place of getAttribute("value") |
|
| 2683 | if ( !support.attributes || !assert(function( div ) { |
|
| 2684 | div.innerHTML = "<input/>"; |
|
| 2685 | div.firstChild.setAttribute( "value", "" ); |
|
| 2686 | return div.firstChild.getAttribute( "value" ) === ""; |
|
| 2687 | }) ) { |
|
| 2688 | addHandle( "value", function( elem, name, isXML ) { |
|
| 2689 | if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { |
|
| 2690 | return elem.defaultValue; |
|
| 2691 | } |
|
| 2692 | }); |
|
| 2693 | } |
|
| 2694 | ||
| 2695 | // Support: IE<9 |
|
| 2696 | // Use getAttributeNode to fetch booleans when getAttribute lies |
|
| 2697 | if ( !assert(function( div ) { |
|
| 2698 | return div.getAttribute("disabled") == null; |
|
| 2699 | }) ) { |
|
| 2700 | addHandle( booleans, function( elem, name, isXML ) { |
|
| 2701 | var val; |
|
| 2702 | if ( !isXML ) { |
|
| 2703 | return elem[ name ] === true ? name.toLowerCase() : |
|
| 2704 | (val = elem.getAttributeNode( name )) && val.specified ? |
|
| 2705 | val.value : |
|
| 2706 | null; |
|
| 2707 | } |
|
| 2708 | }); |
|
| 2709 | } |
|
| 2710 | ||
| 2711 | return Sizzle; |
|
| 2712 | ||
| 2713 | })( window ); |
|
| 2714 | ||
| 2715 | ||
| 2716 | ||
| @@ 551-2674 (lines=2124) @@ | ||
| 548 | * |
|
| 549 | * Date: 2015-10-17 |
|
| 550 | */ |
|
| 551 | (function( window ) { |
|
| 552 | ||
| 553 | var i, |
|
| 554 | support, |
|
| 555 | Expr, |
|
| 556 | getText, |
|
| 557 | isXML, |
|
| 558 | tokenize, |
|
| 559 | compile, |
|
| 560 | select, |
|
| 561 | outermostContext, |
|
| 562 | sortInput, |
|
| 563 | hasDuplicate, |
|
| 564 | ||
| 565 | // Local document vars |
|
| 566 | setDocument, |
|
| 567 | document, |
|
| 568 | docElem, |
|
| 569 | documentIsHTML, |
|
| 570 | rbuggyQSA, |
|
| 571 | rbuggyMatches, |
|
| 572 | matches, |
|
| 573 | contains, |
|
| 574 | ||
| 575 | // Instance-specific data |
|
| 576 | expando = "sizzle" + 1 * new Date(), |
|
| 577 | preferredDoc = window.document, |
|
| 578 | dirruns = 0, |
|
| 579 | done = 0, |
|
| 580 | classCache = createCache(), |
|
| 581 | tokenCache = createCache(), |
|
| 582 | compilerCache = createCache(), |
|
| 583 | sortOrder = function( a, b ) { |
|
| 584 | if ( a === b ) { |
|
| 585 | hasDuplicate = true; |
|
| 586 | } |
|
| 587 | return 0; |
|
| 588 | }, |
|
| 589 | ||
| 590 | // General-purpose constants |
|
| 591 | MAX_NEGATIVE = 1 << 31, |
|
| 592 | ||
| 593 | // Instance methods |
|
| 594 | hasOwn = ({}).hasOwnProperty, |
|
| 595 | arr = [], |
|
| 596 | pop = arr.pop, |
|
| 597 | push_native = arr.push, |
|
| 598 | push = arr.push, |
|
| 599 | slice = arr.slice, |
|
| 600 | // Use a stripped-down indexOf as it's faster than native |
|
| 601 | // http://jsperf.com/thor-indexof-vs-for/5 |
|
| 602 | indexOf = function( list, elem ) { |
|
| 603 | var i = 0, |
|
| 604 | len = list.length; |
|
| 605 | for ( ; i < len; i++ ) { |
|
| 606 | if ( list[i] === elem ) { |
|
| 607 | return i; |
|
| 608 | } |
|
| 609 | } |
|
| 610 | return -1; |
|
| 611 | }, |
|
| 612 | ||
| 613 | booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", |
|
| 614 | ||
| 615 | // Regular expressions |
|
| 616 | ||
| 617 | // http://www.w3.org/TR/css3-selectors/#whitespace |
|
| 618 | whitespace = "[\\x20\\t\\r\\n\\f]", |
|
| 619 | ||
| 620 | // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier |
|
| 621 | identifier = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", |
|
| 622 | ||
| 623 | // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors |
|
| 624 | attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + |
|
| 625 | // Operator (capture 2) |
|
| 626 | "*([*^$|!~]?=)" + whitespace + |
|
| 627 | // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" |
|
| 628 | "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + |
|
| 629 | "*\\]", |
|
| 630 | ||
| 631 | pseudos = ":(" + identifier + ")(?:\\((" + |
|
| 632 | // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: |
|
| 633 | // 1. quoted (capture 3; capture 4 or capture 5) |
|
| 634 | "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + |
|
| 635 | // 2. simple (capture 6) |
|
| 636 | "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + |
|
| 637 | // 3. anything else (capture 2) |
|
| 638 | ".*" + |
|
| 639 | ")\\)|)", |
|
| 640 | ||
| 641 | // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter |
|
| 642 | rwhitespace = new RegExp( whitespace + "+", "g" ), |
|
| 643 | rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), |
|
| 644 | ||
| 645 | rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), |
|
| 646 | rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), |
|
| 647 | ||
| 648 | rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), |
|
| 649 | ||
| 650 | rpseudo = new RegExp( pseudos ), |
|
| 651 | ridentifier = new RegExp( "^" + identifier + "$" ), |
|
| 652 | ||
| 653 | matchExpr = { |
|
| 654 | "ID": new RegExp( "^#(" + identifier + ")" ), |
|
| 655 | "CLASS": new RegExp( "^\\.(" + identifier + ")" ), |
|
| 656 | "TAG": new RegExp( "^(" + identifier + "|[*])" ), |
|
| 657 | "ATTR": new RegExp( "^" + attributes ), |
|
| 658 | "PSEUDO": new RegExp( "^" + pseudos ), |
|
| 659 | "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + |
|
| 660 | "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + |
|
| 661 | "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), |
|
| 662 | "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), |
|
| 663 | // For use in libraries implementing .is() |
|
| 664 | // We use this for POS matching in `select` |
|
| 665 | "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + |
|
| 666 | whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) |
|
| 667 | }, |
|
| 668 | ||
| 669 | rinputs = /^(?:input|select|textarea|button)$/i, |
|
| 670 | rheader = /^h\d$/i, |
|
| 671 | ||
| 672 | rnative = /^[^{]+\{\s*\[native \w/, |
|
| 673 | ||
| 674 | // Easily-parseable/retrievable ID or TAG or CLASS selectors |
|
| 675 | rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, |
|
| 676 | ||
| 677 | rsibling = /[+~]/, |
|
| 678 | rescape = /'|\\/g, |
|
| 679 | ||
| 680 | // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters |
|
| 681 | runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), |
|
| 682 | funescape = function( _, escaped, escapedWhitespace ) { |
|
| 683 | var high = "0x" + escaped - 0x10000; |
|
| 684 | // NaN means non-codepoint |
|
| 685 | // Support: Firefox<24 |
|
| 686 | // Workaround erroneous numeric interpretation of +"0x" |
|
| 687 | return high !== high || escapedWhitespace ? |
|
| 688 | escaped : |
|
| 689 | high < 0 ? |
|
| 690 | // BMP codepoint |
|
| 691 | String.fromCharCode( high + 0x10000 ) : |
|
| 692 | // Supplemental Plane codepoint (surrogate pair) |
|
| 693 | String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); |
|
| 694 | }, |
|
| 695 | ||
| 696 | // Used for iframes |
|
| 697 | // See setDocument() |
|
| 698 | // Removing the function wrapper causes a "Permission Denied" |
|
| 699 | // error in IE |
|
| 700 | unloadHandler = function() { |
|
| 701 | setDocument(); |
|
| 702 | }; |
|
| 703 | ||
| 704 | // Optimize for push.apply( _, NodeList ) |
|
| 705 | try { |
|
| 706 | push.apply( |
|
| 707 | (arr = slice.call( preferredDoc.childNodes )), |
|
| 708 | preferredDoc.childNodes |
|
| 709 | ); |
|
| 710 | // Support: Android<4.0 |
|
| 711 | // Detect silently failing push.apply |
|
| 712 | arr[ preferredDoc.childNodes.length ].nodeType; |
|
| 713 | } catch ( e ) { |
|
| 714 | push = { apply: arr.length ? |
|
| 715 | ||
| 716 | // Leverage slice if possible |
|
| 717 | function( target, els ) { |
|
| 718 | push_native.apply( target, slice.call(els) ); |
|
| 719 | } : |
|
| 720 | ||
| 721 | // Support: IE<9 |
|
| 722 | // Otherwise append directly |
|
| 723 | function( target, els ) { |
|
| 724 | var j = target.length, |
|
| 725 | i = 0; |
|
| 726 | // Can't trust NodeList.length |
|
| 727 | while ( (target[j++] = els[i++]) ) {} |
|
| 728 | target.length = j - 1; |
|
| 729 | } |
|
| 730 | }; |
|
| 731 | } |
|
| 732 | ||
| 733 | function Sizzle( selector, context, results, seed ) { |
|
| 734 | var m, i, elem, nid, nidselect, match, groups, newSelector, |
|
| 735 | newContext = context && context.ownerDocument, |
|
| 736 | ||
| 737 | // nodeType defaults to 9, since context defaults to document |
|
| 738 | nodeType = context ? context.nodeType : 9; |
|
| 739 | ||
| 740 | results = results || []; |
|
| 741 | ||
| 742 | // Return early from calls with invalid selector or context |
|
| 743 | if ( typeof selector !== "string" || !selector || |
|
| 744 | nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { |
|
| 745 | ||
| 746 | return results; |
|
| 747 | } |
|
| 748 | ||
| 749 | // Try to shortcut find operations (as opposed to filters) in HTML documents |
|
| 750 | if ( !seed ) { |
|
| 751 | ||
| 752 | if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { |
|
| 753 | setDocument( context ); |
|
| 754 | } |
|
| 755 | context = context || document; |
|
| 756 | ||
| 757 | if ( documentIsHTML ) { |
|
| 758 | ||
| 759 | // If the selector is sufficiently simple, try using a "get*By*" DOM method |
|
| 760 | // (excepting DocumentFragment context, where the methods don't exist) |
|
| 761 | if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { |
|
| 762 | ||
| 763 | // ID selector |
|
| 764 | if ( (m = match[1]) ) { |
|
| 765 | ||
| 766 | // Document context |
|
| 767 | if ( nodeType === 9 ) { |
|
| 768 | if ( (elem = context.getElementById( m )) ) { |
|
| 769 | ||
| 770 | // Support: IE, Opera, Webkit |
|
| 771 | // TODO: identify versions |
|
| 772 | // getElementById can match elements by name instead of ID |
|
| 773 | if ( elem.id === m ) { |
|
| 774 | results.push( elem ); |
|
| 775 | return results; |
|
| 776 | } |
|
| 777 | } else { |
|
| 778 | return results; |
|
| 779 | } |
|
| 780 | ||
| 781 | // Element context |
|
| 782 | } else { |
|
| 783 | ||
| 784 | // Support: IE, Opera, Webkit |
|
| 785 | // TODO: identify versions |
|
| 786 | // getElementById can match elements by name instead of ID |
|
| 787 | if ( newContext && (elem = newContext.getElementById( m )) && |
|
| 788 | contains( context, elem ) && |
|
| 789 | elem.id === m ) { |
|
| 790 | ||
| 791 | results.push( elem ); |
|
| 792 | return results; |
|
| 793 | } |
|
| 794 | } |
|
| 795 | ||
| 796 | // Type selector |
|
| 797 | } else if ( match[2] ) { |
|
| 798 | push.apply( results, context.getElementsByTagName( selector ) ); |
|
| 799 | return results; |
|
| 800 | ||
| 801 | // Class selector |
|
| 802 | } else if ( (m = match[3]) && support.getElementsByClassName && |
|
| 803 | context.getElementsByClassName ) { |
|
| 804 | ||
| 805 | push.apply( results, context.getElementsByClassName( m ) ); |
|
| 806 | return results; |
|
| 807 | } |
|
| 808 | } |
|
| 809 | ||
| 810 | // Take advantage of querySelectorAll |
|
| 811 | if ( support.qsa && |
|
| 812 | !compilerCache[ selector + " " ] && |
|
| 813 | (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { |
|
| 814 | ||
| 815 | if ( nodeType !== 1 ) { |
|
| 816 | newContext = context; |
|
| 817 | newSelector = selector; |
|
| 818 | ||
| 819 | // qSA looks outside Element context, which is not what we want |
|
| 820 | // Thanks to Andrew Dupont for this workaround technique |
|
| 821 | // Support: IE <=8 |
|
| 822 | // Exclude object elements |
|
| 823 | } else if ( context.nodeName.toLowerCase() !== "object" ) { |
|
| 824 | ||
| 825 | // Capture the context ID, setting it first if necessary |
|
| 826 | if ( (nid = context.getAttribute( "id" )) ) { |
|
| 827 | nid = nid.replace( rescape, "\\$&" ); |
|
| 828 | } else { |
|
| 829 | context.setAttribute( "id", (nid = expando) ); |
|
| 830 | } |
|
| 831 | ||
| 832 | // Prefix every selector in the list |
|
| 833 | groups = tokenize( selector ); |
|
| 834 | i = groups.length; |
|
| 835 | nidselect = ridentifier.test( nid ) ? "#" + nid : "[id='" + nid + "']"; |
|
| 836 | while ( i-- ) { |
|
| 837 | groups[i] = nidselect + " " + toSelector( groups[i] ); |
|
| 838 | } |
|
| 839 | newSelector = groups.join( "," ); |
|
| 840 | ||
| 841 | // Expand context for sibling selectors |
|
| 842 | newContext = rsibling.test( selector ) && testContext( context.parentNode ) || |
|
| 843 | context; |
|
| 844 | } |
|
| 845 | ||
| 846 | if ( newSelector ) { |
|
| 847 | try { |
|
| 848 | push.apply( results, |
|
| 849 | newContext.querySelectorAll( newSelector ) |
|
| 850 | ); |
|
| 851 | return results; |
|
| 852 | } catch ( qsaError ) { |
|
| 853 | } finally { |
|
| 854 | if ( nid === expando ) { |
|
| 855 | context.removeAttribute( "id" ); |
|
| 856 | } |
|
| 857 | } |
|
| 858 | } |
|
| 859 | } |
|
| 860 | } |
|
| 861 | } |
|
| 862 | ||
| 863 | // All others |
|
| 864 | return select( selector.replace( rtrim, "$1" ), context, results, seed ); |
|
| 865 | } |
|
| 866 | ||
| 867 | /** |
|
| 868 | * Create key-value caches of limited size |
|
| 869 | * @returns {function(string, object)} Returns the Object data after storing it on itself with |
|
| 870 | * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) |
|
| 871 | * deleting the oldest entry |
|
| 872 | */ |
|
| 873 | function createCache() { |
|
| 874 | var keys = []; |
|
| 875 | ||
| 876 | function cache( key, value ) { |
|
| 877 | // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) |
|
| 878 | if ( keys.push( key + " " ) > Expr.cacheLength ) { |
|
| 879 | // Only keep the most recent entries |
|
| 880 | delete cache[ keys.shift() ]; |
|
| 881 | } |
|
| 882 | return (cache[ key + " " ] = value); |
|
| 883 | } |
|
| 884 | return cache; |
|
| 885 | } |
|
| 886 | ||
| 887 | /** |
|
| 888 | * Mark a function for special use by Sizzle |
|
| 889 | * @param {Function} fn The function to mark |
|
| 890 | */ |
|
| 891 | function markFunction( fn ) { |
|
| 892 | fn[ expando ] = true; |
|
| 893 | return fn; |
|
| 894 | } |
|
| 895 | ||
| 896 | /** |
|
| 897 | * Support testing using an element |
|
| 898 | * @param {Function} fn Passed the created div and expects a boolean result |
|
| 899 | */ |
|
| 900 | function assert( fn ) { |
|
| 901 | var div = document.createElement("div"); |
|
| 902 | ||
| 903 | try { |
|
| 904 | return !!fn( div ); |
|
| 905 | } catch (e) { |
|
| 906 | return false; |
|
| 907 | } finally { |
|
| 908 | // Remove from its parent by default |
|
| 909 | if ( div.parentNode ) { |
|
| 910 | div.parentNode.removeChild( div ); |
|
| 911 | } |
|
| 912 | // release memory in IE |
|
| 913 | div = null; |
|
| 914 | } |
|
| 915 | } |
|
| 916 | ||
| 917 | /** |
|
| 918 | * Adds the same handler for all of the specified attrs |
|
| 919 | * @param {String} attrs Pipe-separated list of attributes |
|
| 920 | * @param {Function} handler The method that will be applied |
|
| 921 | */ |
|
| 922 | function addHandle( attrs, handler ) { |
|
| 923 | var arr = attrs.split("|"), |
|
| 924 | i = arr.length; |
|
| 925 | ||
| 926 | while ( i-- ) { |
|
| 927 | Expr.attrHandle[ arr[i] ] = handler; |
|
| 928 | } |
|
| 929 | } |
|
| 930 | ||
| 931 | /** |
|
| 932 | * Checks document order of two siblings |
|
| 933 | * @param {Element} a |
|
| 934 | * @param {Element} b |
|
| 935 | * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b |
|
| 936 | */ |
|
| 937 | function siblingCheck( a, b ) { |
|
| 938 | var cur = b && a, |
|
| 939 | diff = cur && a.nodeType === 1 && b.nodeType === 1 && |
|
| 940 | ( ~b.sourceIndex || MAX_NEGATIVE ) - |
|
| 941 | ( ~a.sourceIndex || MAX_NEGATIVE ); |
|
| 942 | ||
| 943 | // Use IE sourceIndex if available on both nodes |
|
| 944 | if ( diff ) { |
|
| 945 | return diff; |
|
| 946 | } |
|
| 947 | ||
| 948 | // Check if b follows a |
|
| 949 | if ( cur ) { |
|
| 950 | while ( (cur = cur.nextSibling) ) { |
|
| 951 | if ( cur === b ) { |
|
| 952 | return -1; |
|
| 953 | } |
|
| 954 | } |
|
| 955 | } |
|
| 956 | ||
| 957 | return a ? 1 : -1; |
|
| 958 | } |
|
| 959 | ||
| 960 | /** |
|
| 961 | * Returns a function to use in pseudos for input types |
|
| 962 | * @param {String} type |
|
| 963 | */ |
|
| 964 | function createInputPseudo( type ) { |
|
| 965 | return function( elem ) { |
|
| 966 | var name = elem.nodeName.toLowerCase(); |
|
| 967 | return name === "input" && elem.type === type; |
|
| 968 | }; |
|
| 969 | } |
|
| 970 | ||
| 971 | /** |
|
| 972 | * Returns a function to use in pseudos for buttons |
|
| 973 | * @param {String} type |
|
| 974 | */ |
|
| 975 | function createButtonPseudo( type ) { |
|
| 976 | return function( elem ) { |
|
| 977 | var name = elem.nodeName.toLowerCase(); |
|
| 978 | return (name === "input" || name === "button") && elem.type === type; |
|
| 979 | }; |
|
| 980 | } |
|
| 981 | ||
| 982 | /** |
|
| 983 | * Returns a function to use in pseudos for positionals |
|
| 984 | * @param {Function} fn |
|
| 985 | */ |
|
| 986 | function createPositionalPseudo( fn ) { |
|
| 987 | return markFunction(function( argument ) { |
|
| 988 | argument = +argument; |
|
| 989 | return markFunction(function( seed, matches ) { |
|
| 990 | var j, |
|
| 991 | matchIndexes = fn( [], seed.length, argument ), |
|
| 992 | i = matchIndexes.length; |
|
| 993 | ||
| 994 | // Match elements found at the specified indexes |
|
| 995 | while ( i-- ) { |
|
| 996 | if ( seed[ (j = matchIndexes[i]) ] ) { |
|
| 997 | seed[j] = !(matches[j] = seed[j]); |
|
| 998 | } |
|
| 999 | } |
|
| 1000 | }); |
|
| 1001 | }); |
|
| 1002 | } |
|
| 1003 | ||
| 1004 | /** |
|
| 1005 | * Checks a node for validity as a Sizzle context |
|
| 1006 | * @param {Element|Object=} context |
|
| 1007 | * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value |
|
| 1008 | */ |
|
| 1009 | function testContext( context ) { |
|
| 1010 | return context && typeof context.getElementsByTagName !== "undefined" && context; |
|
| 1011 | } |
|
| 1012 | ||
| 1013 | // Expose support vars for convenience |
|
| 1014 | support = Sizzle.support = {}; |
|
| 1015 | ||
| 1016 | /** |
|
| 1017 | * Detects XML nodes |
|
| 1018 | * @param {Element|Object} elem An element or a document |
|
| 1019 | * @returns {Boolean} True iff elem is a non-HTML XML node |
|
| 1020 | */ |
|
| 1021 | isXML = Sizzle.isXML = function( elem ) { |
|
| 1022 | // documentElement is verified for cases where it doesn't yet exist |
|
| 1023 | // (such as loading iframes in IE - #4833) |
|
| 1024 | var documentElement = elem && (elem.ownerDocument || elem).documentElement; |
|
| 1025 | return documentElement ? documentElement.nodeName !== "HTML" : false; |
|
| 1026 | }; |
|
| 1027 | ||
| 1028 | /** |
|
| 1029 | * Sets document-related variables once based on the current document |
|
| 1030 | * @param {Element|Object} [doc] An element or document object to use to set the document |
|
| 1031 | * @returns {Object} Returns the current document |
|
| 1032 | */ |
|
| 1033 | setDocument = Sizzle.setDocument = function( node ) { |
|
| 1034 | var hasCompare, parent, |
|
| 1035 | doc = node ? node.ownerDocument || node : preferredDoc; |
|
| 1036 | ||
| 1037 | // Return early if doc is invalid or already selected |
|
| 1038 | if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { |
|
| 1039 | return document; |
|
| 1040 | } |
|
| 1041 | ||
| 1042 | // Update global variables |
|
| 1043 | document = doc; |
|
| 1044 | docElem = document.documentElement; |
|
| 1045 | documentIsHTML = !isXML( document ); |
|
| 1046 | ||
| 1047 | // Support: IE 9-11, Edge |
|
| 1048 | // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) |
|
| 1049 | if ( (parent = document.defaultView) && parent.top !== parent ) { |
|
| 1050 | // Support: IE 11 |
|
| 1051 | if ( parent.addEventListener ) { |
|
| 1052 | parent.addEventListener( "unload", unloadHandler, false ); |
|
| 1053 | ||
| 1054 | // Support: IE 9 - 10 only |
|
| 1055 | } else if ( parent.attachEvent ) { |
|
| 1056 | parent.attachEvent( "onunload", unloadHandler ); |
|
| 1057 | } |
|
| 1058 | } |
|
| 1059 | ||
| 1060 | /* Attributes |
|
| 1061 | ---------------------------------------------------------------------- */ |
|
| 1062 | ||
| 1063 | // Support: IE<8 |
|
| 1064 | // Verify that getAttribute really returns attributes and not properties |
|
| 1065 | // (excepting IE8 booleans) |
|
| 1066 | support.attributes = assert(function( div ) { |
|
| 1067 | div.className = "i"; |
|
| 1068 | return !div.getAttribute("className"); |
|
| 1069 | }); |
|
| 1070 | ||
| 1071 | /* getElement(s)By* |
|
| 1072 | ---------------------------------------------------------------------- */ |
|
| 1073 | ||
| 1074 | // Check if getElementsByTagName("*") returns only elements |
|
| 1075 | support.getElementsByTagName = assert(function( div ) { |
|
| 1076 | div.appendChild( document.createComment("") ); |
|
| 1077 | return !div.getElementsByTagName("*").length; |
|
| 1078 | }); |
|
| 1079 | ||
| 1080 | // Support: IE<9 |
|
| 1081 | support.getElementsByClassName = rnative.test( document.getElementsByClassName ); |
|
| 1082 | ||
| 1083 | // Support: IE<10 |
|
| 1084 | // Check if getElementById returns elements by name |
|
| 1085 | // The broken getElementById methods don't pick up programatically-set names, |
|
| 1086 | // so use a roundabout getElementsByName test |
|
| 1087 | support.getById = assert(function( div ) { |
|
| 1088 | docElem.appendChild( div ).id = expando; |
|
| 1089 | return !document.getElementsByName || !document.getElementsByName( expando ).length; |
|
| 1090 | }); |
|
| 1091 | ||
| 1092 | // ID find and filter |
|
| 1093 | if ( support.getById ) { |
|
| 1094 | Expr.find["ID"] = function( id, context ) { |
|
| 1095 | if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { |
|
| 1096 | var m = context.getElementById( id ); |
|
| 1097 | return m ? [ m ] : []; |
|
| 1098 | } |
|
| 1099 | }; |
|
| 1100 | Expr.filter["ID"] = function( id ) { |
|
| 1101 | var attrId = id.replace( runescape, funescape ); |
|
| 1102 | return function( elem ) { |
|
| 1103 | return elem.getAttribute("id") === attrId; |
|
| 1104 | }; |
|
| 1105 | }; |
|
| 1106 | } else { |
|
| 1107 | // Support: IE6/7 |
|
| 1108 | // getElementById is not reliable as a find shortcut |
|
| 1109 | delete Expr.find["ID"]; |
|
| 1110 | ||
| 1111 | Expr.filter["ID"] = function( id ) { |
|
| 1112 | var attrId = id.replace( runescape, funescape ); |
|
| 1113 | return function( elem ) { |
|
| 1114 | var node = typeof elem.getAttributeNode !== "undefined" && |
|
| 1115 | elem.getAttributeNode("id"); |
|
| 1116 | return node && node.value === attrId; |
|
| 1117 | }; |
|
| 1118 | }; |
|
| 1119 | } |
|
| 1120 | ||
| 1121 | // Tag |
|
| 1122 | Expr.find["TAG"] = support.getElementsByTagName ? |
|
| 1123 | function( tag, context ) { |
|
| 1124 | if ( typeof context.getElementsByTagName !== "undefined" ) { |
|
| 1125 | return context.getElementsByTagName( tag ); |
|
| 1126 | ||
| 1127 | // DocumentFragment nodes don't have gEBTN |
|
| 1128 | } else if ( support.qsa ) { |
|
| 1129 | return context.querySelectorAll( tag ); |
|
| 1130 | } |
|
| 1131 | } : |
|
| 1132 | ||
| 1133 | function( tag, context ) { |
|
| 1134 | var elem, |
|
| 1135 | tmp = [], |
|
| 1136 | i = 0, |
|
| 1137 | // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too |
|
| 1138 | results = context.getElementsByTagName( tag ); |
|
| 1139 | ||
| 1140 | // Filter out possible comments |
|
| 1141 | if ( tag === "*" ) { |
|
| 1142 | while ( (elem = results[i++]) ) { |
|
| 1143 | if ( elem.nodeType === 1 ) { |
|
| 1144 | tmp.push( elem ); |
|
| 1145 | } |
|
| 1146 | } |
|
| 1147 | ||
| 1148 | return tmp; |
|
| 1149 | } |
|
| 1150 | return results; |
|
| 1151 | }; |
|
| 1152 | ||
| 1153 | // Class |
|
| 1154 | Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { |
|
| 1155 | if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { |
|
| 1156 | return context.getElementsByClassName( className ); |
|
| 1157 | } |
|
| 1158 | }; |
|
| 1159 | ||
| 1160 | /* QSA/matchesSelector |
|
| 1161 | ---------------------------------------------------------------------- */ |
|
| 1162 | ||
| 1163 | // QSA and matchesSelector support |
|
| 1164 | ||
| 1165 | // matchesSelector(:active) reports false when true (IE9/Opera 11.5) |
|
| 1166 | rbuggyMatches = []; |
|
| 1167 | ||
| 1168 | // qSa(:focus) reports false when true (Chrome 21) |
|
| 1169 | // We allow this because of a bug in IE8/9 that throws an error |
|
| 1170 | // whenever `document.activeElement` is accessed on an iframe |
|
| 1171 | // So, we allow :focus to pass through QSA all the time to avoid the IE error |
|
| 1172 | // See http://bugs.jquery.com/ticket/13378 |
|
| 1173 | rbuggyQSA = []; |
|
| 1174 | ||
| 1175 | if ( (support.qsa = rnative.test( document.querySelectorAll )) ) { |
|
| 1176 | // Build QSA regex |
|
| 1177 | // Regex strategy adopted from Diego Perini |
|
| 1178 | assert(function( div ) { |
|
| 1179 | // Select is set to empty string on purpose |
|
| 1180 | // This is to test IE's treatment of not explicitly |
|
| 1181 | // setting a boolean content attribute, |
|
| 1182 | // since its presence should be enough |
|
| 1183 | // http://bugs.jquery.com/ticket/12359 |
|
| 1184 | docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" + |
|
| 1185 | "<select id='" + expando + "-\r\\' msallowcapture=''>" + |
|
| 1186 | "<option selected=''></option></select>"; |
|
| 1187 | ||
| 1188 | // Support: IE8, Opera 11-12.16 |
|
| 1189 | // Nothing should be selected when empty strings follow ^= or $= or *= |
|
| 1190 | // The test attribute must be unknown in Opera but "safe" for WinRT |
|
| 1191 | // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section |
|
| 1192 | if ( div.querySelectorAll("[msallowcapture^='']").length ) { |
|
| 1193 | rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); |
|
| 1194 | } |
|
| 1195 | ||
| 1196 | // Support: IE8 |
|
| 1197 | // Boolean attributes and "value" are not treated correctly |
|
| 1198 | if ( !div.querySelectorAll("[selected]").length ) { |
|
| 1199 | rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); |
|
| 1200 | } |
|
| 1201 | ||
| 1202 | // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ |
|
| 1203 | if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) { |
|
| 1204 | rbuggyQSA.push("~="); |
|
| 1205 | } |
|
| 1206 | ||
| 1207 | // Webkit/Opera - :checked should return selected option elements |
|
| 1208 | // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked |
|
| 1209 | // IE8 throws error here and will not see later tests |
|
| 1210 | if ( !div.querySelectorAll(":checked").length ) { |
|
| 1211 | rbuggyQSA.push(":checked"); |
|
| 1212 | } |
|
| 1213 | ||
| 1214 | // Support: Safari 8+, iOS 8+ |
|
| 1215 | // https://bugs.webkit.org/show_bug.cgi?id=136851 |
|
| 1216 | // In-page `selector#id sibing-combinator selector` fails |
|
| 1217 | if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) { |
|
| 1218 | rbuggyQSA.push(".#.+[+~]"); |
|
| 1219 | } |
|
| 1220 | }); |
|
| 1221 | ||
| 1222 | assert(function( div ) { |
|
| 1223 | // Support: Windows 8 Native Apps |
|
| 1224 | // The type and name attributes are restricted during .innerHTML assignment |
|
| 1225 | var input = document.createElement("input"); |
|
| 1226 | input.setAttribute( "type", "hidden" ); |
|
| 1227 | div.appendChild( input ).setAttribute( "name", "D" ); |
|
| 1228 | ||
| 1229 | // Support: IE8 |
|
| 1230 | // Enforce case-sensitivity of name attribute |
|
| 1231 | if ( div.querySelectorAll("[name=d]").length ) { |
|
| 1232 | rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); |
|
| 1233 | } |
|
| 1234 | ||
| 1235 | // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) |
|
| 1236 | // IE8 throws error here and will not see later tests |
|
| 1237 | if ( !div.querySelectorAll(":enabled").length ) { |
|
| 1238 | rbuggyQSA.push( ":enabled", ":disabled" ); |
|
| 1239 | } |
|
| 1240 | ||
| 1241 | // Opera 10-11 does not throw on post-comma invalid pseudos |
|
| 1242 | div.querySelectorAll("*,:x"); |
|
| 1243 | rbuggyQSA.push(",.*:"); |
|
| 1244 | }); |
|
| 1245 | } |
|
| 1246 | ||
| 1247 | if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || |
|
| 1248 | docElem.webkitMatchesSelector || |
|
| 1249 | docElem.mozMatchesSelector || |
|
| 1250 | docElem.oMatchesSelector || |
|
| 1251 | docElem.msMatchesSelector) )) ) { |
|
| 1252 | ||
| 1253 | assert(function( div ) { |
|
| 1254 | // Check to see if it's possible to do matchesSelector |
|
| 1255 | // on a disconnected node (IE 9) |
|
| 1256 | support.disconnectedMatch = matches.call( div, "div" ); |
|
| 1257 | ||
| 1258 | // This should fail with an exception |
|
| 1259 | // Gecko does not error, returns false instead |
|
| 1260 | matches.call( div, "[s!='']:x" ); |
|
| 1261 | rbuggyMatches.push( "!=", pseudos ); |
|
| 1262 | }); |
|
| 1263 | } |
|
| 1264 | ||
| 1265 | rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); |
|
| 1266 | rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); |
|
| 1267 | ||
| 1268 | /* Contains |
|
| 1269 | ---------------------------------------------------------------------- */ |
|
| 1270 | hasCompare = rnative.test( docElem.compareDocumentPosition ); |
|
| 1271 | ||
| 1272 | // Element contains another |
|
| 1273 | // Purposefully self-exclusive |
|
| 1274 | // As in, an element does not contain itself |
|
| 1275 | contains = hasCompare || rnative.test( docElem.contains ) ? |
|
| 1276 | function( a, b ) { |
|
| 1277 | var adown = a.nodeType === 9 ? a.documentElement : a, |
|
| 1278 | bup = b && b.parentNode; |
|
| 1279 | return a === bup || !!( bup && bup.nodeType === 1 && ( |
|
| 1280 | adown.contains ? |
|
| 1281 | adown.contains( bup ) : |
|
| 1282 | a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 |
|
| 1283 | )); |
|
| 1284 | } : |
|
| 1285 | function( a, b ) { |
|
| 1286 | if ( b ) { |
|
| 1287 | while ( (b = b.parentNode) ) { |
|
| 1288 | if ( b === a ) { |
|
| 1289 | return true; |
|
| 1290 | } |
|
| 1291 | } |
|
| 1292 | } |
|
| 1293 | return false; |
|
| 1294 | }; |
|
| 1295 | ||
| 1296 | /* Sorting |
|
| 1297 | ---------------------------------------------------------------------- */ |
|
| 1298 | ||
| 1299 | // Document order sorting |
|
| 1300 | sortOrder = hasCompare ? |
|
| 1301 | function( a, b ) { |
|
| 1302 | ||
| 1303 | // Flag for duplicate removal |
|
| 1304 | if ( a === b ) { |
|
| 1305 | hasDuplicate = true; |
|
| 1306 | return 0; |
|
| 1307 | } |
|
| 1308 | ||
| 1309 | // Sort on method existence if only one input has compareDocumentPosition |
|
| 1310 | var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; |
|
| 1311 | if ( compare ) { |
|
| 1312 | return compare; |
|
| 1313 | } |
|
| 1314 | ||
| 1315 | // Calculate position if both inputs belong to the same document |
|
| 1316 | compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? |
|
| 1317 | a.compareDocumentPosition( b ) : |
|
| 1318 | ||
| 1319 | // Otherwise we know they are disconnected |
|
| 1320 | 1; |
|
| 1321 | ||
| 1322 | // Disconnected nodes |
|
| 1323 | if ( compare & 1 || |
|
| 1324 | (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { |
|
| 1325 | ||
| 1326 | // Choose the first element that is related to our preferred document |
|
| 1327 | if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { |
|
| 1328 | return -1; |
|
| 1329 | } |
|
| 1330 | if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { |
|
| 1331 | return 1; |
|
| 1332 | } |
|
| 1333 | ||
| 1334 | // Maintain original order |
|
| 1335 | return sortInput ? |
|
| 1336 | ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : |
|
| 1337 | 0; |
|
| 1338 | } |
|
| 1339 | ||
| 1340 | return compare & 4 ? -1 : 1; |
|
| 1341 | } : |
|
| 1342 | function( a, b ) { |
|
| 1343 | // Exit early if the nodes are identical |
|
| 1344 | if ( a === b ) { |
|
| 1345 | hasDuplicate = true; |
|
| 1346 | return 0; |
|
| 1347 | } |
|
| 1348 | ||
| 1349 | var cur, |
|
| 1350 | i = 0, |
|
| 1351 | aup = a.parentNode, |
|
| 1352 | bup = b.parentNode, |
|
| 1353 | ap = [ a ], |
|
| 1354 | bp = [ b ]; |
|
| 1355 | ||
| 1356 | // Parentless nodes are either documents or disconnected |
|
| 1357 | if ( !aup || !bup ) { |
|
| 1358 | return a === document ? -1 : |
|
| 1359 | b === document ? 1 : |
|
| 1360 | aup ? -1 : |
|
| 1361 | bup ? 1 : |
|
| 1362 | sortInput ? |
|
| 1363 | ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : |
|
| 1364 | 0; |
|
| 1365 | ||
| 1366 | // If the nodes are siblings, we can do a quick check |
|
| 1367 | } else if ( aup === bup ) { |
|
| 1368 | return siblingCheck( a, b ); |
|
| 1369 | } |
|
| 1370 | ||
| 1371 | // Otherwise we need full lists of their ancestors for comparison |
|
| 1372 | cur = a; |
|
| 1373 | while ( (cur = cur.parentNode) ) { |
|
| 1374 | ap.unshift( cur ); |
|
| 1375 | } |
|
| 1376 | cur = b; |
|
| 1377 | while ( (cur = cur.parentNode) ) { |
|
| 1378 | bp.unshift( cur ); |
|
| 1379 | } |
|
| 1380 | ||
| 1381 | // Walk down the tree looking for a discrepancy |
|
| 1382 | while ( ap[i] === bp[i] ) { |
|
| 1383 | i++; |
|
| 1384 | } |
|
| 1385 | ||
| 1386 | return i ? |
|
| 1387 | // Do a sibling check if the nodes have a common ancestor |
|
| 1388 | siblingCheck( ap[i], bp[i] ) : |
|
| 1389 | ||
| 1390 | // Otherwise nodes in our document sort first |
|
| 1391 | ap[i] === preferredDoc ? -1 : |
|
| 1392 | bp[i] === preferredDoc ? 1 : |
|
| 1393 | 0; |
|
| 1394 | }; |
|
| 1395 | ||
| 1396 | return document; |
|
| 1397 | }; |
|
| 1398 | ||
| 1399 | Sizzle.matches = function( expr, elements ) { |
|
| 1400 | return Sizzle( expr, null, null, elements ); |
|
| 1401 | }; |
|
| 1402 | ||
| 1403 | Sizzle.matchesSelector = function( elem, expr ) { |
|
| 1404 | // Set document vars if needed |
|
| 1405 | if ( ( elem.ownerDocument || elem ) !== document ) { |
|
| 1406 | setDocument( elem ); |
|
| 1407 | } |
|
| 1408 | ||
| 1409 | // Make sure that attribute selectors are quoted |
|
| 1410 | expr = expr.replace( rattributeQuotes, "='$1']" ); |
|
| 1411 | ||
| 1412 | if ( support.matchesSelector && documentIsHTML && |
|
| 1413 | !compilerCache[ expr + " " ] && |
|
| 1414 | ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && |
|
| 1415 | ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { |
|
| 1416 | ||
| 1417 | try { |
|
| 1418 | var ret = matches.call( elem, expr ); |
|
| 1419 | ||
| 1420 | // IE 9's matchesSelector returns false on disconnected nodes |
|
| 1421 | if ( ret || support.disconnectedMatch || |
|
| 1422 | // As well, disconnected nodes are said to be in a document |
|
| 1423 | // fragment in IE 9 |
|
| 1424 | elem.document && elem.document.nodeType !== 11 ) { |
|
| 1425 | return ret; |
|
| 1426 | } |
|
| 1427 | } catch (e) {} |
|
| 1428 | } |
|
| 1429 | ||
| 1430 | return Sizzle( expr, document, null, [ elem ] ).length > 0; |
|
| 1431 | }; |
|
| 1432 | ||
| 1433 | Sizzle.contains = function( context, elem ) { |
|
| 1434 | // Set document vars if needed |
|
| 1435 | if ( ( context.ownerDocument || context ) !== document ) { |
|
| 1436 | setDocument( context ); |
|
| 1437 | } |
|
| 1438 | return contains( context, elem ); |
|
| 1439 | }; |
|
| 1440 | ||
| 1441 | Sizzle.attr = function( elem, name ) { |
|
| 1442 | // Set document vars if needed |
|
| 1443 | if ( ( elem.ownerDocument || elem ) !== document ) { |
|
| 1444 | setDocument( elem ); |
|
| 1445 | } |
|
| 1446 | ||
| 1447 | var fn = Expr.attrHandle[ name.toLowerCase() ], |
|
| 1448 | // Don't get fooled by Object.prototype properties (jQuery #13807) |
|
| 1449 | val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? |
|
| 1450 | fn( elem, name, !documentIsHTML ) : |
|
| 1451 | undefined; |
|
| 1452 | ||
| 1453 | return val !== undefined ? |
|
| 1454 | val : |
|
| 1455 | support.attributes || !documentIsHTML ? |
|
| 1456 | elem.getAttribute( name ) : |
|
| 1457 | (val = elem.getAttributeNode(name)) && val.specified ? |
|
| 1458 | val.value : |
|
| 1459 | null; |
|
| 1460 | }; |
|
| 1461 | ||
| 1462 | Sizzle.error = function( msg ) { |
|
| 1463 | throw new Error( "Syntax error, unrecognized expression: " + msg ); |
|
| 1464 | }; |
|
| 1465 | ||
| 1466 | /** |
|
| 1467 | * Document sorting and removing duplicates |
|
| 1468 | * @param {ArrayLike} results |
|
| 1469 | */ |
|
| 1470 | Sizzle.uniqueSort = function( results ) { |
|
| 1471 | var elem, |
|
| 1472 | duplicates = [], |
|
| 1473 | j = 0, |
|
| 1474 | i = 0; |
|
| 1475 | ||
| 1476 | // Unless we *know* we can detect duplicates, assume their presence |
|
| 1477 | hasDuplicate = !support.detectDuplicates; |
|
| 1478 | sortInput = !support.sortStable && results.slice( 0 ); |
|
| 1479 | results.sort( sortOrder ); |
|
| 1480 | ||
| 1481 | if ( hasDuplicate ) { |
|
| 1482 | while ( (elem = results[i++]) ) { |
|
| 1483 | if ( elem === results[ i ] ) { |
|
| 1484 | j = duplicates.push( i ); |
|
| 1485 | } |
|
| 1486 | } |
|
| 1487 | while ( j-- ) { |
|
| 1488 | results.splice( duplicates[ j ], 1 ); |
|
| 1489 | } |
|
| 1490 | } |
|
| 1491 | ||
| 1492 | // Clear input after sorting to release objects |
|
| 1493 | // See https://github.com/jquery/sizzle/pull/225 |
|
| 1494 | sortInput = null; |
|
| 1495 | ||
| 1496 | return results; |
|
| 1497 | }; |
|
| 1498 | ||
| 1499 | /** |
|
| 1500 | * Utility function for retrieving the text value of an array of DOM nodes |
|
| 1501 | * @param {Array|Element} elem |
|
| 1502 | */ |
|
| 1503 | getText = Sizzle.getText = function( elem ) { |
|
| 1504 | var node, |
|
| 1505 | ret = "", |
|
| 1506 | i = 0, |
|
| 1507 | nodeType = elem.nodeType; |
|
| 1508 | ||
| 1509 | if ( !nodeType ) { |
|
| 1510 | // If no nodeType, this is expected to be an array |
|
| 1511 | while ( (node = elem[i++]) ) { |
|
| 1512 | // Do not traverse comment nodes |
|
| 1513 | ret += getText( node ); |
|
| 1514 | } |
|
| 1515 | } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { |
|
| 1516 | // Use textContent for elements |
|
| 1517 | // innerText usage removed for consistency of new lines (jQuery #11153) |
|
| 1518 | if ( typeof elem.textContent === "string" ) { |
|
| 1519 | return elem.textContent; |
|
| 1520 | } else { |
|
| 1521 | // Traverse its children |
|
| 1522 | for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { |
|
| 1523 | ret += getText( elem ); |
|
| 1524 | } |
|
| 1525 | } |
|
| 1526 | } else if ( nodeType === 3 || nodeType === 4 ) { |
|
| 1527 | return elem.nodeValue; |
|
| 1528 | } |
|
| 1529 | // Do not include comment or processing instruction nodes |
|
| 1530 | ||
| 1531 | return ret; |
|
| 1532 | }; |
|
| 1533 | ||
| 1534 | Expr = Sizzle.selectors = { |
|
| 1535 | ||
| 1536 | // Can be adjusted by the user |
|
| 1537 | cacheLength: 50, |
|
| 1538 | ||
| 1539 | createPseudo: markFunction, |
|
| 1540 | ||
| 1541 | match: matchExpr, |
|
| 1542 | ||
| 1543 | attrHandle: {}, |
|
| 1544 | ||
| 1545 | find: {}, |
|
| 1546 | ||
| 1547 | relative: { |
|
| 1548 | ">": { dir: "parentNode", first: true }, |
|
| 1549 | " ": { dir: "parentNode" }, |
|
| 1550 | "+": { dir: "previousSibling", first: true }, |
|
| 1551 | "~": { dir: "previousSibling" } |
|
| 1552 | }, |
|
| 1553 | ||
| 1554 | preFilter: { |
|
| 1555 | "ATTR": function( match ) { |
|
| 1556 | match[1] = match[1].replace( runescape, funescape ); |
|
| 1557 | ||
| 1558 | // Move the given value to match[3] whether quoted or unquoted |
|
| 1559 | match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape ); |
|
| 1560 | ||
| 1561 | if ( match[2] === "~=" ) { |
|
| 1562 | match[3] = " " + match[3] + " "; |
|
| 1563 | } |
|
| 1564 | ||
| 1565 | return match.slice( 0, 4 ); |
|
| 1566 | }, |
|
| 1567 | ||
| 1568 | "CHILD": function( match ) { |
|
| 1569 | /* matches from matchExpr["CHILD"] |
|
| 1570 | 1 type (only|nth|...) |
|
| 1571 | 2 what (child|of-type) |
|
| 1572 | 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) |
|
| 1573 | 4 xn-component of xn+y argument ([+-]?\d*n|) |
|
| 1574 | 5 sign of xn-component |
|
| 1575 | 6 x of xn-component |
|
| 1576 | 7 sign of y-component |
|
| 1577 | 8 y of y-component |
|
| 1578 | */ |
|
| 1579 | match[1] = match[1].toLowerCase(); |
|
| 1580 | ||
| 1581 | if ( match[1].slice( 0, 3 ) === "nth" ) { |
|
| 1582 | // nth-* requires argument |
|
| 1583 | if ( !match[3] ) { |
|
| 1584 | Sizzle.error( match[0] ); |
|
| 1585 | } |
|
| 1586 | ||
| 1587 | // numeric x and y parameters for Expr.filter.CHILD |
|
| 1588 | // remember that false/true cast respectively to 0/1 |
|
| 1589 | match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); |
|
| 1590 | match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); |
|
| 1591 | ||
| 1592 | // other types prohibit arguments |
|
| 1593 | } else if ( match[3] ) { |
|
| 1594 | Sizzle.error( match[0] ); |
|
| 1595 | } |
|
| 1596 | ||
| 1597 | return match; |
|
| 1598 | }, |
|
| 1599 | ||
| 1600 | "PSEUDO": function( match ) { |
|
| 1601 | var excess, |
|
| 1602 | unquoted = !match[6] && match[2]; |
|
| 1603 | ||
| 1604 | if ( matchExpr["CHILD"].test( match[0] ) ) { |
|
| 1605 | return null; |
|
| 1606 | } |
|
| 1607 | ||
| 1608 | // Accept quoted arguments as-is |
|
| 1609 | if ( match[3] ) { |
|
| 1610 | match[2] = match[4] || match[5] || ""; |
|
| 1611 | ||
| 1612 | // Strip excess characters from unquoted arguments |
|
| 1613 | } else if ( unquoted && rpseudo.test( unquoted ) && |
|
| 1614 | // Get excess from tokenize (recursively) |
|
| 1615 | (excess = tokenize( unquoted, true )) && |
|
| 1616 | // advance to the next closing parenthesis |
|
| 1617 | (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { |
|
| 1618 | ||
| 1619 | // excess is a negative index |
|
| 1620 | match[0] = match[0].slice( 0, excess ); |
|
| 1621 | match[2] = unquoted.slice( 0, excess ); |
|
| 1622 | } |
|
| 1623 | ||
| 1624 | // Return only captures needed by the pseudo filter method (type and argument) |
|
| 1625 | return match.slice( 0, 3 ); |
|
| 1626 | } |
|
| 1627 | }, |
|
| 1628 | ||
| 1629 | filter: { |
|
| 1630 | ||
| 1631 | "TAG": function( nodeNameSelector ) { |
|
| 1632 | var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); |
|
| 1633 | return nodeNameSelector === "*" ? |
|
| 1634 | function() { return true; } : |
|
| 1635 | function( elem ) { |
|
| 1636 | return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; |
|
| 1637 | }; |
|
| 1638 | }, |
|
| 1639 | ||
| 1640 | "CLASS": function( className ) { |
|
| 1641 | var pattern = classCache[ className + " " ]; |
|
| 1642 | ||
| 1643 | return pattern || |
|
| 1644 | (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && |
|
| 1645 | classCache( className, function( elem ) { |
|
| 1646 | return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" ); |
|
| 1647 | }); |
|
| 1648 | }, |
|
| 1649 | ||
| 1650 | "ATTR": function( name, operator, check ) { |
|
| 1651 | return function( elem ) { |
|
| 1652 | var result = Sizzle.attr( elem, name ); |
|
| 1653 | ||
| 1654 | if ( result == null ) { |
|
| 1655 | return operator === "!="; |
|
| 1656 | } |
|
| 1657 | if ( !operator ) { |
|
| 1658 | return true; |
|
| 1659 | } |
|
| 1660 | ||
| 1661 | result += ""; |
|
| 1662 | ||
| 1663 | return operator === "=" ? result === check : |
|
| 1664 | operator === "!=" ? result !== check : |
|
| 1665 | operator === "^=" ? check && result.indexOf( check ) === 0 : |
|
| 1666 | operator === "*=" ? check && result.indexOf( check ) > -1 : |
|
| 1667 | operator === "$=" ? check && result.slice( -check.length ) === check : |
|
| 1668 | operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : |
|
| 1669 | operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : |
|
| 1670 | false; |
|
| 1671 | }; |
|
| 1672 | }, |
|
| 1673 | ||
| 1674 | "CHILD": function( type, what, argument, first, last ) { |
|
| 1675 | var simple = type.slice( 0, 3 ) !== "nth", |
|
| 1676 | forward = type.slice( -4 ) !== "last", |
|
| 1677 | ofType = what === "of-type"; |
|
| 1678 | ||
| 1679 | return first === 1 && last === 0 ? |
|
| 1680 | ||
| 1681 | // Shortcut for :nth-*(n) |
|
| 1682 | function( elem ) { |
|
| 1683 | return !!elem.parentNode; |
|
| 1684 | } : |
|
| 1685 | ||
| 1686 | function( elem, context, xml ) { |
|
| 1687 | var cache, uniqueCache, outerCache, node, nodeIndex, start, |
|
| 1688 | dir = simple !== forward ? "nextSibling" : "previousSibling", |
|
| 1689 | parent = elem.parentNode, |
|
| 1690 | name = ofType && elem.nodeName.toLowerCase(), |
|
| 1691 | useCache = !xml && !ofType, |
|
| 1692 | diff = false; |
|
| 1693 | ||
| 1694 | if ( parent ) { |
|
| 1695 | ||
| 1696 | // :(first|last|only)-(child|of-type) |
|
| 1697 | if ( simple ) { |
|
| 1698 | while ( dir ) { |
|
| 1699 | node = elem; |
|
| 1700 | while ( (node = node[ dir ]) ) { |
|
| 1701 | if ( ofType ? |
|
| 1702 | node.nodeName.toLowerCase() === name : |
|
| 1703 | node.nodeType === 1 ) { |
|
| 1704 | ||
| 1705 | return false; |
|
| 1706 | } |
|
| 1707 | } |
|
| 1708 | // Reverse direction for :only-* (if we haven't yet done so) |
|
| 1709 | start = dir = type === "only" && !start && "nextSibling"; |
|
| 1710 | } |
|
| 1711 | return true; |
|
| 1712 | } |
|
| 1713 | ||
| 1714 | start = [ forward ? parent.firstChild : parent.lastChild ]; |
|
| 1715 | ||
| 1716 | // non-xml :nth-child(...) stores cache data on `parent` |
|
| 1717 | if ( forward && useCache ) { |
|
| 1718 | ||
| 1719 | // Seek `elem` from a previously-cached index |
|
| 1720 | ||
| 1721 | // ...in a gzip-friendly way |
|
| 1722 | node = parent; |
|
| 1723 | outerCache = node[ expando ] || (node[ expando ] = {}); |
|
| 1724 | ||
| 1725 | // Support: IE <9 only |
|
| 1726 | // Defend against cloned attroperties (jQuery gh-1709) |
|
| 1727 | uniqueCache = outerCache[ node.uniqueID ] || |
|
| 1728 | (outerCache[ node.uniqueID ] = {}); |
|
| 1729 | ||
| 1730 | cache = uniqueCache[ type ] || []; |
|
| 1731 | nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; |
|
| 1732 | diff = nodeIndex && cache[ 2 ]; |
|
| 1733 | node = nodeIndex && parent.childNodes[ nodeIndex ]; |
|
| 1734 | ||
| 1735 | while ( (node = ++nodeIndex && node && node[ dir ] || |
|
| 1736 | ||
| 1737 | // Fallback to seeking `elem` from the start |
|
| 1738 | (diff = nodeIndex = 0) || start.pop()) ) { |
|
| 1739 | ||
| 1740 | // When found, cache indexes on `parent` and break |
|
| 1741 | if ( node.nodeType === 1 && ++diff && node === elem ) { |
|
| 1742 | uniqueCache[ type ] = [ dirruns, nodeIndex, diff ]; |
|
| 1743 | break; |
|
| 1744 | } |
|
| 1745 | } |
|
| 1746 | ||
| 1747 | } else { |
|
| 1748 | // Use previously-cached element index if available |
|
| 1749 | if ( useCache ) { |
|
| 1750 | // ...in a gzip-friendly way |
|
| 1751 | node = elem; |
|
| 1752 | outerCache = node[ expando ] || (node[ expando ] = {}); |
|
| 1753 | ||
| 1754 | // Support: IE <9 only |
|
| 1755 | // Defend against cloned attroperties (jQuery gh-1709) |
|
| 1756 | uniqueCache = outerCache[ node.uniqueID ] || |
|
| 1757 | (outerCache[ node.uniqueID ] = {}); |
|
| 1758 | ||
| 1759 | cache = uniqueCache[ type ] || []; |
|
| 1760 | nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; |
|
| 1761 | diff = nodeIndex; |
|
| 1762 | } |
|
| 1763 | ||
| 1764 | // xml :nth-child(...) |
|
| 1765 | // or :nth-last-child(...) or :nth(-last)?-of-type(...) |
|
| 1766 | if ( diff === false ) { |
|
| 1767 | // Use the same loop as above to seek `elem` from the start |
|
| 1768 | while ( (node = ++nodeIndex && node && node[ dir ] || |
|
| 1769 | (diff = nodeIndex = 0) || start.pop()) ) { |
|
| 1770 | ||
| 1771 | if ( ( ofType ? |
|
| 1772 | node.nodeName.toLowerCase() === name : |
|
| 1773 | node.nodeType === 1 ) && |
|
| 1774 | ++diff ) { |
|
| 1775 | ||
| 1776 | // Cache the index of each encountered element |
|
| 1777 | if ( useCache ) { |
|
| 1778 | outerCache = node[ expando ] || (node[ expando ] = {}); |
|
| 1779 | ||
| 1780 | // Support: IE <9 only |
|
| 1781 | // Defend against cloned attroperties (jQuery gh-1709) |
|
| 1782 | uniqueCache = outerCache[ node.uniqueID ] || |
|
| 1783 | (outerCache[ node.uniqueID ] = {}); |
|
| 1784 | ||
| 1785 | uniqueCache[ type ] = [ dirruns, diff ]; |
|
| 1786 | } |
|
| 1787 | ||
| 1788 | if ( node === elem ) { |
|
| 1789 | break; |
|
| 1790 | } |
|
| 1791 | } |
|
| 1792 | } |
|
| 1793 | } |
|
| 1794 | } |
|
| 1795 | ||
| 1796 | // Incorporate the offset, then check against cycle size |
|
| 1797 | diff -= last; |
|
| 1798 | return diff === first || ( diff % first === 0 && diff / first >= 0 ); |
|
| 1799 | } |
|
| 1800 | }; |
|
| 1801 | }, |
|
| 1802 | ||
| 1803 | "PSEUDO": function( pseudo, argument ) { |
|
| 1804 | // pseudo-class names are case-insensitive |
|
| 1805 | // http://www.w3.org/TR/selectors/#pseudo-classes |
|
| 1806 | // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters |
|
| 1807 | // Remember that setFilters inherits from pseudos |
|
| 1808 | var args, |
|
| 1809 | fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || |
|
| 1810 | Sizzle.error( "unsupported pseudo: " + pseudo ); |
|
| 1811 | ||
| 1812 | // The user may use createPseudo to indicate that |
|
| 1813 | // arguments are needed to create the filter function |
|
| 1814 | // just as Sizzle does |
|
| 1815 | if ( fn[ expando ] ) { |
|
| 1816 | return fn( argument ); |
|
| 1817 | } |
|
| 1818 | ||
| 1819 | // But maintain support for old signatures |
|
| 1820 | if ( fn.length > 1 ) { |
|
| 1821 | args = [ pseudo, pseudo, "", argument ]; |
|
| 1822 | return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? |
|
| 1823 | markFunction(function( seed, matches ) { |
|
| 1824 | var idx, |
|
| 1825 | matched = fn( seed, argument ), |
|
| 1826 | i = matched.length; |
|
| 1827 | while ( i-- ) { |
|
| 1828 | idx = indexOf( seed, matched[i] ); |
|
| 1829 | seed[ idx ] = !( matches[ idx ] = matched[i] ); |
|
| 1830 | } |
|
| 1831 | }) : |
|
| 1832 | function( elem ) { |
|
| 1833 | return fn( elem, 0, args ); |
|
| 1834 | }; |
|
| 1835 | } |
|
| 1836 | ||
| 1837 | return fn; |
|
| 1838 | } |
|
| 1839 | }, |
|
| 1840 | ||
| 1841 | pseudos: { |
|
| 1842 | // Potentially complex pseudos |
|
| 1843 | "not": markFunction(function( selector ) { |
|
| 1844 | // Trim the selector passed to compile |
|
| 1845 | // to avoid treating leading and trailing |
|
| 1846 | // spaces as combinators |
|
| 1847 | var input = [], |
|
| 1848 | results = [], |
|
| 1849 | matcher = compile( selector.replace( rtrim, "$1" ) ); |
|
| 1850 | ||
| 1851 | return matcher[ expando ] ? |
|
| 1852 | markFunction(function( seed, matches, context, xml ) { |
|
| 1853 | var elem, |
|
| 1854 | unmatched = matcher( seed, null, xml, [] ), |
|
| 1855 | i = seed.length; |
|
| 1856 | ||
| 1857 | // Match elements unmatched by `matcher` |
|
| 1858 | while ( i-- ) { |
|
| 1859 | if ( (elem = unmatched[i]) ) { |
|
| 1860 | seed[i] = !(matches[i] = elem); |
|
| 1861 | } |
|
| 1862 | } |
|
| 1863 | }) : |
|
| 1864 | function( elem, context, xml ) { |
|
| 1865 | input[0] = elem; |
|
| 1866 | matcher( input, null, xml, results ); |
|
| 1867 | // Don't keep the element (issue #299) |
|
| 1868 | input[0] = null; |
|
| 1869 | return !results.pop(); |
|
| 1870 | }; |
|
| 1871 | }), |
|
| 1872 | ||
| 1873 | "has": markFunction(function( selector ) { |
|
| 1874 | return function( elem ) { |
|
| 1875 | return Sizzle( selector, elem ).length > 0; |
|
| 1876 | }; |
|
| 1877 | }), |
|
| 1878 | ||
| 1879 | "contains": markFunction(function( text ) { |
|
| 1880 | text = text.replace( runescape, funescape ); |
|
| 1881 | return function( elem ) { |
|
| 1882 | return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; |
|
| 1883 | }; |
|
| 1884 | }), |
|
| 1885 | ||
| 1886 | // "Whether an element is represented by a :lang() selector |
|
| 1887 | // is based solely on the element's language value |
|
| 1888 | // being equal to the identifier C, |
|
| 1889 | // or beginning with the identifier C immediately followed by "-". |
|
| 1890 | // The matching of C against the element's language value is performed case-insensitively. |
|
| 1891 | // The identifier C does not have to be a valid language name." |
|
| 1892 | // http://www.w3.org/TR/selectors/#lang-pseudo |
|
| 1893 | "lang": markFunction( function( lang ) { |
|
| 1894 | // lang value must be a valid identifier |
|
| 1895 | if ( !ridentifier.test(lang || "") ) { |
|
| 1896 | Sizzle.error( "unsupported lang: " + lang ); |
|
| 1897 | } |
|
| 1898 | lang = lang.replace( runescape, funescape ).toLowerCase(); |
|
| 1899 | return function( elem ) { |
|
| 1900 | var elemLang; |
|
| 1901 | do { |
|
| 1902 | if ( (elemLang = documentIsHTML ? |
|
| 1903 | elem.lang : |
|
| 1904 | elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { |
|
| 1905 | ||
| 1906 | elemLang = elemLang.toLowerCase(); |
|
| 1907 | return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; |
|
| 1908 | } |
|
| 1909 | } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); |
|
| 1910 | return false; |
|
| 1911 | }; |
|
| 1912 | }), |
|
| 1913 | ||
| 1914 | // Miscellaneous |
|
| 1915 | "target": function( elem ) { |
|
| 1916 | var hash = window.location && window.location.hash; |
|
| 1917 | return hash && hash.slice( 1 ) === elem.id; |
|
| 1918 | }, |
|
| 1919 | ||
| 1920 | "root": function( elem ) { |
|
| 1921 | return elem === docElem; |
|
| 1922 | }, |
|
| 1923 | ||
| 1924 | "focus": function( elem ) { |
|
| 1925 | return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); |
|
| 1926 | }, |
|
| 1927 | ||
| 1928 | // Boolean properties |
|
| 1929 | "enabled": function( elem ) { |
|
| 1930 | return elem.disabled === false; |
|
| 1931 | }, |
|
| 1932 | ||
| 1933 | "disabled": function( elem ) { |
|
| 1934 | return elem.disabled === true; |
|
| 1935 | }, |
|
| 1936 | ||
| 1937 | "checked": function( elem ) { |
|
| 1938 | // In CSS3, :checked should return both checked and selected elements |
|
| 1939 | // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked |
|
| 1940 | var nodeName = elem.nodeName.toLowerCase(); |
|
| 1941 | return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); |
|
| 1942 | }, |
|
| 1943 | ||
| 1944 | "selected": function( elem ) { |
|
| 1945 | // Accessing this property makes selected-by-default |
|
| 1946 | // options in Safari work properly |
|
| 1947 | if ( elem.parentNode ) { |
|
| 1948 | elem.parentNode.selectedIndex; |
|
| 1949 | } |
|
| 1950 | ||
| 1951 | return elem.selected === true; |
|
| 1952 | }, |
|
| 1953 | ||
| 1954 | // Contents |
|
| 1955 | "empty": function( elem ) { |
|
| 1956 | // http://www.w3.org/TR/selectors/#empty-pseudo |
|
| 1957 | // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), |
|
| 1958 | // but not by others (comment: 8; processing instruction: 7; etc.) |
|
| 1959 | // nodeType < 6 works because attributes (2) do not appear as children |
|
| 1960 | for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { |
|
| 1961 | if ( elem.nodeType < 6 ) { |
|
| 1962 | return false; |
|
| 1963 | } |
|
| 1964 | } |
|
| 1965 | return true; |
|
| 1966 | }, |
|
| 1967 | ||
| 1968 | "parent": function( elem ) { |
|
| 1969 | return !Expr.pseudos["empty"]( elem ); |
|
| 1970 | }, |
|
| 1971 | ||
| 1972 | // Element/input types |
|
| 1973 | "header": function( elem ) { |
|
| 1974 | return rheader.test( elem.nodeName ); |
|
| 1975 | }, |
|
| 1976 | ||
| 1977 | "input": function( elem ) { |
|
| 1978 | return rinputs.test( elem.nodeName ); |
|
| 1979 | }, |
|
| 1980 | ||
| 1981 | "button": function( elem ) { |
|
| 1982 | var name = elem.nodeName.toLowerCase(); |
|
| 1983 | return name === "input" && elem.type === "button" || name === "button"; |
|
| 1984 | }, |
|
| 1985 | ||
| 1986 | "text": function( elem ) { |
|
| 1987 | var attr; |
|
| 1988 | return elem.nodeName.toLowerCase() === "input" && |
|
| 1989 | elem.type === "text" && |
|
| 1990 | ||
| 1991 | // Support: IE<8 |
|
| 1992 | // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" |
|
| 1993 | ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); |
|
| 1994 | }, |
|
| 1995 | ||
| 1996 | // Position-in-collection |
|
| 1997 | "first": createPositionalPseudo(function() { |
|
| 1998 | return [ 0 ]; |
|
| 1999 | }), |
|
| 2000 | ||
| 2001 | "last": createPositionalPseudo(function( matchIndexes, length ) { |
|
| 2002 | return [ length - 1 ]; |
|
| 2003 | }), |
|
| 2004 | ||
| 2005 | "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { |
|
| 2006 | return [ argument < 0 ? argument + length : argument ]; |
|
| 2007 | }), |
|
| 2008 | ||
| 2009 | "even": createPositionalPseudo(function( matchIndexes, length ) { |
|
| 2010 | var i = 0; |
|
| 2011 | for ( ; i < length; i += 2 ) { |
|
| 2012 | matchIndexes.push( i ); |
|
| 2013 | } |
|
| 2014 | return matchIndexes; |
|
| 2015 | }), |
|
| 2016 | ||
| 2017 | "odd": createPositionalPseudo(function( matchIndexes, length ) { |
|
| 2018 | var i = 1; |
|
| 2019 | for ( ; i < length; i += 2 ) { |
|
| 2020 | matchIndexes.push( i ); |
|
| 2021 | } |
|
| 2022 | return matchIndexes; |
|
| 2023 | }), |
|
| 2024 | ||
| 2025 | "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { |
|
| 2026 | var i = argument < 0 ? argument + length : argument; |
|
| 2027 | for ( ; --i >= 0; ) { |
|
| 2028 | matchIndexes.push( i ); |
|
| 2029 | } |
|
| 2030 | return matchIndexes; |
|
| 2031 | }), |
|
| 2032 | ||
| 2033 | "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { |
|
| 2034 | var i = argument < 0 ? argument + length : argument; |
|
| 2035 | for ( ; ++i < length; ) { |
|
| 2036 | matchIndexes.push( i ); |
|
| 2037 | } |
|
| 2038 | return matchIndexes; |
|
| 2039 | }) |
|
| 2040 | } |
|
| 2041 | }; |
|
| 2042 | ||
| 2043 | Expr.pseudos["nth"] = Expr.pseudos["eq"]; |
|
| 2044 | ||
| 2045 | // Add button/input type pseudos |
|
| 2046 | for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { |
|
| 2047 | Expr.pseudos[ i ] = createInputPseudo( i ); |
|
| 2048 | } |
|
| 2049 | for ( i in { submit: true, reset: true } ) { |
|
| 2050 | Expr.pseudos[ i ] = createButtonPseudo( i ); |
|
| 2051 | } |
|
| 2052 | ||
| 2053 | // Easy API for creating new setFilters |
|
| 2054 | function setFilters() {} |
|
| 2055 | setFilters.prototype = Expr.filters = Expr.pseudos; |
|
| 2056 | Expr.setFilters = new setFilters(); |
|
| 2057 | ||
| 2058 | tokenize = Sizzle.tokenize = function( selector, parseOnly ) { |
|
| 2059 | var matched, match, tokens, type, |
|
| 2060 | soFar, groups, preFilters, |
|
| 2061 | cached = tokenCache[ selector + " " ]; |
|
| 2062 | ||
| 2063 | if ( cached ) { |
|
| 2064 | return parseOnly ? 0 : cached.slice( 0 ); |
|
| 2065 | } |
|
| 2066 | ||
| 2067 | soFar = selector; |
|
| 2068 | groups = []; |
|
| 2069 | preFilters = Expr.preFilter; |
|
| 2070 | ||
| 2071 | while ( soFar ) { |
|
| 2072 | ||
| 2073 | // Comma and first run |
|
| 2074 | if ( !matched || (match = rcomma.exec( soFar )) ) { |
|
| 2075 | if ( match ) { |
|
| 2076 | // Don't consume trailing commas as valid |
|
| 2077 | soFar = soFar.slice( match[0].length ) || soFar; |
|
| 2078 | } |
|
| 2079 | groups.push( (tokens = []) ); |
|
| 2080 | } |
|
| 2081 | ||
| 2082 | matched = false; |
|
| 2083 | ||
| 2084 | // Combinators |
|
| 2085 | if ( (match = rcombinators.exec( soFar )) ) { |
|
| 2086 | matched = match.shift(); |
|
| 2087 | tokens.push({ |
|
| 2088 | value: matched, |
|
| 2089 | // Cast descendant combinators to space |
|
| 2090 | type: match[0].replace( rtrim, " " ) |
|
| 2091 | }); |
|
| 2092 | soFar = soFar.slice( matched.length ); |
|
| 2093 | } |
|
| 2094 | ||
| 2095 | // Filters |
|
| 2096 | for ( type in Expr.filter ) { |
|
| 2097 | if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || |
|
| 2098 | (match = preFilters[ type ]( match ))) ) { |
|
| 2099 | matched = match.shift(); |
|
| 2100 | tokens.push({ |
|
| 2101 | value: matched, |
|
| 2102 | type: type, |
|
| 2103 | matches: match |
|
| 2104 | }); |
|
| 2105 | soFar = soFar.slice( matched.length ); |
|
| 2106 | } |
|
| 2107 | } |
|
| 2108 | ||
| 2109 | if ( !matched ) { |
|
| 2110 | break; |
|
| 2111 | } |
|
| 2112 | } |
|
| 2113 | ||
| 2114 | // Return the length of the invalid excess |
|
| 2115 | // if we're just parsing |
|
| 2116 | // Otherwise, throw an error or return tokens |
|
| 2117 | return parseOnly ? |
|
| 2118 | soFar.length : |
|
| 2119 | soFar ? |
|
| 2120 | Sizzle.error( selector ) : |
|
| 2121 | // Cache the tokens |
|
| 2122 | tokenCache( selector, groups ).slice( 0 ); |
|
| 2123 | }; |
|
| 2124 | ||
| 2125 | function toSelector( tokens ) { |
|
| 2126 | var i = 0, |
|
| 2127 | len = tokens.length, |
|
| 2128 | selector = ""; |
|
| 2129 | for ( ; i < len; i++ ) { |
|
| 2130 | selector += tokens[i].value; |
|
| 2131 | } |
|
| 2132 | return selector; |
|
| 2133 | } |
|
| 2134 | ||
| 2135 | function addCombinator( matcher, combinator, base ) { |
|
| 2136 | var dir = combinator.dir, |
|
| 2137 | checkNonElements = base && dir === "parentNode", |
|
| 2138 | doneName = done++; |
|
| 2139 | ||
| 2140 | return combinator.first ? |
|
| 2141 | // Check against closest ancestor/preceding element |
|
| 2142 | function( elem, context, xml ) { |
|
| 2143 | while ( (elem = elem[ dir ]) ) { |
|
| 2144 | if ( elem.nodeType === 1 || checkNonElements ) { |
|
| 2145 | return matcher( elem, context, xml ); |
|
| 2146 | } |
|
| 2147 | } |
|
| 2148 | } : |
|
| 2149 | ||
| 2150 | // Check against all ancestor/preceding elements |
|
| 2151 | function( elem, context, xml ) { |
|
| 2152 | var oldCache, uniqueCache, outerCache, |
|
| 2153 | newCache = [ dirruns, doneName ]; |
|
| 2154 | ||
| 2155 | // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching |
|
| 2156 | if ( xml ) { |
|
| 2157 | while ( (elem = elem[ dir ]) ) { |
|
| 2158 | if ( elem.nodeType === 1 || checkNonElements ) { |
|
| 2159 | if ( matcher( elem, context, xml ) ) { |
|
| 2160 | return true; |
|
| 2161 | } |
|
| 2162 | } |
|
| 2163 | } |
|
| 2164 | } else { |
|
| 2165 | while ( (elem = elem[ dir ]) ) { |
|
| 2166 | if ( elem.nodeType === 1 || checkNonElements ) { |
|
| 2167 | outerCache = elem[ expando ] || (elem[ expando ] = {}); |
|
| 2168 | ||
| 2169 | // Support: IE <9 only |
|
| 2170 | // Defend against cloned attroperties (jQuery gh-1709) |
|
| 2171 | uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {}); |
|
| 2172 | ||
| 2173 | if ( (oldCache = uniqueCache[ dir ]) && |
|
| 2174 | oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { |
|
| 2175 | ||
| 2176 | // Assign to newCache so results back-propagate to previous elements |
|
| 2177 | return (newCache[ 2 ] = oldCache[ 2 ]); |
|
| 2178 | } else { |
|
| 2179 | // Reuse newcache so results back-propagate to previous elements |
|
| 2180 | uniqueCache[ dir ] = newCache; |
|
| 2181 | ||
| 2182 | // A match means we're done; a fail means we have to keep checking |
|
| 2183 | if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { |
|
| 2184 | return true; |
|
| 2185 | } |
|
| 2186 | } |
|
| 2187 | } |
|
| 2188 | } |
|
| 2189 | } |
|
| 2190 | }; |
|
| 2191 | } |
|
| 2192 | ||
| 2193 | function elementMatcher( matchers ) { |
|
| 2194 | return matchers.length > 1 ? |
|
| 2195 | function( elem, context, xml ) { |
|
| 2196 | var i = matchers.length; |
|
| 2197 | while ( i-- ) { |
|
| 2198 | if ( !matchers[i]( elem, context, xml ) ) { |
|
| 2199 | return false; |
|
| 2200 | } |
|
| 2201 | } |
|
| 2202 | return true; |
|
| 2203 | } : |
|
| 2204 | matchers[0]; |
|
| 2205 | } |
|
| 2206 | ||
| 2207 | function multipleContexts( selector, contexts, results ) { |
|
| 2208 | var i = 0, |
|
| 2209 | len = contexts.length; |
|
| 2210 | for ( ; i < len; i++ ) { |
|
| 2211 | Sizzle( selector, contexts[i], results ); |
|
| 2212 | } |
|
| 2213 | return results; |
|
| 2214 | } |
|
| 2215 | ||
| 2216 | function condense( unmatched, map, filter, context, xml ) { |
|
| 2217 | var elem, |
|
| 2218 | newUnmatched = [], |
|
| 2219 | i = 0, |
|
| 2220 | len = unmatched.length, |
|
| 2221 | mapped = map != null; |
|
| 2222 | ||
| 2223 | for ( ; i < len; i++ ) { |
|
| 2224 | if ( (elem = unmatched[i]) ) { |
|
| 2225 | if ( !filter || filter( elem, context, xml ) ) { |
|
| 2226 | newUnmatched.push( elem ); |
|
| 2227 | if ( mapped ) { |
|
| 2228 | map.push( i ); |
|
| 2229 | } |
|
| 2230 | } |
|
| 2231 | } |
|
| 2232 | } |
|
| 2233 | ||
| 2234 | return newUnmatched; |
|
| 2235 | } |
|
| 2236 | ||
| 2237 | function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { |
|
| 2238 | if ( postFilter && !postFilter[ expando ] ) { |
|
| 2239 | postFilter = setMatcher( postFilter ); |
|
| 2240 | } |
|
| 2241 | if ( postFinder && !postFinder[ expando ] ) { |
|
| 2242 | postFinder = setMatcher( postFinder, postSelector ); |
|
| 2243 | } |
|
| 2244 | return markFunction(function( seed, results, context, xml ) { |
|
| 2245 | var temp, i, elem, |
|
| 2246 | preMap = [], |
|
| 2247 | postMap = [], |
|
| 2248 | preexisting = results.length, |
|
| 2249 | ||
| 2250 | // Get initial elements from seed or context |
|
| 2251 | elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), |
|
| 2252 | ||
| 2253 | // Prefilter to get matcher input, preserving a map for seed-results synchronization |
|
| 2254 | matcherIn = preFilter && ( seed || !selector ) ? |
|
| 2255 | condense( elems, preMap, preFilter, context, xml ) : |
|
| 2256 | elems, |
|
| 2257 | ||
| 2258 | matcherOut = matcher ? |
|
| 2259 | // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, |
|
| 2260 | postFinder || ( seed ? preFilter : preexisting || postFilter ) ? |
|
| 2261 | ||
| 2262 | // ...intermediate processing is necessary |
|
| 2263 | [] : |
|
| 2264 | ||
| 2265 | // ...otherwise use results directly |
|
| 2266 | results : |
|
| 2267 | matcherIn; |
|
| 2268 | ||
| 2269 | // Find primary matches |
|
| 2270 | if ( matcher ) { |
|
| 2271 | matcher( matcherIn, matcherOut, context, xml ); |
|
| 2272 | } |
|
| 2273 | ||
| 2274 | // Apply postFilter |
|
| 2275 | if ( postFilter ) { |
|
| 2276 | temp = condense( matcherOut, postMap ); |
|
| 2277 | postFilter( temp, [], context, xml ); |
|
| 2278 | ||
| 2279 | // Un-match failing elements by moving them back to matcherIn |
|
| 2280 | i = temp.length; |
|
| 2281 | while ( i-- ) { |
|
| 2282 | if ( (elem = temp[i]) ) { |
|
| 2283 | matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); |
|
| 2284 | } |
|
| 2285 | } |
|
| 2286 | } |
|
| 2287 | ||
| 2288 | if ( seed ) { |
|
| 2289 | if ( postFinder || preFilter ) { |
|
| 2290 | if ( postFinder ) { |
|
| 2291 | // Get the final matcherOut by condensing this intermediate into postFinder contexts |
|
| 2292 | temp = []; |
|
| 2293 | i = matcherOut.length; |
|
| 2294 | while ( i-- ) { |
|
| 2295 | if ( (elem = matcherOut[i]) ) { |
|
| 2296 | // Restore matcherIn since elem is not yet a final match |
|
| 2297 | temp.push( (matcherIn[i] = elem) ); |
|
| 2298 | } |
|
| 2299 | } |
|
| 2300 | postFinder( null, (matcherOut = []), temp, xml ); |
|
| 2301 | } |
|
| 2302 | ||
| 2303 | // Move matched elements from seed to results to keep them synchronized |
|
| 2304 | i = matcherOut.length; |
|
| 2305 | while ( i-- ) { |
|
| 2306 | if ( (elem = matcherOut[i]) && |
|
| 2307 | (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) { |
|
| 2308 | ||
| 2309 | seed[temp] = !(results[temp] = elem); |
|
| 2310 | } |
|
| 2311 | } |
|
| 2312 | } |
|
| 2313 | ||
| 2314 | // Add elements to results, through postFinder if defined |
|
| 2315 | } else { |
|
| 2316 | matcherOut = condense( |
|
| 2317 | matcherOut === results ? |
|
| 2318 | matcherOut.splice( preexisting, matcherOut.length ) : |
|
| 2319 | matcherOut |
|
| 2320 | ); |
|
| 2321 | if ( postFinder ) { |
|
| 2322 | postFinder( null, results, matcherOut, xml ); |
|
| 2323 | } else { |
|
| 2324 | push.apply( results, matcherOut ); |
|
| 2325 | } |
|
| 2326 | } |
|
| 2327 | }); |
|
| 2328 | } |
|
| 2329 | ||
| 2330 | function matcherFromTokens( tokens ) { |
|
| 2331 | var checkContext, matcher, j, |
|
| 2332 | len = tokens.length, |
|
| 2333 | leadingRelative = Expr.relative[ tokens[0].type ], |
|
| 2334 | implicitRelative = leadingRelative || Expr.relative[" "], |
|
| 2335 | i = leadingRelative ? 1 : 0, |
|
| 2336 | ||
| 2337 | // The foundational matcher ensures that elements are reachable from top-level context(s) |
|
| 2338 | matchContext = addCombinator( function( elem ) { |
|
| 2339 | return elem === checkContext; |
|
| 2340 | }, implicitRelative, true ), |
|
| 2341 | matchAnyContext = addCombinator( function( elem ) { |
|
| 2342 | return indexOf( checkContext, elem ) > -1; |
|
| 2343 | }, implicitRelative, true ), |
|
| 2344 | matchers = [ function( elem, context, xml ) { |
|
| 2345 | var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( |
|
| 2346 | (checkContext = context).nodeType ? |
|
| 2347 | matchContext( elem, context, xml ) : |
|
| 2348 | matchAnyContext( elem, context, xml ) ); |
|
| 2349 | // Avoid hanging onto element (issue #299) |
|
| 2350 | checkContext = null; |
|
| 2351 | return ret; |
|
| 2352 | } ]; |
|
| 2353 | ||
| 2354 | for ( ; i < len; i++ ) { |
|
| 2355 | if ( (matcher = Expr.relative[ tokens[i].type ]) ) { |
|
| 2356 | matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; |
|
| 2357 | } else { |
|
| 2358 | matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); |
|
| 2359 | ||
| 2360 | // Return special upon seeing a positional matcher |
|
| 2361 | if ( matcher[ expando ] ) { |
|
| 2362 | // Find the next relative operator (if any) for proper handling |
|
| 2363 | j = ++i; |
|
| 2364 | for ( ; j < len; j++ ) { |
|
| 2365 | if ( Expr.relative[ tokens[j].type ] ) { |
|
| 2366 | break; |
|
| 2367 | } |
|
| 2368 | } |
|
| 2369 | return setMatcher( |
|
| 2370 | i > 1 && elementMatcher( matchers ), |
|
| 2371 | i > 1 && toSelector( |
|
| 2372 | // If the preceding token was a descendant combinator, insert an implicit any-element `*` |
|
| 2373 | tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) |
|
| 2374 | ).replace( rtrim, "$1" ), |
|
| 2375 | matcher, |
|
| 2376 | i < j && matcherFromTokens( tokens.slice( i, j ) ), |
|
| 2377 | j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), |
|
| 2378 | j < len && toSelector( tokens ) |
|
| 2379 | ); |
|
| 2380 | } |
|
| 2381 | matchers.push( matcher ); |
|
| 2382 | } |
|
| 2383 | } |
|
| 2384 | ||
| 2385 | return elementMatcher( matchers ); |
|
| 2386 | } |
|
| 2387 | ||
| 2388 | function matcherFromGroupMatchers( elementMatchers, setMatchers ) { |
|
| 2389 | var bySet = setMatchers.length > 0, |
|
| 2390 | byElement = elementMatchers.length > 0, |
|
| 2391 | superMatcher = function( seed, context, xml, results, outermost ) { |
|
| 2392 | var elem, j, matcher, |
|
| 2393 | matchedCount = 0, |
|
| 2394 | i = "0", |
|
| 2395 | unmatched = seed && [], |
|
| 2396 | setMatched = [], |
|
| 2397 | contextBackup = outermostContext, |
|
| 2398 | // We must always have either seed elements or outermost context |
|
| 2399 | elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), |
|
| 2400 | // Use integer dirruns iff this is the outermost matcher |
|
| 2401 | dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), |
|
| 2402 | len = elems.length; |
|
| 2403 | ||
| 2404 | if ( outermost ) { |
|
| 2405 | outermostContext = context === document || context || outermost; |
|
| 2406 | } |
|
| 2407 | ||
| 2408 | // Add elements passing elementMatchers directly to results |
|
| 2409 | // Support: IE<9, Safari |
|
| 2410 | // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id |
|
| 2411 | for ( ; i !== len && (elem = elems[i]) != null; i++ ) { |
|
| 2412 | if ( byElement && elem ) { |
|
| 2413 | j = 0; |
|
| 2414 | if ( !context && elem.ownerDocument !== document ) { |
|
| 2415 | setDocument( elem ); |
|
| 2416 | xml = !documentIsHTML; |
|
| 2417 | } |
|
| 2418 | while ( (matcher = elementMatchers[j++]) ) { |
|
| 2419 | if ( matcher( elem, context || document, xml) ) { |
|
| 2420 | results.push( elem ); |
|
| 2421 | break; |
|
| 2422 | } |
|
| 2423 | } |
|
| 2424 | if ( outermost ) { |
|
| 2425 | dirruns = dirrunsUnique; |
|
| 2426 | } |
|
| 2427 | } |
|
| 2428 | ||
| 2429 | // Track unmatched elements for set filters |
|
| 2430 | if ( bySet ) { |
|
| 2431 | // They will have gone through all possible matchers |
|
| 2432 | if ( (elem = !matcher && elem) ) { |
|
| 2433 | matchedCount--; |
|
| 2434 | } |
|
| 2435 | ||
| 2436 | // Lengthen the array for every element, matched or not |
|
| 2437 | if ( seed ) { |
|
| 2438 | unmatched.push( elem ); |
|
| 2439 | } |
|
| 2440 | } |
|
| 2441 | } |
|
| 2442 | ||
| 2443 | // `i` is now the count of elements visited above, and adding it to `matchedCount` |
|
| 2444 | // makes the latter nonnegative. |
|
| 2445 | matchedCount += i; |
|
| 2446 | ||
| 2447 | // Apply set filters to unmatched elements |
|
| 2448 | // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` |
|
| 2449 | // equals `i`), unless we didn't visit _any_ elements in the above loop because we have |
|
| 2450 | // no element matchers and no seed. |
|
| 2451 | // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that |
|
| 2452 | // case, which will result in a "00" `matchedCount` that differs from `i` but is also |
|
| 2453 | // numerically zero. |
|
| 2454 | if ( bySet && i !== matchedCount ) { |
|
| 2455 | j = 0; |
|
| 2456 | while ( (matcher = setMatchers[j++]) ) { |
|
| 2457 | matcher( unmatched, setMatched, context, xml ); |
|
| 2458 | } |
|
| 2459 | ||
| 2460 | if ( seed ) { |
|
| 2461 | // Reintegrate element matches to eliminate the need for sorting |
|
| 2462 | if ( matchedCount > 0 ) { |
|
| 2463 | while ( i-- ) { |
|
| 2464 | if ( !(unmatched[i] || setMatched[i]) ) { |
|
| 2465 | setMatched[i] = pop.call( results ); |
|
| 2466 | } |
|
| 2467 | } |
|
| 2468 | } |
|
| 2469 | ||
| 2470 | // Discard index placeholder values to get only actual matches |
|
| 2471 | setMatched = condense( setMatched ); |
|
| 2472 | } |
|
| 2473 | ||
| 2474 | // Add matches to results |
|
| 2475 | push.apply( results, setMatched ); |
|
| 2476 | ||
| 2477 | // Seedless set matches succeeding multiple successful matchers stipulate sorting |
|
| 2478 | if ( outermost && !seed && setMatched.length > 0 && |
|
| 2479 | ( matchedCount + setMatchers.length ) > 1 ) { |
|
| 2480 | ||
| 2481 | Sizzle.uniqueSort( results ); |
|
| 2482 | } |
|
| 2483 | } |
|
| 2484 | ||
| 2485 | // Override manipulation of globals by nested matchers |
|
| 2486 | if ( outermost ) { |
|
| 2487 | dirruns = dirrunsUnique; |
|
| 2488 | outermostContext = contextBackup; |
|
| 2489 | } |
|
| 2490 | ||
| 2491 | return unmatched; |
|
| 2492 | }; |
|
| 2493 | ||
| 2494 | return bySet ? |
|
| 2495 | markFunction( superMatcher ) : |
|
| 2496 | superMatcher; |
|
| 2497 | } |
|
| 2498 | ||
| 2499 | compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { |
|
| 2500 | var i, |
|
| 2501 | setMatchers = [], |
|
| 2502 | elementMatchers = [], |
|
| 2503 | cached = compilerCache[ selector + " " ]; |
|
| 2504 | ||
| 2505 | if ( !cached ) { |
|
| 2506 | // Generate a function of recursive functions that can be used to check each element |
|
| 2507 | if ( !match ) { |
|
| 2508 | match = tokenize( selector ); |
|
| 2509 | } |
|
| 2510 | i = match.length; |
|
| 2511 | while ( i-- ) { |
|
| 2512 | cached = matcherFromTokens( match[i] ); |
|
| 2513 | if ( cached[ expando ] ) { |
|
| 2514 | setMatchers.push( cached ); |
|
| 2515 | } else { |
|
| 2516 | elementMatchers.push( cached ); |
|
| 2517 | } |
|
| 2518 | } |
|
| 2519 | ||
| 2520 | // Cache the compiled function |
|
| 2521 | cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); |
|
| 2522 | ||
| 2523 | // Save selector and tokenization |
|
| 2524 | cached.selector = selector; |
|
| 2525 | } |
|
| 2526 | return cached; |
|
| 2527 | }; |
|
| 2528 | ||
| 2529 | /** |
|
| 2530 | * A low-level selection function that works with Sizzle's compiled |
|
| 2531 | * selector functions |
|
| 2532 | * @param {String|Function} selector A selector or a pre-compiled |
|
| 2533 | * selector function built with Sizzle.compile |
|
| 2534 | * @param {Element} context |
|
| 2535 | * @param {Array} [results] |
|
| 2536 | * @param {Array} [seed] A set of elements to match against |
|
| 2537 | */ |
|
| 2538 | select = Sizzle.select = function( selector, context, results, seed ) { |
|
| 2539 | var i, tokens, token, type, find, |
|
| 2540 | compiled = typeof selector === "function" && selector, |
|
| 2541 | match = !seed && tokenize( (selector = compiled.selector || selector) ); |
|
| 2542 | ||
| 2543 | results = results || []; |
|
| 2544 | ||
| 2545 | // Try to minimize operations if there is only one selector in the list and no seed |
|
| 2546 | // (the latter of which guarantees us context) |
|
| 2547 | if ( match.length === 1 ) { |
|
| 2548 | ||
| 2549 | // Reduce context if the leading compound selector is an ID |
|
| 2550 | tokens = match[0] = match[0].slice( 0 ); |
|
| 2551 | if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && |
|
| 2552 | support.getById && context.nodeType === 9 && documentIsHTML && |
|
| 2553 | Expr.relative[ tokens[1].type ] ) { |
|
| 2554 | ||
| 2555 | context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; |
|
| 2556 | if ( !context ) { |
|
| 2557 | return results; |
|
| 2558 | ||
| 2559 | // Precompiled matchers will still verify ancestry, so step up a level |
|
| 2560 | } else if ( compiled ) { |
|
| 2561 | context = context.parentNode; |
|
| 2562 | } |
|
| 2563 | ||
| 2564 | selector = selector.slice( tokens.shift().value.length ); |
|
| 2565 | } |
|
| 2566 | ||
| 2567 | // Fetch a seed set for right-to-left matching |
|
| 2568 | i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; |
|
| 2569 | while ( i-- ) { |
|
| 2570 | token = tokens[i]; |
|
| 2571 | ||
| 2572 | // Abort if we hit a combinator |
|
| 2573 | if ( Expr.relative[ (type = token.type) ] ) { |
|
| 2574 | break; |
|
| 2575 | } |
|
| 2576 | if ( (find = Expr.find[ type ]) ) { |
|
| 2577 | // Search, expanding context for leading sibling combinators |
|
| 2578 | if ( (seed = find( |
|
| 2579 | token.matches[0].replace( runescape, funescape ), |
|
| 2580 | rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context |
|
| 2581 | )) ) { |
|
| 2582 | ||
| 2583 | // If seed is empty or no tokens remain, we can return early |
|
| 2584 | tokens.splice( i, 1 ); |
|
| 2585 | selector = seed.length && toSelector( tokens ); |
|
| 2586 | if ( !selector ) { |
|
| 2587 | push.apply( results, seed ); |
|
| 2588 | return results; |
|
| 2589 | } |
|
| 2590 | ||
| 2591 | break; |
|
| 2592 | } |
|
| 2593 | } |
|
| 2594 | } |
|
| 2595 | } |
|
| 2596 | ||
| 2597 | // Compile and execute a filtering function if one is not provided |
|
| 2598 | // Provide `match` to avoid retokenization if we modified the selector above |
|
| 2599 | ( compiled || compile( selector, match ) )( |
|
| 2600 | seed, |
|
| 2601 | context, |
|
| 2602 | !documentIsHTML, |
|
| 2603 | results, |
|
| 2604 | !context || rsibling.test( selector ) && testContext( context.parentNode ) || context |
|
| 2605 | ); |
|
| 2606 | return results; |
|
| 2607 | }; |
|
| 2608 | ||
| 2609 | // One-time assignments |
|
| 2610 | ||
| 2611 | // Sort stability |
|
| 2612 | support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; |
|
| 2613 | ||
| 2614 | // Support: Chrome 14-35+ |
|
| 2615 | // Always assume duplicates if they aren't passed to the comparison function |
|
| 2616 | support.detectDuplicates = !!hasDuplicate; |
|
| 2617 | ||
| 2618 | // Initialize against the default document |
|
| 2619 | setDocument(); |
|
| 2620 | ||
| 2621 | // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) |
|
| 2622 | // Detached nodes confoundingly follow *each other* |
|
| 2623 | support.sortDetached = assert(function( div1 ) { |
|
| 2624 | // Should return 1, but returns 4 (following) |
|
| 2625 | return div1.compareDocumentPosition( document.createElement("div") ) & 1; |
|
| 2626 | }); |
|
| 2627 | ||
| 2628 | // Support: IE<8 |
|
| 2629 | // Prevent attribute/property "interpolation" |
|
| 2630 | // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx |
|
| 2631 | if ( !assert(function( div ) { |
|
| 2632 | div.innerHTML = "<a href='#'></a>"; |
|
| 2633 | return div.firstChild.getAttribute("href") === "#" ; |
|
| 2634 | }) ) { |
|
| 2635 | addHandle( "type|href|height|width", function( elem, name, isXML ) { |
|
| 2636 | if ( !isXML ) { |
|
| 2637 | return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); |
|
| 2638 | } |
|
| 2639 | }); |
|
| 2640 | } |
|
| 2641 | ||
| 2642 | // Support: IE<9 |
|
| 2643 | // Use defaultValue in place of getAttribute("value") |
|
| 2644 | if ( !support.attributes || !assert(function( div ) { |
|
| 2645 | div.innerHTML = "<input/>"; |
|
| 2646 | div.firstChild.setAttribute( "value", "" ); |
|
| 2647 | return div.firstChild.getAttribute( "value" ) === ""; |
|
| 2648 | }) ) { |
|
| 2649 | addHandle( "value", function( elem, name, isXML ) { |
|
| 2650 | if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { |
|
| 2651 | return elem.defaultValue; |
|
| 2652 | } |
|
| 2653 | }); |
|
| 2654 | } |
|
| 2655 | ||
| 2656 | // Support: IE<9 |
|
| 2657 | // Use getAttributeNode to fetch booleans when getAttribute lies |
|
| 2658 | if ( !assert(function( div ) { |
|
| 2659 | return div.getAttribute("disabled") == null; |
|
| 2660 | }) ) { |
|
| 2661 | addHandle( booleans, function( elem, name, isXML ) { |
|
| 2662 | var val; |
|
| 2663 | if ( !isXML ) { |
|
| 2664 | return elem[ name ] === true ? name.toLowerCase() : |
|
| 2665 | (val = elem.getAttributeNode( name )) && val.specified ? |
|
| 2666 | val.value : |
|
| 2667 | null; |
|
| 2668 | } |
|
| 2669 | }); |
|
| 2670 | } |
|
| 2671 | ||
| 2672 | return Sizzle; |
|
| 2673 | ||
| 2674 | })( window ); |
|
| 2675 | ||
| 2676 | ||
| 2677 | ||