NEW 172224
Incorrect dimensions of images with srcset when adopted from document without browsing context
https://bugs.webkit.org/show_bug.cgi?id=172224
Summary Incorrect dimensions of images with srcset when adopted from document without...
Memmie Lenglet
Reported 2017-05-17 09:13:01 PDT
Created attachment 310397 [details] Test cases: nodes from documents with and without browsing context Overview: Images created from document without browsing context have incorrect dimension (width=0 and height=0) if not forced (defined with CSS). These images are loaded but not visible. NaturalHeight and naturalWidth are correctly provided (the images are loaded). This issue doesn't happend if the node is imported (Document#importNode) instead of adopted (Document#adoptNode). Steps to Reproduce, with JavaScript: 1. Create a document without browsing context (createHTMLDocument, DOMParser, removed iframe) 2. create image with srcset nodes with innerHTML or write() or createElement(), etc. 3. adopt the image node to the current document 4. append the image node Actual Results: Images are loaded (see web dev tools, load event) but the width and the height are equals 0. If with CSS, dimensions are defined (forced), the image is visible Expected Results: If dimensions are not forced, the image should have dimension match its natural width and height.
Attachments
Test cases: nodes from documents with and without browsing context (6.37 KB, text/html)
2017-05-17 09:13 PDT, Memmie Lenglet
no flags
Test cases: nodes from documents with and without browsing context (use HTTPS) (5.39 KB, text/html)
2017-05-17 09:16 PDT, Memmie Lenglet
no flags
Memmie Lenglet
Comment 1 2017-05-17 09:16:32 PDT
Created attachment 310398 [details] Test cases: nodes from documents with and without browsing context (use HTTPS)
Radar WebKit Bug Importer
Comment 2 2017-05-18 11:49:54 PDT
pnparam
Comment 3 2018-03-22 22:54:03 PDT
Check my bug report: https://bugs.webkit.org/show_bug.cgi?id=183910 It is closed based on the suggestions here: https://bugzilla.mozilla.org/show_bug.cgi?id=1448110
mic.gallego
Comment 4 2022-08-08 21:09:17 PDT
Hi, We are facing this issue as well, and I could not find any fix in the link you have provided pnparam. Is there any way to make sure that srcset is properly honored when a node is added through a fragment or DOMParser ?
Dominik Dröscher
Comment 5 2022-11-25 01:31:07 PST
I also stumbled upon this issue. Dynamically adding DOM nodes containing images with srcset will set their dimensions to 0, 0. For my case I was able to work around this by forcing a predefined aspect-ratio, but that is clearly not ideal and not applicable to most contexts.
Note You need to log in before you can comment on or make changes to this bug.