* 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 )
| 1230 | * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b |
| 1231 | */ |
| 1232 | function siblingCheck( a, b ) { |
| 1233 | var cur = b && a, |
| 1234 | diff = cur && a.nodeType === 1 && b.nodeType === 1 && |
| 1235 | ( ~b.sourceIndex || MAX_NEGATIVE ) - |
| 1236 | ( ~a.sourceIndex || MAX_NEGATIVE ); |
| 1237 | |
| 1238 | // Use IE sourceIndex if available on both nodes |
| 1239 | if ( diff ) { |
| 1240 | return diff; |
| 1241 | } |
| 1242 | |
| 1243 | // Check if b follows a |
| 1244 | if ( cur ) { |
| 1245 | while ( (cur = cur.nextSibling) ) { |
| 1246 | if ( cur === b ) { |
| 1247 | return -1; |
| 1248 | } |
| 1249 | } |
| 1250 | } |
| 1251 | |
| 1252 | return a ? 1 : -1; |
| 1253 | } |
| 1254 | |
| 1255 | /** |
| 1256 | * Returns a function to use in pseudos for input types |