From 11e82e95b6d8542902bfd4d0d1394bed0d676946 Mon Sep 17 00:00:00 2001 From: John Resig Date: Mon, 27 Mar 2006 07:09:28 +0000 Subject: [PATCH] Added checks to triggerEvent for optional data and element verification. Uses $.apply() now, too. --- jquery/jquery.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jquery/jquery.js b/jquery/jquery.js index 48082c7b8..59b6779fe 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) {