* 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 )
| 955 | * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b |
| 956 | */ |
| 957 | function siblingCheck( a, b ) { |
| 958 | var cur = b && a, |
| 959 | diff = cur && a.nodeType === 1 && b.nodeType === 1 && |
| 960 | a.sourceIndex - b.sourceIndex; |
| 961 | |
| 962 | // Use IE sourceIndex if available on both nodes |
| 963 | if ( diff ) { |
| 964 | return diff; |
| 965 | } |
| 966 | |
| 967 | // Check if b follows a |
| 968 | if ( cur ) { |
| 969 | while ( (cur = cur.nextSibling) ) { |
| 970 | if ( cur === b ) { |
| 971 | return -1; |
| 972 | } |
| 973 | } |
| 974 | } |
| 975 | |
| 976 | return a ? 1 : -1; |
| 977 | } |
| 978 | |
| 979 | /** |
| 980 | * Returns a function to use in pseudos for input types |