Skip to content

Svelte's usage of the :where CSS selector breaks sites in Safari 12 and 13 #14518

Open
@kevinrenskers

Description

@kevinrenskers

Describe the bug

Svelte uses the :where CSS selector when you use a CSS selector like li.main-menu:hover ul. Svelte turns that into .main-menu.svelte-13eihuy:hover ul:where(.svelte-13eihuy).

This :where selector has only been added to Safari in version 14.

The fix is to change li.main-menu:hover ul into li.main-menu:hover :global(ul), but this is not obvious and you won't notice that your CSS doesn't work in older browsers unless you specifically test your site in them.

Now obviously I know that Safari 12 and 13 are quite old, but aren't they supported by Svelte? What is the list of supported browsers anyway?

Reproduction

I have an extremely simple version here in the playground:

https://svelte.dev/playground/ca3a0989871744e7b2d43959c9d6f574?version=5.4.0

When you inspect the generated css, you will see this:

	.main-menu.svelte-13eihuy ul:where(.svelte-13eihuy) {
		display: none;
	}

	.main-menu.svelte-13eihuy:hover ul:where(.svelte-13eihuy) {
		display: block;
	}

This will not work in Safari 12 or 13.

Logs

No response

System Info

System:
    OS: macOS 15.1.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 161.03 MB / 32.00 GB
    Shell: 3.7.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 20.17.0 - ~/Library/pnpm/node
    npm: 10.8.2 - ~/Library/pnpm/npm
    pnpm: 9.13.2 - ~/Library/pnpm/pnpm
  Browsers:
    Safari: 18.1.1
  npmPackages:
    svelte: ^5.2.4 => 5.2.4

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    cssStuff related to Svelte's built-in CSS handling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions