Permalink
Browse files

Replaces try/catch with smaller smarter conditions; Fixes #9447

  • Loading branch information...
rwaldron committed May 27, 2011
1 parent bf0bb35 commit 387bbece9df9f74bb29c3e8c568404aff51932a9
Showing with 19 additions and 5 deletions.
  1. +0 −5 src/event.js
  2. +19 −0 test/unit/event.js
View
@@ -652,10 +652,6 @@ jQuery.Event.prototype = {
// Used in jQuery.event.special.mouseenter and mouseleave handlers
var withinElement = function( event ) {
- //testing at:
- //http://jsfiddle.net/rwaldron/pBQEd/15/
- //http://jsfiddle.net/dmethvin/pBQEd/16/
-
// Check if mouse(over|out) are still within the same parent element
var related = event.relatedTarget,
inside = false,
@@ -678,7 +674,6 @@ var withinElement = function( event ) {
}
},
-
// In case of event delegation, we only need to rename the event.type,
// liveHandler will take care of the rest.
delegate = function( event ) {
View
@@ -780,6 +780,25 @@ test("mouseover triggers mouseenter", function() {
elem.remove();
});
+test("withinElement implemented with jQuery.contains()", function() {
+
+ expect(1);
+
+ jQuery("#qunit-fixture").append('<div id="jc-outer"><div id="jc-inner"></div></div>');
+
+ jQuery("#jc-outer").bind("mouseenter mouseleave", function( event ) {
+
+ equal( this.id, "jc-outer", this.id + " " + event.type );
+
+ }).trigger("mouseenter");
+
+ jQuery("#jc-inner").trigger("mousenter");
+
+ jQuery("#jc-outer").unbind("mouseenter mouseleave").remove();
+ jQuery("#jc-inner").remove();
+
+});
+
test("trigger() shortcuts", function() {
expect(6);

0 comments on commit 387bbec

Please sign in to comment.