Bug Tracker

Ticket #1148 (closed bug: fixed)

Opened 1 year ago

Last modified 1 year ago

Window load and resize events fail in Safari

Reported by: eric Assigned to: anonymous
Type: bug Priority: critical
Milestone: 1.1.3 Component: event
Version: 1.1.2 Keywords: safari, event
Cc: Needs: Test Case

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

Change History

Changed 1 year 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 [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 1 year ago by brandon

  • need changed from Review to Test Case
  • priority changed from critical to major
  • status changed from new to closed
  • resolution set to worksforme

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

Please feel free to reopen with a test case.

Changed 1 year ago by brandon

  • priority changed from major to critical
  • status changed from closed to reopened
  • resolution deleted

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

Changed 1 year ago by brandon

  • status changed from reopened to closed
  • resolution set to fixed

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.