#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 10 years ago by
comment:2 Changed 10 years ago by
| Component: | unfiled → event |
|---|---|
| Keywords: | needsreview added |
| Priority: | undecided → low |
comment:3 Changed 10 years ago by
| Status: | new → open |
|---|
Further verification by josh that colon is the only deathchar: http://jsfiddle.net/josh3736/GVKqD/
comment:4 Changed 10 years ago by
| Keywords: | needsreview removed |
|---|
comment:5 Changed 10 years ago by
| Milestone: | 1.next → 1.6 |
|---|---|
| Owner: | set to dmethvin |
| Priority: | low → high |
| Status: | open → assigned |
comment:6 follow-up: 7 Changed 10 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | assigned → 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 Changed 10 years ago by
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).

Patch submitted as pull request #231.