* 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 )
| 973 | * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b |
| 974 | */ |
| 975 | function siblingCheck( a, b ) { |
| 976 | var cur = b && a, |
| 977 | diff = cur && a.nodeType === 1 && b.nodeType === 1 && |
| 978 | a.sourceIndex - b.sourceIndex; |
| 979 | |
| 980 | // Use IE sourceIndex if available on both nodes |
| 981 | if ( diff ) { |
| 982 | return diff; |
| 983 | } |
| 984 | |
| 985 | // Check if b follows a |
| 986 | if ( cur ) { |
| 987 | while ( ( cur = cur.nextSibling ) ) { |
| 988 | if ( cur === b ) { |
| 989 | return -1; |
| 990 | } |
| 991 | } |
| 992 | } |
| 993 | |
| 994 | return a ? 1 : -1; |
| 995 | } |
| 996 | |
| 997 | /** |
| 998 | * Returns a function to use in pseudos for input types |