MCPcopy Create free account
hub / github.com/PrairieLearn/PrairieLearn / siblingCheck

Function siblingCheck

public/localscripts/calculationQuestion/jquery.js:1273–1294  ·  view source on GitHub ↗

* Checks document order of two siblings * @param {Element} a * @param {Element} b * @returns Returns -1 if a precedes b, 1 if a follows b

( a, b )

Source from the content-addressed store, hash-verified

1271 * @returns Returns -1 if a precedes b, 1 if a follows b
1272 */
1273function siblingCheck( a, b ) {
1274 var cur = b && a,
1275 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
1276 ( ~b.sourceIndex || MAX_NEGATIVE ) -
1277 ( ~a.sourceIndex || MAX_NEGATIVE );
1278
1279 // Use IE sourceIndex if available on both nodes
1280 if ( diff ) {
1281 return diff;
1282 }
1283
1284 // Check if b follows a
1285 if ( cur ) {
1286 while ( (cur = cur.nextSibling) ) {
1287 if ( cur === b ) {
1288 return -1;
1289 }
1290 }
1291 }
1292
1293 return a ? 1 : -1;
1294}
1295
1296/**
1297 * 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