* 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 )
| 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 |