html icon indicating copy to clipboard operation
html copied to clipboard

<img> setting src = "" should maybe be sync

Open zcorpan opened this issue 8 years ago • 8 comments

https://html.spec.whatwg.org/#updating-the-image-data

If the element does not use srcset or picture, and it has a src attribute specified and its value is not the empty string, let selected source be the value of the element's src attribute, and selected pixel density be 1.0. Otherwise, let selected source be null and selected pixel density be undefined.

From https://github.com/w3c/web-platform-tests/pull/5060

See http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4936

It seems that in Chromium and Gecko this case is sync (doesn't await a stable state).

With picture: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4937

Chromium: still sync. Gecko awaits a stable state. Per spec updates shouldn't be sync if srcset or picture are used.

WebKit seems a bit weird for the case of setting src to empty string or removing the src attribute doesn't change .width or the rendered dimensions but it doesn't render the old image.

zcorpan avatar Mar 13 '17 14:03 zcorpan

Result in Edge 13 for 4936:

log: 0

zcorpan avatar Mar 13 '17 14:03 zcorpan

See http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4936 It seems that in Chromium and Gecko this case is sync (doesn't await a stable state).

Gecko now always sync loads image for non-responsive case (without picture and srcset), but we intent to change behaviour to follow the current spec, so http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4936 will become async (await a stable state) after https://bugzilla.mozilla.org/show_bug.cgi?id=1076583.

EdgarChen avatar Mar 14 '17 07:03 EdgarChen

It sounds like we should not necessarily blindly follow the current specification, though.

jdm avatar Mar 14 '17 08:03 jdm

Yeah this a case I probably did not carefully consider before. Though given WebKit's behavior it may not be critical for Web compat either way. But it seems slightly safer to align with majority behavior (in the non-responsive case).

zcorpan avatar Mar 14 '17 09:03 zcorpan

I see, I will also handle this case in https://bugzilla.mozilla.org/show_bug.cgi?id=1076583. Thank you, @zcorpan and @jdm.

EdgarChen avatar Mar 16 '17 03:03 EdgarChen

Per https://github.com/whatwg/html/issues/4884#issuecomment-527867774, it looks like browsers have different behavior not only in non-responsive case, but also responsive case. :(

EdgarChen avatar Sep 04 '19 12:09 EdgarChen

I was told webkit has still async behavior here. @rniwa do you think webkit would be will to follow Gecko's and Blink's behavior here?

smaug---- avatar Aug 01 '24 10:08 smaug----

Note that this is more subtle than just src="" is sync, see https://phabricator.services.mozilla.com/D218603

emilio avatar Aug 05 '24 23:08 emilio