Ticket #6369 (closed bug)
In IE v8.0.7600.16385 Line 1919 v1.4.2 undefined when exiting page???
| Reported by: | mcslayton@… | Owned by: | mcslayton@… |
|---|---|---|---|
| Priority: | low | Milestone: | 1.5 |
| Component: | event | Version: | 1.4.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Strange behavior / error. When using IE v8 I could run my full, very heavy jQuery v1.4.2 w/ v1.8 jQuery UI app with all functions without error UNTIL I tried to navigate away from the page and then line 1919 below would get an undefined error. What's bizarre is I have NOT onbeforeunload kind of logic in the app?????
I had to wrap the setting of this line:
var events = jQuery.data(this, "events"), handlers = events[event.type];
Like this:
try {
events = jQuery.data(this, "events"), handlers = events[event.type];
} catch (err) {
events = null;
};
Change History
comment:3 Changed 3 years ago by bbostow
This can happen after the unload event is fired. Using the try catch code that is in the bug will still generate an exception because of the if( event && handler). I was able to mitigate this and also handle the case reported in bug #6163 by changing lines 1919 through 1921 to use the following:
events = jQuery.data(this, "events");
handlers = (typeof(events) !== "undefined" && events !== null)? events[ event.type ] : null;
if ( handlers ) {
using null as the default for handlers was to preserve the if(events && handlers) logic. If handlers or events is undefined the if statement may throw an undefined error. The other option is to change jQuery.data so that it returns an object that is not undefined or null but still preserves the need of the if statement.
comment:4 Changed 3 years ago by SlexAxton
- Owner set to mcslayton@…
- Priority set to low
- Status changed from new to pending
- Milestone changed from 1.4.3 to 1.5
It'd be great to have a test-case page that we could use to fix this bug. Anyone that has been able to duplicate willing to make a jsfiddle/jsbin page for us?
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

I'm seeing the same error.