Bug 294315
| Summary: | prefers-color scheme is not applied to svg image when inserted through img or background css | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Karl Dubost <karlcow> |
| Component: | CSS | Assignee: | Kiet Ho <kiet.ho> |
| Status: | NEW | ||
| Severity: | Normal | CC: | kiet.ho, koivisto, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| URL: | https://wpt.live/css/mediaqueries/prefers-color-scheme-svg-image.html | ||
| See Also: | https://bugs.webkit.org/show_bug.cgi?id=314270 | ||
Karl Dubost
https://wpt.fyi/results/css/mediaqueries/prefers-color-scheme-svg-image.html
https://wpt.live/css/mediaqueries/prefers-color-scheme-svg-image.html
The SVG called directy is changing color depending on the preferred color scheme when called directly.
But once it is called through an img element or a CSS background property it fails.
The test is basically.
<div style="color-scheme: dark">
<img src="resources/prefers-color-scheme.svg">
<div class="background"></div>
</div>
with the SVG being
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<style>
:root { color: blue }
@media (prefers-color-scheme: dark) {
:root { color: purple }
}
</style>
<rect fill="currentColor" width="32" height="32"/>
</svg>
The SVG stays blue instead of being purple.
This would have impact on anyone using SVG icon with dark theme.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/153716346>