aboutsummaryrefslogtreecommitdiffstats
path: root/src/event
diff options
context:
space:
mode:
authorBrandon Aaron <brandon.aaron@gmail.com>2007-07-21 01:04:59 +0000
committerBrandon Aaron <brandon.aaron@gmail.com>2007-07-21 01:04:59 +0000
commit24463a04ce5612f4007263f9af0d1e4d7568ed9a (patch)
tree76b9a25f1aa98f2cd36077dc15705cbcb214c840 /src/event
parente20e8e6e3cc565469cedfad105565ce534c98c71 (diff)
downloadjquery-24463a04ce5612f4007263f9af0d1e4d7568ed9a.tar.gz
jquery-24463a04ce5612f4007263f9af0d1e4d7568ed9a.zip
trigger DOM0 event handlers when doing a trigger (#1363)
Diffstat (limited to 'src/event')
-rw-r--r--src/event/event.js10
-rw-r--r--src/event/eventTest.js9
2 files changed, 15 insertions, 4 deletions
diff --git a/src/event/event.js b/src/event/event.js
index f264a2cd2..b13e5a02f 100644
--- a/src/event/event.js
+++ b/src/event/event.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;
}
diff --git a/src/event/eventTest.js b/src/event/eventTest.js
index d913b56ee..7ac3a6efb 100644
--- a/src/event/eventTest.js
+++ b/src/event/eventTest.js
@@ -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() {