#1148 closed bug (fixed)
Window load and resize events fail in Safari
Reported by: | eric | Owned by: | |
---|---|---|---|
Priority: | critical | Milestone: | 1.1.3 |
Component: | event | Version: | 1.1.2 |
Keywords: | safari, event | Cc: | |
Blocked by: | Blocking: |
Description
Calls to $(window).load and $(window).resize fail in Safari version 2.0.(412). An error in event.fix seems to be the cause.
Change History (4)
comment:1 Changed 16 years ago by
comment:2 Changed 16 years ago by
need: | Review → Test Case |
---|---|
Priority: | critical → major |
Resolution: | → worksforme |
Status: | new → closed |
This works for me. http://brandon.jquery.com/testing/1148/test.html
Please feel free to reopen with a test case.
comment:3 Changed 16 years ago by
Priority: | major → critical |
---|---|
Resolution: | worksforme |
Status: | closed → reopened |
Never mind. I didn't wrap the event handlers in document.ready. :) Reopened and checking into fix right now.
comment:4 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Okay ... round and round we go. It looks like document.ready and load are firing at the same time for my test page in Safari and that is why it was not working for me ... not because it was throwing the error you describe. The resize event works just fine. I'm unable to reproduce this bug.
This might have been resolved with the move to DOM Level 2 event handlers. Please feel free to reopen if you can reproduce with the latest from SVN.
It seems that for window events in safari event.target is null. I see this happening in version 2.0.4. (maybe a safari bug). Firefox shows the event target as the document object.
The problem seems to be event.fix. The conditional on line http://dev.jquery.com/browser/trunk/jquery/src/event/event.js#L196 196 assumes an event.target:
this fixes the problem for me:
This avoids the error and allows Safari to continue executing the event code but maybe it would be better to assign the document as a default target for events with a null target. The null target thing strikes me as the sort of thing that will cause more bugs at some point.