MCPcopy
hub / github.com/geekape/geek-navigation / siblingCheck

Function siblingCheck

js/jquery.js:957–977  ·  view source on GitHub ↗

* 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 )

Source from the content-addressed store, hash-verified

955 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
956 */
957function 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

Callers 1

jquery.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected