Bug 243341 - Gradients in an SVG are affected by parent's `display: none`, when SVG is referenced through <use>
Summary: Gradients in an SVG are affected by parent's `display: none`, when SVG is ref...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: Safari 15
Hardware: Unspecified macOS 12
: P2 Normal
Assignee: Nobody
URL: https://codepen.io/sergiomdgomes/pen/...
Keywords: BrowserCompat, InRadar, LayerBasedSVGEngine
Depends on:
Blocks:
 
Reported: 2022-07-29 08:10 PDT by Sérgio Gomes
Modified: 2024-01-04 16:17 PST (History)
5 users (show)

See Also:


Attachments
Safari test result (20.20 KB, image/png)
2022-07-29 08:10 PDT, Sérgio Gomes
no flags Details
rendering in Safari, firefox, chrome (249.18 KB, image/png)
2022-07-31 22:35 PDT, Karl Dubost
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sérgio Gomes 2022-07-29 08:10:52 PDT
Created attachment 461295 [details]
Safari test result

Steps to reproduce the problem:
1. Visit https://codepen.io/sergiomdgomes/pen/JjLOmoa?editors=1100
2. Observe result

Expected: both circles look the same, with a black stroke and a gradient fill.
Observed: the first circle has a black stroke but a solid fill.

Problem Description:
When:
- An SVG exists inside a `display: none` parent
- That SVG contains a named gradient that gets used inside the same SVG for a fill (via `url()`)
- Another SVG references the first one via SVG <use>

Then: the gradient will not render correctly.

If you visit https://codepen.io/sergiomdgomes/pen/JjLOmoa?editors=1100 you'll see that if the referenced SVG is inside a `visibility: hidden` parent, both the stroke and the fill (which uses a named gradient) will render correctly. However, if the referenced SVG is inside a `display: none` parent, then the stroke will render correctly but the fill will not.

Firefox correctly renders the stroke and the fill in both situations.

Chromium also fails to render the gradient for a referenced SVG inside a `visibility: hidden` parent, but it applies an empty fill instead of a solid one ( Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1348561 )

Note that this is not just an issue with gradients; it also seems to be an issue for other named elements, such as masks and clip paths.
Comment 1 Karl Dubost 2022-07-31 22:35:32 PDT
Created attachment 461331 [details]
rendering in Safari, firefox, chrome

Firefox Nightly 105.0a1
Google Chrome Canary 106.0.5212.0
Safari 16.0
Comment 2 Radar WebKit Bug Importer 2022-07-31 22:36:07 PDT
<rdar://problem/97892709>