From 1472dc854ce5f204a0977cb45f87a1bde978f83f Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Wed, 21 Jul 2021 18:32:07 +0200 Subject: [PATCH] Deal with case where no style.{width,height} is set for size dimensions --- ts/editor/ImageHandle.svelte | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ts/editor/ImageHandle.svelte b/ts/editor/ImageHandle.svelte index c67744731..2f20f2101 100644 --- a/ts/editor/ImageHandle.svelte +++ b/ts/editor/ImageHandle.svelte @@ -71,14 +71,22 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html height = image!.clientHeight; const widthProperty = image!.style.width; - actualWidth = widthProperty.endsWith("px") - ? widthProperty.substring(0, widthProperty.length - 2) - : widthProperty; + if (widthProperty) { + actualWidth = widthProperty.endsWith("px") + ? widthProperty.substring(0, widthProperty.length - 2) + : widthProperty; + } else { + actualWidth = String(width); + } const heightProperty = image!.style.height; - actualHeight = heightProperty.endsWith("px") - ? heightProperty.substring(0, heightProperty.length - 2) - : heightProperty; + if (heightProperty) { + actualHeight = heightProperty.endsWith("px") + ? heightProperty.substring(0, heightProperty.length - 2) + : heightProperty; + } else { + actualHeight = String(height); + } } function setPointerCapture(event: PointerEvent): void {