* 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 )
| 913 | * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b |
| 914 | */ |
| 915 | function siblingCheck( a, b ) { |
| 916 | var cur = b && a, |
| 917 | diff = cur && a.nodeType === 1 && b.nodeType === 1 && |
| 918 | ( ~b.sourceIndex || MAX_NEGATIVE ) - |
| 919 | ( ~a.sourceIndex || MAX_NEGATIVE ); |
| 920 | |
| 921 | // Use IE sourceIndex if available on both nodes |
| 922 | if ( diff ) { |
| 923 | return diff; |
| 924 | } |
| 925 | |
| 926 | // Check if b follows a |
| 927 | if ( cur ) { |
| 928 | while ( (cur = cur.nextSibling) ) { |
| 929 | if ( cur === b ) { |
| 930 | return -1; |
| 931 | } |
| 932 | } |
| 933 | } |
| 934 | |
| 935 | return a ? 1 : -1; |
| 936 | } |
| 937 | |
| 938 | /** |
| 939 | * Returns a function to use in pseudos for input types |