-
-
Notifications
You must be signed in to change notification settings - Fork 198
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
fix: issue 407, add IntersectionObserver mock to Dom #730
base: main
Are you sure you want to change the base?
Conversation
jsdom does not implement IntersectionObserver so we need to mock it. This is similar in scope to histoire-dev@2d16838
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
|
✅ Deploy Preview for histoire-examples-svelte3 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for histoire-examples-vue3 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for histoire-controls ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for histoire-site ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
rootMargin: string | ||
thresholds: number[] | ||
disconnect(): void { /* noop */ } | ||
observe(_target: Element): void { /* noop */ } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be:
observe = (_target: Element): void => {};
Of you will get errors like:
console.error
ERROR TypeError: intersectionObserver.observe is not a function
Description
Add mock ResizeObserver to DOM after jsdom initialisation to fix #407. jsdom does not implement IntersectionObserver so we mock it.
Additional context
I stumbled onto this issue when using nk-o/jarallax in a component, which uses IntersectionObserver and breaks histoire stories. There is an open issue on jsdom here: jsdom/jsdom#2032 but looks like a won't fix due to the project's scope. This is a quick noop fix similar to (and indeed based on)
2d16838 / #664
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).