Skip to content

Commit

Permalink
Fix property name conversion in custom transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
zaninime committed Oct 23, 2024
1 parent 7ecc6c0 commit 93b54f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
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
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

0 comments on commit 93b54f9

Please sign in to comment.