@@ -192,6 +192,13 @@ export function transition(flags, element, get_fn, get_params) {
192192
193193 var inert = element . inert ;
194194
195+ /**
196+ * The default overflow style, stashed so we can revert changes during the transition
197+ * that are necessary to work around a Safari <18 bug
198+ * TODO 6.0 remove this, if older versions of Safari have died out enough
199+ */
200+ var overflow = element . style . overflow ;
201+
195202 /** @type {Animation | undefined } */
196203 var intro ;
197204
@@ -242,6 +249,8 @@ export function transition(flags, element, get_fn, get_params) {
242249 // Ensure we cancel the animation to prevent leaking
243250 intro ?. abort ( ) ;
244251 intro = current_options = undefined ;
252+
253+ element . style . overflow = overflow ;
245254 } ) ;
246255 } ,
247256 out ( fn ) {
@@ -382,16 +391,29 @@ function animate(element, options, counterpart, t2, on_finish) {
382391 var keyframes = [ ] ;
383392
384393 if ( duration > 0 ) {
394+ /**
395+ * Whether or not the CSS includes `overflow: hidden`, in which case we need to
396+ * add it as an inline style to work around a Safari <18 bug
397+ * TODO 6.0 remove this, if possible
398+ */
399+ var needs_overflow_hidden = false ;
400+
385401 if ( css ) {
386402 var n = Math . ceil ( duration / ( 1000 / 60 ) ) ; // `n` must be an integer, or we risk missing the `t2` value
387403
388404 for ( var i = 0 ; i <= n ; i += 1 ) {
389405 var t = t1 + delta * easing ( i / n ) ;
390- var styles = css ( t , 1 - t ) ;
391- keyframes . push ( css_to_keyframe ( styles ) ) ;
406+ var styles = css_to_keyframe ( css ( t , 1 - t ) ) ;
407+ keyframes . push ( styles ) ;
408+
409+ needs_overflow_hidden ||= styles . overflow === 'hidden' ;
392410 }
393411 }
394412
413+ if ( needs_overflow_hidden ) {
414+ /** @type {HTMLElement } */ ( element ) . style . overflow = 'hidden' ;
415+ }
416+
395417 get_t = ( ) => {
396418 var time = /** @type {number } */ (
397419 /** @type {globalThis.Animation } */ ( animation ) . currentTime
0 commit comments