[whatwg] Image.complete in broken state

The spec states:

> The IDL attribute `complete` must return true if […]The final task that  
> is queued by the networking task source once the resource has been  
> fetched has been queued, but has not yet been run, and the img element  
> is not in the broken state.
> The img element is completely available.

http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-content-1.html#dom-img-complete

If I understand correctly the spec calls for Image.complete to be false  
when the image is broken — and this doesn't match implementations. At  
least Firefox, Chrome and Safari set image.complete == true when the image  
is broken. Test case:

<img src="data:image/gif,broken" onerror="alert(this.complete)">

Having complete == true set on broken images is actually useful: it allows  
distinguishing between images that haven't been loaded yet and images that  
have been loaded and failed to decode (.complete == true && .naturalWidth  
== 0).

-- 
regards, Kornel

Received on Wednesday, 30 October 2013 22:50:21 UTC