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
Global scope object should be window
when using happy-dom
#1243
Comments
It is impossible to do with the current architecture. Right now we are copying the Window object properties to global. If they are not copied, it could mean they are not returned from PR welcome to add the key on |
@sheremet-va I'm happy to make a PR! Question though: Those two arrays are getting concatenated. What about looping over the enumerable props on happy-dom's (and jsdom's) |
We are already looping over them tho? See utils. |
Ohh, you are! It looks like the issue is that happy-dom GlobalWindow extends Window, where Is this why you resorted to a manual in the first place? If so, I'll happily just PR for some additional keys. But I'd really like to solve for future cases as well. |
I honestly don’t remember the exact reason. But some properties should not be moved to global space, as they will conflict with happy-dom. (setTimeout will go into infinite loop, for example) I prefer if we just add a key right now. Also I’ve changed how global is populated in #1256, maybe I will invest more time with globals after we resolve react issues. |
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
Describe the bug
One of my react hooks relies on a third party library (
react-use
) to function. That library references the raw globalcancelAnimationFrame()
, notwindow.cancelAnimationFrame()
. This is perfectly valid JS DOM code, but it throws an error invitest
, because the global scope object doesn't containcancelAnimationFrame()
since it is notwindow
.I think that the global scope object should be
window
when usinghappy-dom
(orjsdom
, though I'm not using it, so I'm not sure if it's working already).Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-uwd1uk?file=test/basic.test.ts
System Info
Used Package Manager
yarn
Validations
The text was updated successfully, but these errors were encountered: