Bug 150443 - <img>.naturalWidth should return the density-corrected intrinsic width
Summary: <img>.naturalWidth should return the density-corrected intrinsic width
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Images (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-22 03:39 PDT by Simon Pieters
Modified: 2018-03-27 14:10 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Pieters 2015-10-22 03:39:04 PDT
Consider

   <img srcset="http://placehold.it/240 2x" onload="alert(this.naturalWidth)">

Per spec it should alert 120. WebKit alerts 240. Gecko and Blink match the spec, I don't know about Edge.

https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-naturalwidth

I would recommend waiting with fixing this bug until .currentSrc is implemented, since exploiting this bug can be a poor man's .currentSrc; see http://stackoverflow.com/questions/33231426/get-the-currentsrc-of-responsive-image-on-safari/33278821