Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change window to globalThis in Virtualizer.ts for SSR #4564

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/rare-actors-grab.md
@@ -0,0 +1,7 @@
---
'@lit-labs/virtualizer': major
---

BREAKING: Replace top-level access to `window` with `globalThis` so that loading the module won't error in non-browser environments.

A polyfill for `globalThis` may be needed if you are targeting an environment that does not support it.
3 changes: 2 additions & 1 deletion packages/labs/virtualizer/src/Virtualizer.ts
Expand Up @@ -34,7 +34,8 @@ import {ScrollerController} from './ScrollerController.js';
// polyfill in the package; this bit of module state facilitates
// a simple mechanism (see ./polyfillLoaders/ResizeObserver.js.)
// for loading the polyfill.
let _ResizeObserver: typeof ResizeObserver | undefined = window?.ResizeObserver;
let _ResizeObserver: typeof ResizeObserver | undefined =
globalThis.ResizeObserver;

/**
* Call this function to provide a `ResizeObserver` polyfill for Virtualizer to use.
Expand Down