This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 14531 - Require that <img>s are updated when @crossorigin is changed
Summary: Require that <img>s are updated when @crossorigin is changed
Status: RESOLVED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: HTML5 spec (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-21 17:41 UTC by Jonas Sicking (Not reading bugmail)
Modified: 2011-10-28 22:59 UTC (History)
5 users (show)

See Also:


Attachments

Description Jonas Sicking (Not reading bugmail) 2011-10-21 17:41:01 UTC
Currently the spec only permits changing the loaded image data when @src is modified. It should both permit and require that the data is updated when @crossorigin is modified too.
Comment 1 Ian 'Hixie' Hickson 2011-10-25 05:06:01 UTC
I'm concerned that this would lead to people setting src="" then setting crossorigin="" and doubling the amount of network traffic. If we don't do this, then they'll quickly realise they have to set it the other way around (since if they need crossorigin, and don't set it, something will break).

What reasoning did you have for the opposite conclusion? (I'm certainly open to changing this, just curious what your reasoning was and whether the above changes your mind.)
Comment 2 Jonas Sicking (Not reading bugmail) 2011-10-25 06:48:17 UTC
As a general rule the way a DOM behaves should depend on the current configuration of the DOM. I.e. on the configuration of elements, children and attributes. It should not matter how it got there. This is much more understandable for people. This is especially the case for attribute setters which people tend to think if as state setters, not function calls. Hence, it's very surprising that the order of setting attributes matter.

We have very few diversions from this rule. Most of them involve <script> elements where we simply can't undo actions when attributes or child lists are changed. The *only* other case I can think of is changes to base URIs where complexity was vey high and value very low to try to do otherwise (and I'd expect that over time we'll end up adding a lot of that complexity).

Additionally, if the crossorigin attribute doesn't affect what image is actually going to be attempted to be loaded that means we'll be carrying around hidden state not exposed to script. In almost every situation where we do that people end up wanting to get at that state. Which leads to more API for us, or more complexity for them when they have to work around not having that state.
Comment 3 Jonas Sicking (Not reading bugmail) 2011-10-25 06:53:19 UTC
I don't think we'll end up with double network traffic ever. Ain most cases I would expect to not have been able to hit the network by the time that the second attribute is set.

But I'm curious what bz thinks of the matter.
Comment 4 Simon Pieters 2011-10-25 10:39:44 UTC
For <video>, loading waits for a stable state, so it wouldn't matter if crossorigin was set first or last. However, setting crossorigin after a video has already loaded (or changing the src="" of <source>, even) does not change anything (the script needs to call load()).

I'm not sure what to do with <img>. It would be nice if it was equivalent to set src first and crossorigin second in the same script. I'm not convinced that setting crossorigin after the image has loaded should reload the image.
Comment 5 Boris Zbarsky 2011-10-25 15:57:18 UTC
Not starting extraneous loads seems like a basic matter of implementation quality...  I'm fairly certain that in Gecko there would be no extra loads.
Comment 6 Ian 'Hixie' Hickson 2011-10-28 22:49:03 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: see diff given below
Rationale: Yeah, fair enough.
Comment 7 contributor 2011-10-28 22:49:21 UTC
Checked in as WHATWG revision r6779.
Check-in comment: Make setting <img crossorigin> refetch the image.
http://html5.org/tools/web-apps-tracker?from=6778&to=6779
Comment 8 contributor 2011-10-28 22:59:56 UTC
Checked in as WHATWG revision r6780.
Check-in comment: Tweak the algorithm for <img> loading to avoid multiple network requests when src='' is set multiple times in a row.
http://html5.org/tools/web-apps-tracker?from=6779&to=6780