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