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