Skip to content

fix: broken property name derivation in keyframe generation #13820

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

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/dull-wolves-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

Fix property name conversion in custom transitions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Fix property name conversion in custom transitions
fix: adjust property name conversion in custom transitions

12 changes: 10 additions & 2 deletions packages/svelte/src/internal/client/dom/elements/transitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ function dispatch_event(element, type) {
}

/**
* Converts a property to the camel-case format expected by Element.animate(), KeyframeEffect(), and KeyframeEffect.setKeyframes().
* @param {string} style
* @returns {string}
*/
function css_style_from_camel_case(style) {
function css_property_to_camelcase(style) {
// in compliance with spec
if (style === 'float') return 'cssFloat';
if (style === 'offset') return 'cssOffset';

// do not rename custom @properties
if (style.startsWith('--')) return style;

const parts = style.split('-');
if (parts.length === 1) return parts[0];
return (
Expand All @@ -52,7 +60,7 @@ function css_to_keyframe(css) {
const [property, value] = part.split(':');
if (!property || value === undefined) break;

const formatted_property = css_style_from_camel_case(property.trim());
const formatted_property = css_property_to_camelcase(property.trim());
keyframe[formatted_property] = value.trim();
}
return keyframe;
Expand Down