Skip to content

Images keep their old image when a viewport change leaves no source that applies #13365

In review

Description

@zcorpan

https://html.spec.whatwg.org/multipage/images.html#reacting-to-environment-changes says:

  1. ⌛ Let selected be the result of selecting an image source given the img element.

  2. ⌛ If selected is null, then return.

So when a viewport change leaves no source that applies, the img keeps its current image. For example, <picture><source media="(min-width: 500px)" srcset="wide.png"><img alt=""></picture> keeps showing wide.png when the viewport shrinks below 500px.

Firefox Nightly, Chrome Canary and Safari TP clear the image instead: currentSrc becomes "", naturalWidth becomes 0 and decode() rejects. None of them fire load or error. Test: web-platform-tests/wpt#65986.

Maybe this step should clear the image like update the image data does when nothing is selected, but without the error event.

Activity

  1. added
    topic: img
    on Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: img

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions