* Checks document order of two siblings * @param {Element} a * @param {Element} b * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
( a, b )
| 921 | * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b |
| 922 | */ |
| 923 | function siblingCheck( a, b ) { |
| 924 | var cur = b && a, |
| 925 | diff = cur && a.nodeType === 1 && b.nodeType === 1 && |
| 926 | ( ~b.sourceIndex || MAX_NEGATIVE ) - |
| 927 | ( ~a.sourceIndex || MAX_NEGATIVE ); |
| 928 | |
| 929 | // Use IE sourceIndex if available on both nodes |
| 930 | if ( diff ) { |
| 931 | return diff; |
| 932 | } |
| 933 | |
| 934 | // Check if b follows a |
| 935 | if ( cur ) { |
| 936 | while ( (cur = cur.nextSibling) ) { |
| 937 | if ( cur === b ) { |
| 938 | return -1; |
| 939 | } |
| 940 | } |
| 941 | } |
| 942 | |
| 943 | return a ? 1 : -1; |
| 944 | } |
| 945 | |
| 946 | /** |
| 947 | * Returns a function to use in pseudos for input types |