Bug 230688

Summary: REGRESSION (Safari 15): Toggling object element display property reloads the object
Product: WebKit Reporter: Ben <ben.browitt>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: ahmad.saleem792, ap, bfulgham, cdumez, mike, rniwa, webkit-bug-importer, zalan
Priority: P2 Keywords: BrowserCompat, InRadar
Version: Safari Technology Preview   
Hardware: All   
OS: iOS 14   

Description Ben 2021-09-23 06:10:55 PDT
When you toggle <object> HTML element between display:block and display:none the object is reloaded.
Didn't happen on iPadOS 14.0 and doesn't happen on Chrome and FireFox.
Tested on iPadOS 15.0, 14.8

To reproduce see that the timestamp on Safari changes every time you click on the 'Toggle Display' button.
On Chrome and Firefox the timestamp doesn't change.
https://jsbin.com/yoboxuhegu/1/edit?html,output

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
</head>
<body>
    <button onclick="toggleDisplay()">Toggle Display</button>
    <object style="display: block;" data="data:text/html;utf-8,&lt;body onload='document.body.innerText = Date.now()'&gt;hello"></object>    
    <script>
        let el = document.querySelector('object');
        let count = 1;
        function log() {
          el.text = count;
          count++;
        }
      
        function toggleDisplay() {
            let display = el.style.display == 'block' ? 'none' : 'block';
            el.style.display = display;
        }
    </script>
</body>
</html>
Comment 1 Radar WebKit Bug Importer 2021-09-25 12:09:50 PDT
<rdar://problem/83534931>
Comment 2 Ahmad Saleem 2022-08-10 04:29:27 PDT
I am able to reproduce this bug in Safari 15.6 and Technical Preview 150 on macOS 12.5 and toggling "Display" button changes timestamp every time unlike other browsers (Chrome Canary 106 and Firefox Nightly 105). Thanks!
Comment 3 Ahmad Saleem 2023-06-14 15:59:33 PDT
Adding 'BrowserCompat' since it is still reproducible in STP172.