MCPcopy
hub / github.com/perkeep/perkeep / siblingCheck

Function siblingCheck

app/publisher/jquery.js:942–963  ·  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

940 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
941 */
942function siblingCheck( a, b ) {
943 var cur = b && a,
944 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
945 ( ~b.sourceIndex || MAX_NEGATIVE ) -
946 ( ~a.sourceIndex || MAX_NEGATIVE );
947
948 // Use IE sourceIndex if available on both nodes
949 if ( diff ) {
950 return diff;
951 }
952
953 // Check if b follows a
954 if ( cur ) {
955 while ( (cur = cur.nextSibling) ) {
956 if ( cur === b ) {
957 return -1;
958 }
959 }
960 }
961
962 return a ? 1 : -1;
963}
964
965/**
966 * 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