Skip to main content

Bug Tracker

Side navigation

#1148 closed bug (fixed)

Opened April 28, 2007 10:10AM UTC

Closed April 30, 2007 03:19AM UTC

Last modified June 21, 2007 05:04AM UTC

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.

Attachments (0)
Change History (4)

Changed April 28, 2007 08:01PM UTC by eric comment:1

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.

Changed April 30, 2007 02:09AM UTC by brandon comment:2

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.

Changed April 30, 2007 02:20AM UTC by brandon comment:3

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.

Changed April 30, 2007 03:19AM UTC by brandon comment:4

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.