MCPcopy Create free account
hub / github.com/TruthHun/BookStack / siblingCheck

Function siblingCheck

static/wangEditor/js/lib/jquery-2.2.1.js:937–958  ·  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

935 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
936 */
937function siblingCheck( a, b ) {
938 var cur = b && a,
939 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
940 ( ~b.sourceIndex || MAX_NEGATIVE ) -
941 ( ~a.sourceIndex || MAX_NEGATIVE );
942
943 // Use IE sourceIndex if available on both nodes
944 if ( diff ) {
945 return diff;
946 }
947
948 // Check if b follows a
949 if ( cur ) {
950 while ( (cur = cur.nextSibling) ) {
951 if ( cur === b ) {
952 return -1;
953 }
954 }
955 }
956
957 return a ? 1 : -1;
958}
959
960/**
961 * Returns a function to use in pseudos for input types

Callers 1

jquery-2.2.1.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected