Make naturalWidth & naturalHeight return non-0 when the image lacks a dimension#12382
Merged
Make naturalWidth & naturalHeight return non-0 when the image lacks a dimension#12382
Conversation
… dimension Unfortunately the more correct behavior was never implemented widely enough and web content started to depend on these properties being non-0. We take special care that dimensions that are missing do not get divided by density so we return the same values for them as CSS (300 by 150).
annevk
added a commit
to web-platform-tests/wpt
that referenced
this pull request
Apr 17, 2026
The change from the tentative version is that image density does not impact the 300 x 150 fallback so when intrinsic dimensions are missing we use the same values in the API and rendering. This complements whatwg/html#12382.
Contributor
I'm on board with this change, on behalf of Firefox/Gecko, FWIW. Thank you for doing this, @annevk ! |
Contributor
|
I skimmed the commit itself and didn't see anything obviously incorrect. @annevk let me know if you'd like me to officially review in the github review UI. I'm happy to do so if that's useful -- but also, I'm not an html-spec-editor, so I might not satisfy the "reviewers with write access" landing-condition. (And I might also be oblivious to bespoke syntax/formatting requirements in the html spec etc.) |
zcorpan
approved these changes
Apr 22, 2026
annevk
added a commit
to web-platform-tests/wpt
that referenced
this pull request
Apr 22, 2026
The change from the tentative version is that image density does not impact the 300 x 150 fallback so when intrinsic dimensions are missing we use the same values in the API and rendering. This complements whatwg/html#12382.
annevk
added a commit
to web-platform-tests/wpt
that referenced
this pull request
Apr 22, 2026
The change from the tentative version is that image density does not impact the 300 x 150 fallback so when intrinsic dimensions are missing we use the same values in the API and rendering. This complements whatwg/html#12382.
lando-worker Bot
pushed a commit
to mozilla-firefox/firefox
that referenced
this pull request
Apr 28, 2026
…ight for SVG, a=testonly Automatic update from web-platform-tests HTML: correct naturalWidth and naturalHeight for SVG The change from the tentative version is that image density does not impact the 300 x 150 fallback so when intrinsic dimensions are missing we use the same values in the API and rendering. This complements whatwg/html#12382. -- wpt-commits: 4a0dd7000d8b0b174f7f857d8362708fa8f0cdd0 wpt-pr: 59304
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.
Unfortunately the more correct behavior was never implemented widely enough and web content started to depend on these properties being non-0.
We take special care that dimensions that are missing do not get divided by density so we return the same values for them as CSS (300 by 150).
Fixes #11287.
(See WHATWG Working Mode: Changes for more details.)
/embedded-content.html ( diff )
/images.html ( diff )
/infrastructure.html ( diff )