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