Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#8272 closed bug (fixed)

Exceptions in plain JS object event handlers swallowed by jQuery

Reported by: josh3736 Owned by: dmethvin
Priority: high Milestone: 1.6
Component: event Version: 1.5
Keywords: Cc:
Blocked by: Blocking:

Description

The fix implemented for #3533 caused a regression in jQuery 1.4.1 (and remains in 1.5). JavaScript exceptions thrown within a plain JS object's on<event> handler get caught and swallowed by event.js:378.

var Test = function() {
    this.onclick = function(e) {
        throw new Error('This exception will be swallowed.');
    }
};
var obj = new Test();
$(obj).click();

Full test case here. Note that changing jQuery back to 1.3.2 yields the expected behavior.

The exception is swallowed because the fix for #3533 was to wrap the call to on<event> handlers in a try/empty catch. I've created a patch which instead checks if the element being triggered is a <table> and if so, skip calling the on<event> function if the event type contains a colon.

My double-checking of the IE bug corrected by #3533 shows that <table> is the only element that triggers the bug.

Change History (7)

comment:1 Changed 6 years ago by josh3736

Patch submitted as pull request #231.

comment:2 Changed 6 years ago by jitter

  • Component changed from unfiled to event
  • Keywords needsreview added
  • Priority changed from undecided to low

comment:3 Changed 6 years ago by dmethvin

  • Status changed from new to open

Further verification by josh that colon is the only deathchar: http://jsfiddle.net/josh3736/GVKqD/

comment:4 Changed 6 years ago by dmethvin

  • Keywords needsreview removed

comment:5 Changed 6 years ago by dmethvin

  • Milestone changed from 1.next to 1.6
  • Owner set to dmethvin
  • Priority changed from low to high
  • Status changed from open to assigned

comment:6 follow-up: Changed 6 years ago by dmethvin

  • Resolution set to fixed
  • Status changed from assigned to closed

Fixes #8722. Remove try/catch used by #3533 to fix the IE Table Colon Blow bug, and instead check for colon in the event name. Thanks to daguej for scoping this out -- a colonoscopy you might say.

Changeset: 98d83ef85f41fefb40a14eec24c6804c088bbeeb

comment:7 in reply to: ↑ 6 Changed 6 years ago by josh3736

Replying to dmethvin:

Fixes #8722. Remove try/catch used by #3533 to fix the IE Table Colon Blow bug, and instead check for colon in the event name. Thanks to daguej for scoping this out -- a colonoscopy you might say.

Changeset: 98d83ef85f41fefb40a14eec24c6804c088bbeeb

Looks like you got the bug number wrong in the commit message (8722 instead of 8272).

Note: See TracTickets for help on using tickets.