<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>24958</bug_id>
          
          <creation_ts>2014-03-06 15:45:13 +0000</creation_ts>
          <short_desc>&lt;img&gt;: When exactly should &quot;update the image data&quot; run?</short_desc>
          <delta_ts>2015-09-16 12:44:17 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#the-img-element</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Simon Pieters">zcorpan</assigned_to>
          <cc>bzbarsky</cc>
    
    <cc>ian</cc>
    
    <cc>johns</cc>
    
    <cc>mike</cc>
    
    <cc>zcorpan</cc>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>101983</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-03-06 15:45:13 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/edits.html
Multipage: http://www.whatwg.org/C#the-img-element
Complete: http://www.whatwg.org/c#the-img-element
Referrer: http://www.whatwg.org/specs/web-apps/current-work/multipage/

Comment:
When exactly should &quot;update the image data&quot; run?

Posted from: 98.110.194.132 by bzbarsky@mit.edu
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:30.0) Gecko/20100101 Firefox/30.0</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>101984</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-03-06 15:46:25 +0000</bug_when>
    <thetext>For example, if you have an img and you do:

  img.crossOrigin = img.crossOrigin;

does that update the image data?

What about:

  img.src = img.src;

?

Note that I believe it&apos;s a web compat requirement that the latter do so (at least to the extent of resetting GIF animations) but it would be nice if the former did not.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>101985</commentid>
    <comment_count>2</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-03-06 15:53:23 +0000</bug_when>
    <thetext>Oh, and I bet whether &quot;update the image data&quot; runs is observable via load events on the image or something, not just via whether the image data changes.  :(</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102001</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-03-06 19:15:03 +0000</bug_when>
    <thetext>The spec says:

# A user agent that obtains images immediately must synchronously update the image 
# data of an img element whenever that element is created with a src attribute, a 
# srcset attribute, or both. A user agent that obtains images immediately must 
# also synchronously update the image data of an img element whenever that element 
# has its src, srcset, or crossorigin attribute set, changed, or removed, and 
# whenever that element&apos;s adopting steps are run.

Is that sufficiently clear?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102008</commentid>
    <comment_count>4</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-03-06 19:21:15 +0000</bug_when>
    <thetext>I&apos;m not sure it is.

Specifically, consider this case:

  img.setAttribute(&quot;src&quot;, img.getAttribute(&quot;src&quot;));

Is that the attribute being &quot;changed&quot;?  If not, is it being set?  If yes, then why does the spec draw a distinction between &quot;changed&quot; and &quot;set&quot;?

Specifically, if the usage of &quot;set&quot; and &quot;changed&quot; here refer to http://dom.spec.whatwg.org/#attribute-is-set and company then we should not be mentioning &quot;changed&quot; at all?  All we want from there is &quot;set&quot; or &quot;removed&quot;.  If we&apos;re not using those terms, then we should define the terms we&apos;re using.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102009</commentid>
    <comment_count>5</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-03-06 19:22:11 +0000</bug_when>
    <thetext>And again, that would imply that setting .crossOrigin to its existing value reloads the image, which seems suboptimal...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102010</commentid>
    <comment_count>6</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-03-06 19:23:20 +0000</bug_when>
    <thetext>Oh, and one other related thing: Gecko updates the image data differently on src sets and other changes (e.g. src sets force a cache validity check even if the URI did not change)...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102011</commentid>
    <comment_count>7</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-03-06 19:23:43 +0000</bug_when>
    <thetext>...and I seem to recall the web depending on that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102019</commentid>
    <comment_count>8</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-03-06 22:47:53 +0000</bug_when>
    <thetext>From http://www.whatwg.org/specs/web-apps/current-work/#dom-trees :
# A content attribute is said to change value only if its new value is
# different than its previous value; setting an attribute to a value it
# already has does not change it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102024</commentid>
    <comment_count>9</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-03-06 23:13:12 +0000</bug_when>
    <thetext>OK, but the use of &quot;changed&quot; here doesn&apos;t link to that definition, and the DOM uses a different one.

Can you see why I was being confused what the spec was requiring yet?

And again, setting src to its existing value should not be a no-op last I checked.  One of the few exceptions.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102087</commentid>
    <comment_count>10</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-03-07 23:04:32 +0000</bug_when>
    <thetext>I agree that the prose is confusing (though it long predates the DOM spec).

Setting the IDL attribute:
  http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2874
  http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2875

Setting the content attribute:
  http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2876

Firefox doesn&apos;t reset the animation, as far as I can tell.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102103</commentid>
    <comment_count>11</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-03-08 05:13:16 +0000</bug_when>
    <thetext>&gt; Firefox doesn&apos;t reset the animation, as far as I can tell.

Firefox 27 regressed this, along with some other src setting stuff.  Try Firefox 26 or earlier...  See &lt;https://bugzilla.mozilla.org/show_bug.cgi?id=980243&gt;.  Fixing that bug is what prompted me to look at this part of the spec, btw.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102163</commentid>
    <comment_count>12</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-03-10 21:36:48 +0000</bug_when>
    <thetext>Ah, good to know. Thanks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107854</commentid>
    <comment_count>13</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-06-16 12:07:13 +0000</bug_when>
    <thetext>Run &apos;update the image data&apos; for img.src = img.src case.
https://github.com/ResponsiveImagesCG/picture-element/commit/56512126f8ac4d69f58807df6b6cfe6d7df20ccb

Make img.src = img.src restart the animation.
https://github.com/ResponsiveImagesCG/picture-element/commit/d2888fb80c2b35070034a6c3ad5cf90a889d955f

Hixie, please move the &quot;restart the animation&quot; definition to the Rendering section. Thanks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110727</commentid>
    <comment_count>14</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-08-28 19:03:31 +0000</bug_when>
    <thetext>Done; back to you to remove the relevant paragraph in the &lt;img&gt; section.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110728</commentid>
    <comment_count>15</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-08-28 19:03:49 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r8725.
Check-in comment: Move &apos;restart the animation&apos; down
http://html5.org/tools/web-apps-tracker?from=8724&amp;to=8725</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110755</commentid>
    <comment_count>16</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-08-29 06:57:44 +0000</bug_when>
    <thetext>https://github.com/ResponsiveImagesCG/picture-element/commit/9c3de000b48dc8181fd7564f9ccea99a927668ba</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>