fix: crash on background-size with calc() (fix #2469) (#2569)

This commit is contained in:
Niklas von Hertzen 2021-07-12 19:09:57 +08:00 committed by GitHub
parent 4555940d0b
commit 084017a673
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -91,6 +91,10 @@ export const calculateBackgroundSize = (
): [number, number] => { ): [number, number] => {
const [first, second] = size; const [first, second] = size;
if (!first) {
return [0, 0];
}
if (isLengthPercentage(first) && second && isLengthPercentage(second)) { if (isLengthPercentage(first) && second && isLengthPercentage(second)) {
return [getAbsoluteValue(first, bounds.width), getAbsoluteValue(second, bounds.height)]; return [getAbsoluteValue(first, bounds.width), getAbsoluteValue(second, bounds.height)];
} }

View File

@ -61,6 +61,7 @@
<div style='background-size: auto;'></div> <div style='background-size: auto;'></div>
</div> </div>
<div class="container" style="padding: 10px; background-size: contain; background-origin: content-box; background-clip: content-box"></div> <div class="container" style="padding: 10px; background-size: contain; background-origin: content-box; background-clip: content-box"></div>
<div class="container" style="background-size: calc(100% - 10px)"></div>
<div class="sliver"> <div class="sliver">
<div></div> <div></div>
</div> </div>