From 5cfff8d6d35e9a2509aa6495fe8ee9eb96703939 Mon Sep 17 00:00:00 2001 From: pushkin Date: Tue, 13 Oct 2020 11:14:35 +0200 Subject: [PATCH] Update dom.ts --- src/runtime/internal/dom.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index 5380443fbc..38ed48fcf5 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -260,6 +260,11 @@ export function is_crossorigin() { } export function add_resize_listener(node: HTMLElement, fn: () => void) { + if ('ResizeObserver' in window) { + const obs = new ResizeObserver(fn); + obs.observe(node); + return obs.disconnect.bind(obs); + } const computed_style = getComputedStyle(node); const z_index = (parseInt(computed_style.zIndex) || 0) - 1;