Bug 264657 - cloneNode in safari waste network resources if the node includes an img tag in a picture tag
Summary: cloneNode in safari waste network resources if the node includes an img tag i...
Status: REOPENED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 16
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: BrowserCompat, InRadar
Depends on:
Blocks:
 
Reported: 2023-11-10 23:21 PST by Muka
Modified: 2023-11-20 18:45 PST (History)
2 users (show)

See Also:


Attachments
testcase.html (574 bytes, text/html)
2023-11-20 18:44 PST, Karl Dubost
no flags Details
rendering in safari, firefox, chrome (486.81 KB, image/png)
2023-11-20 18:45 PST, Karl Dubost
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.