Skip to content

Commit

Permalink
fix(useElementSize): use contentBoxSize as an array in useElementSize
Browse files Browse the repository at this point in the history
  • Loading branch information
vaakian authored and threedayAAAAA committed Jan 5, 2023
1 parent 25f6e30 commit 0b12871
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/core/useElementSize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ export function useElementSize(
: entry.devicePixelContentBoxSize

if (boxSize) {
width.value = boxSize.reduce((acc, { inlineSize }) => acc + inlineSize, 0)
height.value = boxSize.reduce((acc, { blockSize }) => acc + blockSize, 0)
const formatBoxSize = Array.isArray(boxSize) ? boxSize : [boxSize]
width.value = formatBoxSize.reduce((acc, { inlineSize }) => acc + inlineSize, 0)
height.value = formatBoxSize.reduce((acc, { blockSize }) => acc + blockSize, 0)
}
else {
// fallback
Expand Down

0 comments on commit 0b12871

Please sign in to comment.