From 27fbc1456dd5c2b69daf31ee554041b5205d9bd7 Mon Sep 17 00:00:00 2001 From: Alex Svetkin Date: Sat, 18 Oct 2025 16:54:48 +0200 Subject: [PATCH] fix: keyframe names are ordered --- styles/stylemanager.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/styles/stylemanager.go b/styles/stylemanager.go index d729f8a..7163f14 100644 --- a/styles/stylemanager.go +++ b/styles/stylemanager.go @@ -95,7 +95,9 @@ func (sm *StyleManager) GenerateCSS() string { for animationName, keyframes := range sm.animations { builder.WriteString(fmt.Sprintf("@keyframes %s { ", animationName)) - for key, style := range keyframes { + keys := sortedKeys(keyframes) + for _, key := range keys { + style := keyframes[key] builder.WriteString(fmt.Sprintf("%s { ", key)) for prop, value := range style { builder.WriteString(fmt.Sprintf("%s: %s; ", prop, value)) @@ -174,10 +176,10 @@ func ensureMediaPrefix(mediaQuery string) string { return mediaQuery } -// sortedKeys returns the keys of the map sorted alphabetically. -func sortedKeys(style Props) []string { - keys := make([]string, 0, len(style)) - for key := range style { +// sortedKeys returns the keys of the map sorted alphanumerically +func sortedKeys[T any](m map[string]T) []string { + keys := make([]string, 0, len(m)) + for key := range m { keys = append(keys, key) } sort.Strings(keys)