bubbleType = special.delegateType || type;
cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
- old = null;
- for ( ; cur; cur = cur.parentNode ) {
+ for ( old = elem; cur; cur = cur.parentNode ) {
eventPath.push([ cur, bubbleType ]);
old = cur;
}
// Only add window if we got to document (e.g., not plain obj or detached DOM)
- if ( old && old === elem.ownerDocument ) {
+ if ( old === (elem.ownerDocument || document) ) {
eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
}
}
});
// return undefined since we don't need an event listener
},
-
+
postDispatch: function( event ) {
// If form was submitted by the user, bubble the event up the tree
if ( event._submit_bubble ) {
});
test("trigger() bubbling", function() {
- expect(17);
+ expect(18);
var win = 0, doc = 0, html = 0, body = 0, main = 0, ap = 0;
equal( main, 1, "ap bubble" );
equal( ap, 1, "ap bubble" );
+ jQuery( document ).trigger("click");
+ equal( win, 4, "doc bubble" );
+
// manually clean up events from elements outside the fixture
jQuery(document).unbind("click");
jQuery("html, body, #qunit-fixture").unbind("click");