ker/mod/interact.js
function indexOfDeepestElement (elements) {
        var dropzone,
            deepestZone = elements[0],
            index = deepestZone? 0: -1,
            parent,
            deepestZoneParents = [],
            dropzoneParents = [],
            child,
            i,
            n;

        for (i = 1; i < elements.length; i++) {
            dropzone = elements[i];

            // an element might belong to multiple selector dropzones
            if (!dropzone || dropzone === deepestZone) {
                continue;
            }

            if (!deepestZone) {
                deepestZone = dropzone;
                index = i;
                continue;
            }

            // check if the deepest or current are document.documentElement or document.rootElement
            // - if the current dropzone is, do nothing and continue
            if (dropzone.parentNode === dropzone.ownerDocument) {
                continue;
            }
            // - if deepest is, update with the current dropzone and continue to next
            else if (deepestZone.parentNode === dropzone.ownerDocument) {
                deepestZone = dropzone;
                index = i;
                continue;
            }

            if (!deepestZoneParents.length) {
                parent = deepestZone;
                while (parent.parentNode && parent.parentNode !== parent.ownerDocument) {
                    deepestZoneParents.unshift(parent);
                    parent = parent.parentNode;
                }
            }

            // if this element is an svg element and the current deepest is
            // an HTMLElement
            if (deepestZone instanceof HTMLElement
                && dropzone instanceof SVGElement
                && !(dropzone instanceof SVGSVGElement)) {

                if (dropzone === deepestZone.parentNode) {
                    continue;
                }

                parent = dropzone.ownerSVGElement;
            }
            else {
                parent = dropzone;
            }

            dropzoneParents = [];

            while (parent.parentNode !== parent.ownerDocument) {
                dropzoneParents.unshift(parent);
                parent = parent.parentNode;
            }

            n = 0;

            // get (position of last common ancestor) + 1
            while (dropzoneParents[n] && dropzoneParents[n] === deepestZoneParents[n]) {
                n++;
            }

            var parents = [
                dropzoneParents[n - 1],
                dropzoneParents[n],
                deepestZoneParents[n]
            ];

            child = parents[0].lastChild;

            while (child) {
                if (child === parents[1]) {
                    deepestZone = dropzone;
                    index = i;
                    deepestZoneParents = [];

                    break;
                }
                else if (child === parents[2]) {
                    break;
                }

                child = child.previousSibling;
            }
        }

        return index;
    }
function indexOfDeepestElement (elements) {
        var dropzone,
            deepestZone = elements[0],
            index = deepestZone? 0: -1,
            parent,
            deepestZoneParents = [],
            dropzoneParents = [],
            child,
            i,
            n;

        for (i = 1; i < elements.length; i++) {
            dropzone = elements[i];

            // an element might belong to multiple selector dropzones
            if (!dropzone || dropzone === deepestZone) {
                continue;
            }

            if (!deepestZone) {
                deepestZone = dropzone;
                index = i;
                continue;
            }

            // check if the deepest or current are document.documentElement or document.rootElement
            // - if the current dropzone is, do nothing and continue
            if (dropzone.parentNode === dropzone.ownerDocument) {
                continue;
            }
            // - if deepest is, update with the current dropzone and continue to next
            else if (deepestZone.parentNode === dropzone.ownerDocument) {
                deepestZone = dropzone;
                index = i;
                continue;
            }

            if (!deepestZoneParents.length) {
                parent = deepestZone;
                while (parent.parentNode && parent.parentNode !== parent.ownerDocument) {
                    deepestZoneParents.unshift(parent);
                    parent = parent.parentNode;
                }
            }

            // if this element is an svg element and the current deepest is
            // an HTMLElement
            if (deepestZone instanceof HTMLElement
                && dropzone instanceof SVGElement
                && !(dropzone instanceof SVGSVGElement)) {

                if (dropzone === deepestZone.parentNode) {
                    continue;
                }

                parent = dropzone.ownerSVGElement;
            }
            else {
                parent = dropzone;
            }

            dropzoneParents = [];

            while (parent.parentNode !== parent.ownerDocument) {
                dropzoneParents.unshift(parent);
                parent = parent.parentNode;
            }

            n = 0;

            // get (position of last common ancestor) + 1
            while (dropzoneParents[n] && dropzoneParents[n] === deepestZoneParents[n]) {
                n++;
            }

            var parents = [
                dropzoneParents[n - 1],
                dropzoneParents[n],
                deepestZoneParents[n]
            ];

            child = parents[0].lastChild;

            while (child) {
                if (child === parents[1]) {
                    deepestZone = dropzone;
                    index = i;
                    deepestZoneParents = [];

                    break;
                }
                else if (child === parents[2]) {
                    break;
                }

                child = child.previousSibling;
            }
        }

        return index;
    }
function indexOfDeepestElement ( elements ) { var dropzone , deepestZone = elements [ 0 ] , index = deepestZone ? 0 : - 1 , parent , deepestZoneParents = [ ] , dropzoneParents = [ ] , child , i , n ; for ( i = 1 ; i < elements . length ; i ++ ) { dropzone = elements [ i ] ; // an element might belong to multiple selector dropzones if ( ! dropzone || dropzone === deepestZone ) { continue ; } if ( ! deepestZone ) { deepestZone = dropzone ; index = i ; continue ; } // check if the deepest or current are document.documentElement or document.rootElement // - if the current dropzone is, do nothing and continue if ( dropzone . parentNode === dropzone . ownerDocument ) { continue ; } // - if deepest is, update with the current dropzone and continue to next else if ( deepestZone . parentNode === dropzone . ownerDocument ) { deepestZone = dropzone ; index = i ; continue ; } if ( ! deepestZoneParents . length ) { parent = deepestZone ; while ( parent . parentNode && parent . parentNode !== parent . ownerDocument ) { deepestZoneParents . unshift ( parent ) ; parent = parent . parentNode ; } } // if this element is an svg element and the current deepest is // an HTMLElement if ( deepestZone instanceof HTMLElement && dropzone instanceof SVGElement && ! ( dropzone instanceof SVGSVGElement ) ) { if ( dropzone === deepestZone . parentNode ) { continue ; } parent = dropzone . ownerSVGElement ; } else { parent = dropzone ; } dropzoneParents = [ ] ; while ( parent . parentNode !== parent . ownerDocument ) { dropzoneParents . unshift ( parent ) ; parent = parent . parentNode ; } n = 0 ; // get (position of last common ancestor) + 1 while ( dropzoneParents [ n ] && dropzoneParents [ n ] === deepestZoneParents [ n ] ) { n ++ ; } var parents = [ dropzoneParents [ n - 1 ] , dropzoneParents [ n ] , deepestZoneParents [ n ] ] ; child = parents [ 0 ] . lastChild ; while ( child ) { if ( child === parents [ 1 ] ) { deepestZone = dropzone ; index = i ; deepestZoneParents = [ ] ; break ; } else if ( child === parents [ 2 ] ) { break ; } child = child . previousSibling ; } } return index ; }
Test for the element that's "above" all other qualifiers
Test for the element that s above all other qualifiers