Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
36c99dc0
Commit
36c99dc0
authored
Dec 21, 2009
by
jeresig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweaked the syntax of withinElement a bit.
parent
e083d15f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
event.js
src/event.js
+11
-4
No files found.
src/event.js
View file @
36c99dc0
...
@@ -532,23 +532,30 @@ jQuery.Event.prototype = {
...
@@ -532,23 +532,30 @@ jQuery.Event.prototype = {
isPropagationStopped: returnFalse,
isPropagationStopped: returnFalse,
isImmediatePropagationStopped: returnFalse
isImmediatePropagationStopped: returnFalse
};
};
// Checks if an event happened on an element within another element
// Checks if an event happened on an element within another element
// Used in jQuery.event.special.mouseenter and mouseleave handlers
// Used in jQuery.event.special.mouseenter and mouseleave handlers
var withinElement = function( event ) {
var withinElement = function( event ) {
// Check if mouse(over|out) are still within the same parent element
// Check if mouse(over|out) are still within the same parent element
var parent = event.relatedTarget;
var parent = event.relatedTarget;
// Traverse up the tree
// Traverse up the tree
while ( parent && parent != this ) {
while ( parent && parent !=
=
this ) {
// Firefox sometimes assigns relatedTarget a XUL element
// Firefox sometimes assigns relatedTarget a XUL element
// which we cannot access the parentNode property of
// which we cannot access the parentNode property of
try { parent = parent.parentNode; }
try {
parent = parent.parentNode;
// assuming we've left the element since we most likely mousedover a xul element
// assuming we've left the element since we most likely mousedover a xul element
catch(e) { break; }
} catch(e) {
break;
}
}
}
if ( parent != this ) {
if ( parent !=
=
this ) {
// set the correct event type
// set the correct event type
event.type = event.data;
event.type = event.data;
// handle event if we actually just moused on to a non sub-element
// handle event if we actually just moused on to a non sub-element
jQuery.event.handle.apply( this, arguments );
jQuery.event.handle.apply( this, arguments );
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment