Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#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 13 years ago by eric

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:

// check if target is a textnode (safari)
if(jQuery.browser.safari && event.target.nodeType == 3) {

this fixes the problem for me:

// check if target is a textnode (safari)
if(jQuery.browser.safari && event.target && event.target.nodeType == 3) {

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.

comment:2 Changed 13 years ago by brandon

need: ReviewTest Case
Priority: criticalmajor
Resolution: worksforme
Status: newclosed

This works for me. http://brandon.jquery.com/testing/1148/test.html

Please feel free to reopen with a test case.

comment:3 Changed 13 years ago by brandon

Priority: majorcritical
Resolution: worksforme
Status: closedreopened

Never mind. I didn't wrap the event handlers in document.ready. :) Reopened and checking into fix right now.

comment:4 Changed 13 years ago by brandon

Resolution: fixed
Status: reopenedclosed

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.

Note: See TracTickets for help on using tickets.