Side navigation
#8272 closed bug (fixed)
Opened February 14, 2011 03:05PM UTC
Closed April 08, 2011 01:26PM UTC
Last modified April 08, 2011 01:37PM UTC
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.
#!js
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.
Attachments (0)
Change History (7)
Changed February 14, 2011 03:17PM UTC by comment:1
Changed February 23, 2011 12:44AM UTC by comment:2
| component: | unfiled → event |
|---|---|
| keywords: | → needsreview |
| priority: | undecided → low |
Changed March 31, 2011 02:29AM UTC by comment:3
| status: | new → open |
|---|
Further verification by josh that colon is the only deathchar: http://jsfiddle.net/josh3736/GVKqD/
Changed March 31, 2011 02:30AM UTC by comment:4
| keywords: | needsreview |
|---|
Changed April 08, 2011 01:49AM UTC by comment:5
| milestone: | 1.next → 1.6 |
|---|---|
| owner: | → dmethvin |
| priority: | low → high |
| status: | open → assigned |
Changed April 08, 2011 01:26PM UTC by comment:6
Changed April 08, 2011 01:37PM UTC by comment:7
Replying to [comment:6 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.