MCPcopy Create free account
hub / github.com/JsAaron/jQuery / siblingCheck

Function siblingCheck

2.1.1/test/jquery-1.11.1.js:952–973  ·  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

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

Callers 1

jquery-1.11.1.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected