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

Function siblingCheck

2.1.1/test/jquery-2.1.1.js:915–936  ·  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

913 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
914 */
915function siblingCheck( a, b ) {
916 var cur = b && a,
917 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
918 ( ~b.sourceIndex || MAX_NEGATIVE ) -
919 ( ~a.sourceIndex || MAX_NEGATIVE );
920
921 // Use IE sourceIndex if available on both nodes
922 if ( diff ) {
923 return diff;
924 }
925
926 // Check if b follows a
927 if ( cur ) {
928 while ( (cur = cur.nextSibling) ) {
929 if ( cur === b ) {
930 return -1;
931 }
932 }
933 }
934
935 return a ? 1 : -1;
936}
937
938/**
939 * Returns a function to use in pseudos for input types

Callers 1

jquery-2.1.1.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected