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

Function withinElement

1.6.1/src/event.js:653–682  ·  view source on GitHub ↗
( event )

Source from the content-addressed store, hash-verified

651// Checks if an event happened on an element within another element
652// Used in jQuery.event.special.mouseenter and mouseleave handlers
653var withinElement = function( event ) {
654 // Check if mouse(over|out) are still within the same parent element
655 var parent = event.relatedTarget;
656
657 // set the correct event type
658 event.type = event.data;
659
660 // Firefox sometimes assigns relatedTarget a XUL element
661 // which we cannot access the parentNode property of
662 try {
663
664 // Chrome does something similar, the parentNode property
665 // can be accessed but is null.
666 if ( parent && parent !== document && !parent.parentNode ) {
667 return;
668 }
669
670 // Traverse up the tree
671 while ( parent && parent !== this ) {
672 parent = parent.parentNode;
673 }
674
675 if ( parent !== this ) {
676 // handle event if we actually just moused on to a non sub-element
677 jQuery.event.handle.apply( this, arguments );
678 }
679
680 // assuming we've left the element since we most likely mousedover a xul element
681 } catch(e) { }
682},
683
684// In case of event delegation, we only need to rename the event.type,
685// liveHandler will take care of the rest.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected