@@ -192,6 +192,13 @@ export function transition(flags, element, get_fn, get_params) {
192
192
193
193
var inert = element . inert ;
194
194
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
+
195
202
/** @type {Animation | undefined } */
196
203
var intro ;
197
204
@@ -242,6 +249,8 @@ export function transition(flags, element, get_fn, get_params) {
242
249
// Ensure we cancel the animation to prevent leaking
243
250
intro ?. abort ( ) ;
244
251
intro = current_options = undefined ;
252
+
253
+ element . style . overflow = overflow ;
245
254
} ) ;
246
255
} ,
247
256
out ( fn ) {
@@ -382,16 +391,29 @@ function animate(element, options, counterpart, t2, on_finish) {
382
391
var keyframes = [ ] ;
383
392
384
393
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
+
385
401
if ( css ) {
386
402
var n = Math . ceil ( duration / ( 1000 / 60 ) ) ; // `n` must be an integer, or we risk missing the `t2` value
387
403
388
404
for ( var i = 0 ; i <= n ; i += 1 ) {
389
405
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' ;
392
410
}
393
411
}
394
412
413
+ if ( needs_overflow_hidden ) {
414
+ /** @type {HTMLElement } */ ( element ) . style . overflow = 'hidden' ;
415
+ }
416
+
395
417
get_t = ( ) => {
396
418
var time = /** @type {number } */ (
397
419
/** @type {globalThis.Animation } */ ( animation ) . currentTime
0 commit comments