Repository navigation
Ensure that img dimensions are derived synchronously - #13057
Merged
Merged
Conversation
Browsers immediately resolve dimensions for an `<img>` that is a child of a `<picture>` with a preceding `<source>` sibling. This means that adding a `<source>` and then computing the style of the `<img>` should use the dimensions of the `<source>`. However, the spec didn't account for this, as it first schedules a task. That way, only after the task would be resolved, the dimensions would be computed. Instead, the sourceset should synchronously be updated. In the task the sourceset selects an image source, which again updates the sourceset. But moving the "select a source set" before the task could mean that an "error" event would be fired to soon. As such, only updating the sourceset but leaving the rest as-is ensures the relevant new tests pass and no regressions are introduced.
Member
|
Thanks for the PR! AI reviewReviewed at dca1812. Blockers
Suggestions
Nits
("when obtaining images on demand" is basically images disabled, but the user can choose to load specific images from the context menu or similar.) |
Contributor
Author
|
Confirmed with servo/servo#48902 that indeed those fixes makes all tests in |
aniebietafia
pushed a commit
to aniebietafia/servo
that referenced
this pull request
Oct 14, 2026
…ved (servo#48902) Based on reviewer feedback in whatwg/html#13057 Testing: new WPT passes Signed-off-by: Tim van der Lippe <[email protected]>
Member
AI reviewReviewed at 46c7352 All four points from the previous review are fixed. Lint passes. Suggestions
Nits
|
zcorpan
approved these changes
Nov 4, 2026
aphrody-dev
pushed a commit
to aphrody-labs/browser
that referenced
this pull request
Nov 16, 2026
…ved (#48902) Based on reviewer feedback in whatwg/html#13057 Testing: new WPT passes Signed-off-by: Tim van der Lippe <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Browsers apply the width and height attributes of a matching source element in a picture element to the img element as soon as the DOM changes, so the computed style reflects them right away. The spec only updated the img element's dimension attribute source when selecting an image source, which happens in a microtask.
Update the image data now updates the source set synchronously, before any early return. Update the source set now resets the dimension attribute source to the img element before looking at source elements, so removing the source element or moving the img element out of the picture element reverts it. When obtaining images on demand, relevant mutations also update the source set.
Selecting the image URL stays in the microtask, since moving it could fire the error event too soon.
Fixes #8207.
(See WHATWG Working Mode: Changes for more details.)
/images.html ( diff )