Skip to content

Svelte 5: Keyframes list with name that appears elsewhere in animation: style rule breaks CSS scoping #9879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dm-de opened this issue Dec 9, 2023 · 4 comments
Labels
bug compiler Changes relating to the compiler css Stuff related to Svelte's built-in CSS handling
Milestone

Comments

@dm-de
Copy link

dm-de commented Dec 9, 2023

Describe the bug

Svelte 5 can not play CSS animation, because wrong css is generated.

generated:
svelte-1f68qn8-animation: 1s linear infinite animation;

but should be:
animation: 1s linear infinite svelte-1f68qn8-animation;

Reproduction

<span />

<style>
	@keyframes animation {
		0% {
			transform: scale(1);
		}
		100% {
			transform: scale(2);
		}
	}

	* {
		animation: 1s linear infinite animation;
		display: block;
		width:40px;
		height:40px;
		background:red;
		border-radius:999px;
	}
</style>

CSS output:


	@keyframes svelte-1f68qn8-animation {
		0% {
			transform: scale(1);
		}
		100% {
			transform: scale(2);
		}
	}

	.svelte-1f68qn8 {
		svelte-1f68qn8-animation: 1s linear infinite animation;
		display: block;
		width:40px;
		height:40px;
		background:red;
		border-radius:999px;
	}

Logs

No response

System Info

Svelte v5.0.0-next.22

Severity

annoyance

@Conduitry Conduitry added bug compiler Changes relating to the compiler css Stuff related to Svelte's built-in CSS handling labels Dec 9, 2023
@Conduitry
Copy link
Member

It looks like this only happens when the keyframes list is called animation, and the CSS scoper gets confused about what string to replace.

@Conduitry Conduitry changed the title Spelte 5: CSS animation broken (simple bug) Svelte 5: Keyframes list called animation breaks CSS scoping Dec 9, 2023
@dm-de
Copy link
Author

dm-de commented Dec 9, 2023

I also renamed it to "anim" - but same effect.

@Conduitry
Copy link
Member

Ah, okay, yeah, if it's named anything that appears earlier in your animation: style rule before the keyframe list itself, this will break.

@Conduitry Conduitry added this to the 5.0 milestone Dec 10, 2023
@Conduitry Conduitry changed the title Svelte 5: Keyframes list called animation breaks CSS scoping Svelte 5: Keyframes list with name that appears elsewhere in animation: style rule breaks CSS scoping Dec 10, 2023
@navorite
Copy link
Contributor

navorite commented Feb 9, 2024

This should be closed as fixed @Rich-Harris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug compiler Changes relating to the compiler css Stuff related to Svelte's built-in CSS handling
Projects
None yet
Development

No branches or pull requests

4 participants