[Webkit-unassigned] [Bug 177068] New: Creating a picture elm with a source and img elms triggers loading of both sources

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Sep 18 06:04:35 PDT 2017


https://bugs.webkit.org/show_bug.cgi?id=177068

            Bug ID: 177068
           Summary: Creating a picture elm with a source and img elms
                    triggers loading of both sources
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Macintosh
                OS: macOS 10.12
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Images
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: maximuse.chern at gmail.com

Created attachment 321087

  --> https://bugs.webkit.org/attachment.cgi?id=321087&action=review

Reduced test case

When an image element is created:

> const image = document.createElement('img');
> image.setAttribute('srcset', 'https://via.placeholder.com/300x100/0e7f00');

webkit starts preloading the srcset immediately.

However, when an image is intended to become part of a picture tag:

> const picture = document.createElement('picture');
> const source = document.createElement('source');
> const image = document.createElement('img');
> 
> source.setAttribute('sizes', '100vw');
> source.setAttribute('media', '(orientation: portrait)');
> 
> image.setAttribute('sizes', '100vw');
> image.setAttribute('alt', 'Placeholder'); 
> 
> source.setAttribute('srcset', 'https://via.placeholder.com/550x900/6600af 550w, https://via.placeholder.com/750x1000/a100af 750w'); 
> image.setAttribute('srcset', 'https://via.placeholder.com/300x100/0e7f00'); 
> 
> picture.appendChild(source);
> picture.appendChild(image);

I expect either the source or the image to be loaded depending on the media query, not both.

# Actual
Webkit preloads the image tag, and the source tag when it is added to the picture element.

# Expected
Only the source tag to be loaded when (orientation: portrait) or only the img to be loaded when (orientation: landscape).


Chrome handles this scenario correctly by cancelling the initial request for the image's srcset when it becomes a child of the picture element.

Reduced test case: https://s.codepen.io/maximus8891/debug/LzVjNZ/ZorBajwPWeOM

Possible duplicates:
https://bugs.webkit.org/show_bug.cgi?id=6656
https://bugs.webkit.org/show_bug.cgi?id=35377

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20170918/8655dc31/attachment.html>


More information about the webkit-unassigned mailing list