Is your feature request related to a problem? Please describe.
Could it be possible to add support for ResizeObserver?
I'm currently using vitest + happy-dom and I had a poor stub for the ResizeObserver; although it wasn't working but I didn't really know why, at first.
Then I noticed this in my code:
if (typeof global.ResizeObserver !== 'undefined') {
return global.ResizeObserver;
}
So it made me realize that happy-dom already has a ResizeObserver stub with a bunch of // TODO 😅
Describe the solution you'd like
My poor stub is far from optimal so I'm not going to share it here as it's not worth it; and I'm unsure how hard it'd be to build one from scratch.
Is your feature request related to a problem? Please describe. Could it be possible to add support for ResizeObserver?
I'm currently using vitest + happy-dom and I had a poor stub for the ResizeObserver; although it wasn't working but I didn't really know why, at first.
Then I noticed this in my code:
So it made me realize that happy-dom already has a ResizeObserver stub with a bunch of
// TODO
😅https://github.com/capricorn86/happy-dom/blob/e6f91276d7b4549d17f5d67bd2f909723f4940b3/packages/happy-dom/src/resize-observer/ResizeObserver.ts#L13
Describe the solution you'd like My poor stub is far from optimal so I'm not going to share it here as it's not worth it; and I'm unsure how hard it'd be to build one from scratch.
But I could suggest something like https://github.com/juggle/resize-observer which I found by looking at the code of one of the libraries I use: https://github.com/ZeeCoder/use-resize-observer/blob/465fbc11c92e1b97a1dcb526b44ce4d889956951/tests/ie/polyfilled.tsx#L15-L25
Describe alternatives you've considered For now the solution for my case is deleting this code
and forcing my poor stub to be applied regardless if there is a ResizeObserver or not