Skip to content
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

Web Worker Support #240

Open
wSedlacek opened this issue Dec 26, 2023 · 3 comments · May be fixed by #242
Open

Web Worker Support #240

wSedlacek opened this issue Dec 26, 2023 · 3 comments · May be fixed by #242

Comments

@wSedlacek
Copy link

wSedlacek commented Dec 26, 2023

Web Workers resolve to the browser.js however window is not defined thus causing an undefined reference.
Using globalThis or self instead of window could allow this file to work in web workers too.

Uncaught ReferenceError: window is not defined
    at node_modules/.pnpm/[email protected][email protected]/node_modules/isomorphic-dompurify/browser.js (isomorphic-dompurify.js?v=650fd638:949:22)
@kkomelin
Copy link
Owner

Hey @wSedlacek ,
Thanks for reporting this issue.
Would you like to work on a solution?

@wSedlacek
Copy link
Author

Sure! I would be happy to make a PR.
I need to know the supported browsers to know if globalThis is the best solution (or if typeof window === undefined would be better)

@kkomelin
Copy link
Owner

Great news @wSedlacek.
We've recently switched to typeof window !== 'undefined' https://github.com/kkomelin/isomorphic-dompurify/releases/tag/v2.0.0 for the server-side version, so I think it would be ideal if we could use the same for the client one.

@wSedlacek wSedlacek linked a pull request Dec 28, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants