#1126·snabbdom

Fix style.ts for headless environments

Author: timcraftCreated Nov 8, 2024Updated May 12, 2025

Versions 3.6.0 and later include #1082 which removes code that checks if window is defined. This breaks in headless environments which don't have window defined, for example:

$ bun add snabbdom
bun add v1.1.32 (fe8d0079)

installed [email protected]

1 package installed [697.00ms]
$ bun repl
Welcome to Bun v1.1.32
Type ".help" for more information.
[!] Please note that the REPL implementation is still experimental!
    Don't consider it to be representative of the stability or behavior of Bun overall.
> import { h } from 'snabbdom'
1 | // Binding `requestAnimationFrame` like this fixes a bug in IE/Edge. See #360 and #409.
2 | const raf = typeof (window === null || window === void 0 ? void 0 : window.requestAnimationFrame) === "function"
                        ^
ReferenceError: Can't find variable: window

(Double checked on Node.js v22.10.0, different error message but the same error.)

Would it be possible to revert #1082 and apply #885 instead?