* 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 )
| 940 | * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b |
| 941 | */ |
| 942 | function siblingCheck( a, b ) { |
| 943 | var cur = b && a, |
| 944 | diff = cur && a.nodeType === 1 && b.nodeType === 1 && |
| 945 | ( ~b.sourceIndex || MAX_NEGATIVE ) - |
| 946 | ( ~a.sourceIndex || MAX_NEGATIVE ); |
| 947 | |
| 948 | // Use IE sourceIndex if available on both nodes |
| 949 | if ( diff ) { |
| 950 | return diff; |
| 951 | } |
| 952 | |
| 953 | // Check if b follows a |
| 954 | if ( cur ) { |
| 955 | while ( (cur = cur.nextSibling) ) { |
| 956 | if ( cur === b ) { |
| 957 | return -1; |
| 958 | } |
| 959 | } |
| 960 | } |
| 961 | |
| 962 | return a ? 1 : -1; |
| 963 | } |
| 964 | |
| 965 | /** |
| 966 | * Returns a function to use in pseudos for input types |