diff options
author | rwldrn <waldron.rick@gmail.com> | 2011-06-14 15:38:46 -0400 |
---|---|---|
committer | timmywil <tim.willison@thisismedium.com> | 2011-06-14 15:38:46 -0400 |
commit | 6926247bf441deaa0441872849bb3786c257a4cf (patch) | |
tree | 94b08fcfc6340afd28e2f97b83ea932cc5e3d78b /src | |
parent | 641ad802111d2dc16ccf4b3721784a6addaf20df (diff) | |
download | jquery-6926247bf441deaa0441872849bb3786c257a4cf.tar.gz jquery-6926247bf441deaa0441872849bb3786c257a4cf.zip |
Landing pull request 397. withinElement rewrite in event. Fixes #6234, #9357, #9447.
More Details:
- https://github.com/jquery/jquery/pull/397
- http://bugs.jquery.com/ticket/6234
- http://bugs.jquery.com/ticket/9357
- http://bugs.jquery.com/ticket/9447
Diffstat (limited to 'src')
-rw-r--r-- | src/event.js | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/src/event.js b/src/event.js index 3f53ab5c2..131739b1a 100644 --- a/src/event.js +++ b/src/event.js @@ -650,34 +650,27 @@ jQuery.Event.prototype = { // Checks if an event happened on an element within another element // Used in jQuery.event.special.mouseenter and mouseleave handlers var withinElement = function( event ) { + // Check if mouse(over|out) are still within the same parent element - var parent = event.relatedTarget; + var related = event.relatedTarget, + inside = false, + eventType = event.type; - // set the correct event type event.type = event.data; - // Firefox sometimes assigns relatedTarget a XUL element - // which we cannot access the parentNode property of - try { + if ( related !== this ) { - // Chrome does something similar, the parentNode property - // can be accessed but is null. - if ( parent && parent !== document && !parent.parentNode ) { - return; + if ( related ) { + inside = jQuery.contains( this, related ); } - // Traverse up the tree - while ( parent && parent !== this ) { - parent = parent.parentNode; - } + if ( !inside ) { - if ( parent !== this ) { - // handle event if we actually just moused on to a non sub-element jQuery.event.handle.apply( this, arguments ); - } - // assuming we've left the element since we most likely mousedover a xul element - } catch(e) { } + event.type = eventType; + } + } }, // In case of event delegation, we only need to rename the event.type, |