Skip to main content

Bug Tracker

Side navigation

#8619 closed bug (fixed)

Opened March 24, 2011 04:05PM UTC

Closed March 24, 2011 07:29PM UTC

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).

Attachments (0)
Change History (3)

Changed March 24, 2011 04:09PM UTC by jvz comment:1

Here's a jsFiddle test case

Changed March 24, 2011 04:13PM UTC by rwaldron comment:2

component: unfiledevent
priority: undecidedlow
status: newopen

Changed March 24, 2011 07:29PM UTC by dmethvin comment:3

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.