<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>264392</bug_id>
          
          <creation_ts>2023-11-08 01:23:33 -0800</creation_ts>
          <short_desc>Margin accumulates on every layout in Shadow DOM</short_desc>
          <delta_ts>2024-04-15 04:21:51 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Layout and Rendering</component>
          <version>Safari 17</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="oceansky">cris</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>bfulgham</cc>
    
    <cc>koivisto</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1990773</commentid>
    <comment_count>0</comment_count>
    <who name="oceansky">cris</who>
    <bug_when>2023-11-08 01:23:33 -0800</bug_when>
    <thetext>Hello, 

This bug is best described by seeing it in action. I have created a minimal reproduction here:

  https://github.com/00000o1/-/blob/boss/bug-examples/safari-bug-nov-8-2023/index.html

Or you can try it live on the GitHub pages site:

  https://00000o1.github.io/-/bug-examples/safari-bug-nov-8-2023/index.html

I have explained the bug on that page. I will copy the description section below for convenience:



There is no code to add the increasing margin that you see. It simply occurs.

What&apos;s required to summon this bug?

- The custom elements
- &lt;!DOCTYPE html&gt;
- :host { margin: XXXpx; }
   I checked values including 0.1px, 1px, 84px, 999px and all reproduced the bug. 0px did not as did removing this rule.

If you remove any of these, the bug refuses to be conjured.

What version of Safari was this discovered in?

I&apos;ve only checked with Version 17.1 (18616.2.9.11.9, 18616) on Ventura and Safari on iOS 16.7.2 (20H115). They both reproduce the bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1992724</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-11-15 01:24:18 -0800</bug_when>
    <thetext>&lt;rdar://problem/118443538&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1992882</commentid>
    <comment_count>2</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2023-11-15 13:44:54 -0800</bug_when>
    <thetext>Could you describe what the bug actually is? I&apos;ve loaded your test case, and I see &quot;I am the bug&quot; but it would be better to say something like &quot;You should see a green box below, but it&apos;s hidden&quot; or something.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1993766</commentid>
    <comment_count>3</comment_count>
    <who name="oceansky">cris</who>
    <bug_when>2023-11-19 11:50:03 -0800</bug_when>
    <thetext>Hello Simon Fraser,

Yes, thank you, I&apos;m sorry about that! You&apos;re right that it could indeed be described better.

The bug is the accumulation of a margin when the custom element is re-rendered. The result is that the paragraph and button are pushed down on each render, by this growing &apos;ghost&apos; margin. I do not know if it is actually a &quot;margin&quot;, but its effect is similar. 

The only data change is an increment of a counter, displayed as text in the paragraph, which seems unlikely to account for it. Yet it occurs! 

Examining the DOM in Inspector does not reveal any node leak: there are not unintended nodes being added at each render. 

I could not find any CSS (styled or computed) that defines this increasing offset.

There is no code, style, or change it seems that creates this margin in the reproduction, it simply occurs.

It&apos;s entirely possible I simply may have missed something. The reproduction code is very straightforward, so that seems unlikely, tho not impossible!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1993767</commentid>
    <comment_count>4</comment_count>
    <who name="oceansky">cris</who>
    <bug_when>2023-11-19 11:52:40 -0800</bug_when>
    <thetext>Hit the &quot;Show me the Bug&quot; button to see it in action.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1996622</commentid>
    <comment_count>5</comment_count>
    <who name="oceansky">cris</who>
    <bug_when>2023-12-03 20:41:02 -0800</bug_when>
    <thetext>Confirmed this still exists in Version 17.1.2 (18616.2.9.11.12, 18616)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1996773</commentid>
    <comment_count>6</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2023-12-04 10:28:56 -0800</bug_when>
    <thetext>Does this only happen when using Shadow DOM?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1996991</commentid>
    <comment_count>7</comment_count>
    <who name="oceansky">cris</who>
    <bug_when>2023-12-04 21:08:33 -0800</bug_when>
    <thetext>Let me double check that. I will replace this.shadow.innerText = ... with this.innerText and not create a shadow. Hold on a bit... ! :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1996996</commentid>
    <comment_count>8</comment_count>
    <who name="oceansky">cris</who>
    <bug_when>2023-12-04 21:21:15 -0800</bug_when>
    <thetext>Simon Fraser, you are correct! Your suspicion was right, this only occurs when using Shadow DOM. I&apos;ve created an absent test case here with no Shadow DOM and no Bug: https://00000o1.github.io/-/bug-examples/safari-bug-nov-8-2023-variant-2/index.html

Thank you for the clarifying question! :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2000148</commentid>
    <comment_count>9</comment_count>
    <who name="oceansky">cris</who>
    <bug_when>2023-12-15 21:52:21 -0800</bug_when>
    <thetext>Confirmed that this still exists on Safari Version 17.2 (18617.1.17.11.11, 18617)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2028474</commentid>
    <comment_count>10</comment_count>
      <attachid>470924</attachid>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-04-15 04:21:51 -0700</bug_when>
    <thetext>Created attachment 470924
Testcase (from GitHub)

STR:

1) Load testcase
2) Click `show me the bug&apos; button (once or multiple time)

Expected Result:

No change in layout

Actual Result:

On each click, the button gets pushed down.

____

Chrome Canary 125 and Firefox Nightly 126 are working as expected. While STP192 is also broken.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>470924</attachid>
            <date>2024-04-15 04:21:51 -0700</date>
            <delta_ts>2024-04-15 04:21:51 -0700</delta_ts>
            <desc>Testcase (from GitHub)</desc>
            <filename>Testcase_shadow_dom.html</filename>
            <type>text/html</type>
            <size>2458</size>
            <attacher name="Ahmad Saleem">ahmad.saleem792</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxzY3JpcHQ+CiAgY2xhc3MgU2FmYXJpQnVnIGV4dGVuZHMgSFRNTEVs
ZW1lbnQgewogICAgY29uc3RydWN0b3IoKSB7CiAgICAgIHN1cGVyKCk7CiAgICAgIHRoaXMuc2hh
ZG93ID0gdGhpcy5hdHRhY2hTaGFkb3coeyBtb2RlOiAnY2xvc2VkJyB9KTsKCiAgICAgIHRoaXMu
Y291bnQgPSAwOwogICAgfQoKICAgIGNvbm5lY3RlZENhbGxiYWNrKCkgewogICAgICB0aGlzLnJl
bmRlcigpOwogICAgfQoKICAgIHJlbmRlcigpIHsKICAgICAgdGhpcy5zaGFkb3cuaW5uZXJIVE1M
ID0gYAogICAgICAgIDxzdHlsZT4KICAgICAgICAgIDpob3N0IHsKICAgICAgICAgICAgbWFyZ2lu
OiAxNnB4OwogICAgICAgICAgfQogICAgICAgIDwvc3R5bGU+CiAgICAgICAgPHA+SSBhbSBhIGJ1
ZyAke3RoaXMuY291bnR9PC9wPgogICAgICBgOwogICAgfQogIH0KCiAgY2xhc3MgU2FmYXJpQnVn
SUkgZXh0ZW5kcyBIVE1MRWxlbWVudCB7CiAgICBjb25zdHJ1Y3RvcigpI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