From: John Resig Date: Mon, 27 Mar 2006 07:09:28 +0000 (+0000) Subject: Added checks to triggerEvent for optional data and element verification. Uses $.apply... X-Git-Url: http://git.asbjorn.it/?a=commitdiff_plain;h=11e82e95b6d8542902bfd4d0d1394bed0d676946;p=jquery.git Added checks to triggerEvent for optional data and element verification. Uses $.apply() now, too. --- diff --git a/jquery/jquery.js b/jquery/jquery.js index 48082c7..59b6779 100644 --- a/jquery/jquery.js +++ b/jquery/jquery.js @@ -697,9 +697,10 @@ function removeEvent(element, type, handler) { } }; -function triggerEvent(element,type) { - if ( element["on" + type] ) - element["on" + type]({ type: type }); +function triggerEvent(element,type,data) { + data = data || [{ type: type }]; + if ( element && element["on" + type] ) + $.apply( element, element["on" + type], data ); } function handleEvent(event) {