Skip to content
Permalink
Browse files

Fix for #1486. Prevent IE from throwing an error when triggering focu…

…s on hidden input.
  • Loading branch information
brandonaaron committed Dec 8, 2007
1 parent ffbedf0 commit 91f1299f68a68728467a2566a38845d82e30606f
Showing with 15 additions and 2 deletions.
  1. +4 −1 src/event.js
  2. +11 −1 test/unit/event.js
@@ -193,7 +193,10 @@ jQuery.event = {
// Trigger the native events (except for clicks on links)
if ( fn && donative !== false && val !== false && !(jQuery.nodeName(element, 'a') && type == "click") ) {
this.triggered = true;
element[ type ]();
try {
element[ type ]();
// prevent IE from throwing an error for some hidden elements
} catch (e) {}
}

this.triggered = false;
@@ -121,7 +121,7 @@ test("unbind(event)", function() {
});

test("trigger(event, [data], [fn])", function() {
expect(66);
expect(67);

var handler = function(event, a, b, c) {
equals( event.type, "click", "check passed data" );
@@ -193,6 +193,16 @@ test("trigger(event, [data], [fn])", function() {
// Trigger only the handlers (no native) and extra fn, with external event obj
// Triggers 9
equals( $("#firstp").triggerHandler("click", [eventObj, 1, "2", "abc"], handler), "test", "Verify handler response" );

var pass = true;
try {
$('input:first')
.hide()
.trigger('focus');
} catch(e) {
pass = false;
}
ok( pass, "Trigger focus on hidden element" );

// have the extra handler override the return
// Triggers 9

0 comments on commit 91f1299

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