[whatwg] img loading events - can load & error fire for the same image?
jaffathecake at gmail.com
Fri Apr 5 03:30:27 PDT 2013
Been reading the steps for image downloading -
As far as I can tell:
Step 12 "If selected source is null" is the only step where an "error"
event can be fired and abort before step 14.
Step 14 always results in firing a "load" event, either because the image
"download was successful and the user agent was able to determine the
image's width and height", or "Otherwise".
Then if "either the image data is corrupted in some fatal way such that the
image dimensions cannot be obtained, or the image data is not in a
supported file format" an "error" event is fired.
Unless I'm reading it wrong, that suggests
http://jsbin.com/ifihex/1/editshould fire a "load" then an "error",
which doesn't feel right.
I don't think the "Otherwise" step should fire "load", just "loadend".
"load" is fired once the width & height can be determined, which suggests
that an un-decodable image, but with intact headers (which give the width &
height) will fire "load" but not "error".
I agree with this, as it means the browser can defer decoding to render
time, but do we need a way in JS to confirm an image is decodable?
More information about the whatwg