[whatwg] Detached elements and delaying the load event

Andrew Oakley andrew at ado.is-a-geek.net
Tue Sep 6 06:03:55 PDT 2011


I'm going to use the <img> element as an example here, but the same
thing applies to other elements such as <iframe>, <video>, <audio>.

I'm going to assume that the user agent "obtains the images
immediately", given that seems to be what most browsers do.

If an img element is created and given a src attribute (but not
necessarily attached to the tree) then, according to HTML5, we need to
"update the image data" and therefore delay the load event.  I guess
this means we should lock the image element in a similar fashion to
XMLHttpRequest objects, otherwise the image could be garbage collected
before it has been loaded and therefore block the load event indefinitely.

Firefox, Opera, Chrome and Safari do seem to implement this behaviour,
IE does not.

I would prefer not to implement this and just say "detached elements do
not delay the load event", but I'm not sure if that will always work.

Can we please get a clarification in HTML5, either to say that these
detached objects must not be garbage collected while they are delaying
the load event, or to say that they do not delay the load event.

Thanks

-- 
Andrew Oakley


More information about the whatwg mailing list