Skip to content
Permalink
Browse files

trigger DOM0 event handlers when doing a trigger (#1363)

  • Loading branch information
brandonaaron committed Jul 21, 2007
1 parent e20e8e6 commit 24463a04ce5612f4007263f9af0d1e4d7568ed9a
Showing with 15 additions and 4 deletions.
  1. +7 −3 src/event/event.js
  2. +8 −1 src/event/eventTest.js
@@ -148,11 +148,15 @@ jQuery.event = {
data.unshift( this.fix({ type: type, target: element }) );

// Trigger the event
if ( jQuery.isFunction(element.$handle) && (val = element.$handle.apply( element, data )) !== false )
this.triggered = true;
if ( jQuery.isFunction( element.$handle ) )
val = element.$handle.apply( element, data );
if ( !fn && element["on"+type] && element["on"+type].apply( element, data ) === false )
val = false;

if ( fn && val !== false && !jQuery.nodeName(element, 'a') )
if ( fn && val !== false && !jQuery.nodeName(element, 'a') ) {
this.triggered = true;
element[ type ]();
}

this.triggered = false;
}
@@ -48,7 +48,7 @@ test("bind()", function() {
});

test("click()", function() {
expect(3);
expect(4);
$('<li><a href="#">Change location</a></li>').prependTo('#firstUL').find('a').bind('click', function() {
var close = $('spanx', this); // same with $(this).find('span');
ok( close.length == 0, "Context element does not exist, length must be zero" );
@@ -59,6 +59,13 @@ test("click()", function() {
$("#check1").click(function() {
ok( true, "click event handler for checkbox gets fired twice, see #815" );
}).click();

var counter = 0;
$('#firstp')[0].onclick = function(event) {
counter++;
};
$('#firstp').click();
ok( counter == 1, "Check that click, triggers onclick event handler also" );
});

test("unbind(event)", function() {

0 comments on commit 24463a0

Please sign in to comment.
You can’t perform that action at this time.