Bug 264657

Summary: cloneNode in safari waste network resources if the node includes an img tag in a picture tag
Product: WebKit Reporter: Muka <nakazato.muka>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: REOPENED ---    
Severity: Normal CC: karlcow, webkit-bug-importer
Priority: P2 Keywords: BrowserCompat, InRadar
Version: Safari 16   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
testcase.html
none
rendering in safari, firefox, chrome none

Description Muka 2023-11-10 23:21:51 PST
When cloneNode(true) is executed on a node including an img tag included in a picture tag, the source written in an img tag will be loaded, in spite of a source tag above.
This behavior doesn't occur on chrome.
The code below is minimal example.

<!DOCTYPE html>
<html>
  <body>
    <picture id="photo">
      <source srcset="./photo.webp" type="image/webp">
      <img src="./photo.jpg" alt="photo">
    </picture>
    <div id="container"></div>
    <script>
      const photo = document.getElementById("photo");
      const clonedPhoto =photo.cloneNode(true);
      document.getElementById('container').appendChild(clonedPhoto);
    </script>
  </body>
</html>

This is a bug?

Versions: OS: Apple M1 13.4.1 (c)(22F770820d)(※This behavior occurs on iPhone, too.) 
Safari: 16.5.2 (18615.2.9.11.10)
Comment 1 Alexey Proskuryakov 2023-11-13 16:44:52 PST

*** This bug has been marked as a duplicate of bug 61452 ***
Comment 2 Muka 2023-11-13 17:08:23 PST
(In reply to Alexey Proskuryakov from comment #1)
> 
> *** This bug has been marked as a duplicate of bug 61452 ***

I think that this bug is not duplicate of bug 61452.
bug 61452 says " document.documentElement.cloneNode(true) causes resources to be downloaded again".

This bug report says that cloneNode(true) causes network requests(i.e., images in img tags in picture tag) that would normally never occur.
Comment 3 Radar WebKit Bug Importer 2023-11-17 23:22:12 PST
<rdar://problem/118594370>
Comment 4 Karl Dubost 2023-11-20 18:44:49 PST
Created attachment 468696 [details]
testcase.html

The test
Comment 5 Karl Dubost 2023-11-20 18:45:59 PST
Created attachment 468697 [details]
rendering in safari, firefox, chrome

Safari reloads the resource
while other browsers ignore.