From 56caa45e9112ed19f75123110d9ab8e21d80ff52 Mon Sep 17 00:00:00 2001 From: Johann Schopplich Date: Sun, 10 Nov 2024 11:51:10 +0100 Subject: [PATCH] refactor(core): rename observer var --- packages/core/src/lazyLoad.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/core/src/lazyLoad.ts b/packages/core/src/lazyLoad.ts index 55c7e0c..1464146 100644 --- a/packages/core/src/lazyLoad.ts +++ b/packages/core/src/lazyLoad.ts @@ -187,7 +187,7 @@ export function createPlaceholderFromHash( // Keep track of elements that have a `data-sizes="auto"` attribute // and need to be updated when their size changes -const resizeElementStore = new WeakMap() +const elementResizeObserverMap = new WeakMap() function updateSizesAttribute( element: HTMLImageElement | HTMLSourceElement, @@ -215,18 +215,18 @@ function updateSizesAttribute( } if (options?.updateOnResize) { - if (!resizeElementStore.has(element)) { + if (!elementResizeObserverMap.has(element)) { const debounceResize = debounce(() => updateSizesAttribute(element), 500) const observerInstance = new ResizeObserver(debounceResize) - resizeElementStore.set(element, observerInstance) + elementResizeObserverMap.set(element, observerInstance) observerInstance.observe(element) } return () => { - const observerInstance = resizeElementStore.get(element) + const observerInstance = elementResizeObserverMap.get(element) if (observerInstance) { observerInstance.disconnect() - resizeElementStore.delete(element) + elementResizeObserverMap.delete(element) } } }