* 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)
| 367 | */ |
| 368 | |
| 369 | function siblingCheck(a, b) { |
| 370 | var cur = b && a, |
| 371 | diff = cur && a.nodeType === 1 && b.nodeType === 1 && |
| 372 | (~b.sourceIndex || MAX_NEGATIVE) - |
| 373 | (~a.sourceIndex || MAX_NEGATIVE); |
| 374 | |
| 375 | // Use IE sourceIndex if available on both nodes |
| 376 | if (diff) { |
| 377 | return diff; |
| 378 | } |
| 379 | |
| 380 | // Check if b follows a |
| 381 | if (cur) { |
| 382 | while ((cur = cur.nextSibling)) { |
| 383 | if (cur === b) { |
| 384 | return -1; |
| 385 | } |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | return a ? 1 : -1; |
| 390 | } |
| 391 | |
| 392 | /** |
| 393 | * Returns a function to use in pseudos for input types |