Skip to content

Commit

Permalink
fix(renderer): null check HTMLCanvasElement global
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett committed Jan 3, 2025
1 parent 49a87a7 commit 94b4e6c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/fiber/src/core/renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ export interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCan
}

function computeInitialSize(canvas: HTMLCanvasElement | OffscreenCanvas, size?: Size): Size {
if (!size && canvas instanceof HTMLCanvasElement && canvas.parentElement) {
if (
!size &&
typeof HTMLCanvasElement !== 'undefined' &&
canvas instanceof HTMLCanvasElement &&
canvas.parentElement
) {
const { width, height, top, left } = canvas.parentElement.getBoundingClientRect()
return { width, height, top, left }
} else if (!size && typeof OffscreenCanvas !== 'undefined' && canvas instanceof OffscreenCanvas) {
Expand Down

0 comments on commit 94b4e6c

Please sign in to comment.