Skip to content

Commit

Permalink
fix: crash on background-size with calc() (fix #2469) (#2569)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasvh authored Jul 12, 2021
1 parent 4555940 commit 084017a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/render/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)];
}
Expand Down
1 change: 1 addition & 0 deletions tests/reftests/background/size.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<div style='background-size: auto;'></div>
</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></div>
</div>
Expand Down

0 comments on commit 084017a

Please sign in to comment.