-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
MutationObserver observe is not a function #1514
Comments
Thank you for reporting @CUBITECH! 🙂 The instance method Example: `const observer = new MutationObserver((records) => {
console.log(records);
})
observer.observe(element); Do you have a repo or can you reproduce it in a test environment, so that we can debug what is causing the problem? |
Hi, have build a StackBlitz: https://stackblitz.com/edit/happy-dom-issue-1514. |
The problem seem to be that There is an issue for it here, but they don't seem to want to fix it: The workaround seem to be to do: // @ts-ignore
window.MutationObserver = window[Zone.__symbol__("MutationObserver")]; My opinion is that it is a pretty bad idea to wrap the native classes, as no other libraries than Zone compatible libraries will work in this environment, but perhaps I have missed something 😅 I will close this as this seem to be an issue with Angular and Zone.js and not Happy DOM. |
Thanks for watching and the workaround! |
Hi,
in an Angular project, i have switched from JSDom to Happy Dom, for many reasons... I am using Jest as Testing Framework and jest-axe for a11y Tests.
jest-axe uses MutationObserver for observing DOM changes, but the MutationObserver class in Happy Dom seems to work different(ly?).
After instantiating a MutationObserver the new object has no function 'observe', hence jest-axe throws an 'observer.observe is not a function' exception.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
MutationObserver works as expected.
Let me know if you need more information.
Thanks!
The text was updated successfully, but these errors were encountered: