* Checks document order of two siblings * @param {Element} a * @param {Element} b * @returns Returns -1 if a precedes b, 1 if a follows b
( a, b )
| 1271 | * @returns Returns -1 if a precedes b, 1 if a follows b |
| 1272 | */ |
| 1273 | function siblingCheck( a, b ) { |
| 1274 | var cur = b && a, |
| 1275 | diff = cur && a.nodeType === 1 && b.nodeType === 1 && |
| 1276 | ( ~b.sourceIndex || MAX_NEGATIVE ) - |
| 1277 | ( ~a.sourceIndex || MAX_NEGATIVE ); |
| 1278 | |
| 1279 | // Use IE sourceIndex if available on both nodes |
| 1280 | if ( diff ) { |
| 1281 | return diff; |
| 1282 | } |
| 1283 | |
| 1284 | // Check if b follows a |
| 1285 | if ( cur ) { |
| 1286 | while ( (cur = cur.nextSibling) ) { |
| 1287 | if ( cur === b ) { |
| 1288 | return -1; |
| 1289 | } |
| 1290 | } |
| 1291 | } |
| 1292 | |
| 1293 | return a ? 1 : -1; |
| 1294 | } |
| 1295 | |
| 1296 | /** |
| 1297 | * Returns a function to use in pseudos for input types |