From 084017a67319a993d73c6bdf612dd8532f1b8dbe Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Mon, 12 Jul 2021 19:09:57 +0800 Subject: [PATCH] fix: crash on background-size with calc() (fix #2469) (#2569) --- src/render/background.ts | 4 ++++ tests/reftests/background/size.html | 1 + 2 files changed, 5 insertions(+) diff --git a/src/render/background.ts b/src/render/background.ts index 3fed4d3..6e0e877 100644 --- a/src/render/background.ts +++ b/src/render/background.ts @@ -91,6 +91,10 @@ export const calculateBackgroundSize = ( ): [number, number] => { const [first, second] = size; + if (!first) { + return [0, 0]; + } + if (isLengthPercentage(first) && second && isLengthPercentage(second)) { return [getAbsoluteValue(first, bounds.width), getAbsoluteValue(second, bounds.height)]; } diff --git a/tests/reftests/background/size.html b/tests/reftests/background/size.html index d551136..48b7463 100644 --- a/tests/reftests/background/size.html +++ b/tests/reftests/background/size.html @@ -61,6 +61,7 @@
+