Bug 236719 - ID encapsulation is broken with fragment identifiers in SVGs within a shadowRoot
Summary: ID encapsulation is broken with fragment identifiers in SVGs within a shadowRoot
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: Safari 15
Hardware: Mac (Intel) macOS 11
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-02-16 10:46 PST by Elliot Nahman
Modified: 2023-05-14 16:19 PDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Elliot Nahman 2022-02-16 10:46:10 PST
SVGs can use fragment identifies to link various assets such as patterns, clipPaths, etc to SVG elements. When the SVG lives within a shadowRoot, the IDs of these assets should be encapsulated and just have to be unique within their respective shadow DOM.

However, I believe starting in Safari 15, this is no longer the case. Now if the same ID is used in multiple different shadow DOMs, all the references to the fragment point to the last instance put on the page. If that instance is removed from the page, then no fragment will be applied.


See https://codepen.io/nonmetalhail/pen/PoOOZaL for an example of the bug. 
In the example, you start off with two webcomponents, each with an SVG in their shadowRoots. Each SVG displays a pattern. On first render, the patterns are correct for each SVG. However, when the first SVG is re-rendered, it erroneously adopts the pattern of the second SVG. If the pattern from the second SVG is deleted (in the example the whole WC is removed), and the first re-rendered again, it is does not display any pattern even though its own pattern is still present in the its DOM.
Comment 1 Radar WebKit Bug Importer 2022-02-16 11:58:22 PST
<rdar://problem/89040063>
Comment 2 Ahmad Saleem 2023-05-14 16:19:41 PDT
I am not able to reproduce this bug in Safari 16.4.1 and WebKit ToT and it behaves similar to Chrome Canary 115.

Doing 'Re-render' on first without removing second.

--> Safari does not copy design of below element of straight stripes

Deleting second element and then 're-render':

---> Safari does not switch to straight stripe or does not render at all. It still shifts the horizontal stripes slightly similar to Chrome.

Marking this as "RESOLVED CONFIGURATION CHANGED".