public
Description: Updated hourly from the jQuery SVN repo
Homepage: http://jquery.com
Clone URL: git://github.com/JackDanger/jquery.git
jquery event: closes #3127. jQuery.event.special built-in methods were 
optimized. The mouse(enter|leave) special case is only added for non-IE 
browsers.Thanks to Mike Helgeson for his help.

git-svn-id: http://jqueryjs.googlecode.com/svn/trunk@5797 
c715fcbe-d12f-0410-84c4-316a508785bb
aflesler (author)
Mon Jul 28 11:31:25 -0700 2008
commit  2c148d442ff83d4df64d0f057f7bd30658a43cae
tree    8448d05635db14ba215047f31a3e057767174de1
parent  d222339d776398700d3832dac0809c3ff566da8e
...
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
 
 
 
414
415
416
417
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
418
419
420
...
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
...
360
361
362
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
...
575
576
577
 
 
 
 
 
 
 
 
 
 
 
578
579
580
0
@@ -360,61 +360,47 @@ jQuery.event = {
0
 
0
   special: {
0
     ready: {
0
- setup: function() {
0
- // Make sure the ready event is setup
0
- bindReady();
0
- return;
0
- },
0
-
0
- teardown: function() { return; }
0
- },
0
-
0
- mouseenter: {
0
- setup: function( data ) {
0
- if ( jQuery.browser.msie ) return false;
0
- jQuery(this).bind("mouseover", data, jQuery.event.special.mouseenter.handler);
0
- return true;
0
- },
0
-
0
- teardown: function() {
0
- if ( jQuery.browser.msie ) return false;
0
- jQuery(this).unbind("mouseover", jQuery.event.special.mouseenter.handler);
0
- return true;
0
- },
0
-
0
- handler: function(event) {
0
- // If we actually just moused on to a sub-element, ignore it
0
- if ( withinElement(event, this) ) return true;
0
- // Execute the right handlers by setting the event type to mouseenter
0
- event.type = "mouseenter";
0
- return jQuery.event.handle.apply(this, arguments);
0
- }
0
- },
0
-
0
- mouseleave: {
0
- setup: function( data ) {
0
- if ( jQuery.browser.msie ) return false;
0
- jQuery(this).bind("mouseout", data, jQuery.event.special.mouseleave.handler);
0
- return true;
0
- },
0
-
0
- teardown: function() {
0
- if ( jQuery.browser.msie ) return false;
0
- jQuery(this).unbind("mouseout", jQuery.event.special.mouseleave.handler);
0
- return true;
0
- },
0
-
0
- handler: function(event) {
0
- // If we actually just moused on to a sub-element, ignore it
0
- if ( withinElement(event, this) ) return true;
0
- // Execute the right handlers by setting the event type to mouseleave
0
- event.type = "mouseleave";
0
- return jQuery.event.handle.apply(this, arguments);
0
- }
0
+ // Make sure the ready event is setup
0
+ setup: bindReady,
0
+ teardown: function() {}
0
     }
0
   }
0
 };
0
 
0
+if ( !jQuery.browser.msie ){
0
+ // Checks if an event happened on an element within another element
0
+ // Used in jQuery.event.special.mouseenter and mouseleave handlers
0
+ var withinElement = function(event) {
0
+ // Check if mouse(over|out) are still within the same parent element
0
+ var parent = event.relatedTarget;
0
+ // Traverse up the tree
0
+ while ( parent && parent != this )
0
+ try { parent = parent.parentNode; }
0
+ catch(e) { parent = this; }
0
+
0
+ if( parent != this ){
0
+ // set the correct event type
0
+ event.type = event.data;
0
+ // handle event if we actually just moused on to a non sub-element
0
+ jQuery.event.handle.apply( this, arguments );
0
+ }
0
+ };
0
+
0
+ jQuery.each({
0
+ mouseover: 'mouseenter',
0
+ mouseout: 'mouseleave'
0
+ }, function( orig, fix ){
0
+ jQuery.event.special[ fix ] = {
0
+ setup: function(){
0
+ jQuery.event.add( this, orig, withinElement, fix );
0
+ },
0
+ teardown: function(){
0
+ jQuery.event.remove( this, orig, withinElement );
0
+ }
0
+ };
0
+ });
0
+}
0
+
0
 jQuery.fn.extend({
0
   bind: function( type, data, fn ) {
0
     return type == "unload" ? this.one(type, data, fn) : this.each(function(){
0
@@ -589,17 +575,6 @@ jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
0
   };
0
 });
0
 
0
-// Checks if an event happened on an element within another element
0
-// Used in jQuery.event.special.mouseenter and mouseleave handlers
0
-var withinElement = function(event, elem) {
0
- // Check if mouse(over|out) are still within the same parent element
0
- var parent = event.relatedTarget;
0
- // Traverse up the tree
0
- while ( parent && parent != elem ) try { parent = parent.parentNode; } catch(error) { parent = elem; }
0
- // Return true if we actually just moused on to a sub-element
0
- return parent == elem;
0
-};
0
-
0
 // Prevent memory leaks in IE
0
 // And prevent errors on refresh with events like mouseover in other browsers
0
 // Window isn't included so as not to unbind existing unload events

Comments

    No one has commented yet.