Update the image data - setting src to the same value logic seems incorrect
https://html.spec.whatwg.org/multipage/images.html#updating-the-image-data
step 13:
If urlString is the same as the current request's current URL and current request's state is partially available, then abort the image request for the pending request, queue an element task on the DOM manipulation task source given the img element to restart the animation if restart animation is set, and return.
So this only restarts the animation / returns if current request's state is partially available, not if it's completely available. That seems wrong. cc @yoavweiss
I think it should be:
- If urlString is the same as the current request's current URL:
- If current request's state is partially available, then abort the image request for the pending request.
- If restart animation is set, then queue an element task on the DOM manipulation task source given the img element to restart the animation.
- Return.
Sounds reasonable to me!
I think i am capable of solving this issue, Can you please assign this to me?
I will just need some of your guidance as it will my first issue.
@Parthmahajan29 - I believe Simon is OOO for the next month or so. If you're interested in sending a PR for this, I'm happy to help with reviews :)
I am able to do the chances asked for, but i unable to find the file where i have to make the chances, can you help me with that
I just want to know where i have to do the chances?
https://github.com/whatwg/html-build can be a good place to start. The HTML source is where you want to apply the changes.
Also, the WHATWG matrix may be a good place to ask for assistance.
Ohk i will try my best for this project
Ohk Sir now i had solved the issue what should i do now?
@Parthmahajan29 submit a pull request: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request
Hmmm, actually I think the current spec may be correct.
If the image is completely available, it will be in the "list of available images", and so step 6.3.7.1 restarts the animation. (This step is exercised by https://github.com/web-platform-tests/wpt/pull/35468 )
If the image is still loading, the step here will restart the animation. I'm not sure if browsers start to animate images before they're completely loaded, though. This probably needs some more testing.
Here's a demo (with a local wpt serve running):
data:text/html,<img src=http://web-platform.test:8000/css/CSS2/backgrounds/support/animated.gif?pipe=trickle(1200:d10)%20id=x%3E%3Cbutton%20onclick=%22x.src=x.getAttribute(%27src%27)%22%3Eset%20src%3C/button%3E
In Chrome, it starts playing the animation while the image is still loading. Setting src restarts the animation but doesn't re-fetch.
In Safari, the animation is stuck on the first frame while loading. When setting src, it plays to the second frame and gets stuck there.
In Firefox, it starts playing the animation while the image is still loading. Setting src does not restart the animation (while still loading), and also doesn't re-fetch
In all browsers, after the image is fully loaded, setting src restarts the animation.
I think Chrome's behavior seems best.
Why would you want to restart animation if there isn't a re-fetch? If setting src to src doesn't re-fetch, I wouldn't expect it to do anything else either.
It's in the spec because it's something all browsers do.
But you just said it isn't, didn't you :) I mean in the comment above.
Ah, yeah, I wasn't talking about the fully loaded and you are.
Right, setting src while an animated image is still being loaded is an edge case where browsers disagree.