@@ -92,6 +92,25 @@ describe('stringifyAnimation', () => {
9292 assert . ok ( result . includes ( 'both' ) ) ;
9393 } ) ;
9494
95+ it ( 'escapes CSS delimiters in animation values' , ( ) => {
96+ const result = stringifyAnimation ( {
97+ name : 'fade' ,
98+ duration : '1ms;}custom{value' ,
99+ } ) ;
100+
101+ assert . ok ( result . includes ( 'animation-duration: 1ms\\3B \\7D custom\\7B value;' ) ) ;
102+ assert . ok ( ! result . includes ( '}custom{' ) ) ;
103+ } ) ;
104+
105+ it ( 'preserves CSS functions in animation values' , ( ) => {
106+ const result = stringifyAnimation ( {
107+ name : 'fade' ,
108+ duration : 'calc(1s + var(--transition-delay, 200ms))' ,
109+ } ) ;
110+
111+ assert . ok ( result . includes ( 'calc(1s + var(--transition-delay, 200ms))' ) ) ;
112+ } ) ;
113+
95114 it ( 'accepts an array of animations' , ( ) => {
96115 const result = stringifyAnimation ( [ { name : 'fade-in' } , { name : 'slide-in' } ] ) ;
97116 assert . ok ( result . includes ( 'fade-in' ) ) ;
@@ -224,4 +243,26 @@ describe('renderTransition', () => {
224243 assert . equal ( $ ( 'head script' ) . length , 0 ) ;
225244 assert . ok ( style . includes ( '\\3C /style>\\3C script>test\\3C /script>' ) ) ;
226245 } ) ;
246+
247+ it ( 'keeps animation values inside their generated CSS declarations' , ( ) => {
248+ const result = {
249+ _metadata : { extraHead : [ ] } ,
250+ } as unknown as SSRResult ;
251+ const animation = {
252+ forwards : {
253+ old : { name : 'fade' , duration : '1ms;}custom{value' } ,
254+ new : { name : 'fade' } ,
255+ } ,
256+ backwards : {
257+ old : { name : 'fade' } ,
258+ new : { name : 'fade' } ,
259+ } ,
260+ } ;
261+
262+ renderTransition ( result , 'hash' , animation , 'name' ) ;
263+
264+ const style = String ( result . _metadata . extraHead [ 0 ] ) ;
265+ assert . ok ( style . includes ( 'animation-duration: 1ms\\3B \\7D custom\\7B value;' ) ) ;
266+ assert . ok ( ! style . includes ( '}custom{' ) ) ;
267+ } ) ;
227268} ) ;
0 commit comments