diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index ca76b11ab3e9..52f1198833c6 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -624,6 +624,10 @@ export function add_resize_listener(node: HTMLElement, fn: () => void) { iframe.src = 'about:blank'; iframe.onload = () => { unsubscribe = listen(iframe.contentWindow, 'resize', fn); + + // make sure an initial resize event is fired _after_ the iframe is loaded (which is asynchronous) + // see https://github.com/sveltejs/svelte/issues/4233 + fn(); }; }