Bug Tracker

Opened 9 years ago

Closed 9 years ago

#8619 closed bug (fixed)

Documentation for .error() is incorrect.

Reported by: jvz Owned by:
Priority: low Milestone: 1.next
Component: event Version: 1.5.1
Keywords: Cc:
Blocked by: Blocking:

Description

The documentation on the .error() function gives the following example code:

$("img").error(function(){
  $(this).hide();
});

However, its intended purpose of hiding broken images in Internet Explorer works in every browser but IE. I've tested this in Safari 5.0.4, Opera 11.01, Firefox 4.0, and Chrome 10.0.648.151. The bug is in at least IE 8.0 and IE 9.0 (the only versions of IE I have access to at work right now), but knowing IE, it's probably also a bug in every other version.

In IE 9 at least, it only works sometimes due to a race condition pointed out in my previous bug report. Repeated testing in the working web browsers do not appear to exhibit this race condition and will still fire an error event after the image has already been loaded if an error handler is registered (which makes a lot more sense).

Change History (3)

comment:1 Changed 9 years ago by jvz

Here's a jsFiddle test case

comment:2 Changed 9 years ago by Rick Waldron

Component: unfiledevent
Priority: undecidedlow
Status: newopen

comment:3 Changed 9 years ago by dmethvin

Resolution: fixed
Status: openclosed

Original report was #8617.

I agree on the docs at http://api.jquery.com/error/ and have updated them.

Unfortunately, the "error" event does not seem to bubble in any browsers (although the W3C says it should) so you can't use delegate/live to handle them.

Note: See TracTickets for help on using tickets.