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

this.document and this.location.href do not exist in a web worker #55

Merged
merged 4 commits into from
Aug 8, 2024

Conversation

ryanxcharles
Copy link
Contributor

if you use this plugin in a web worker, it will work in development, but not in production.

it fails in production first because this.location does not exist in a web worker. this can be fixed by changing it to self.location.

however, more fundamentally, document does not exist inside a web worker. you cannot do this.document = [anything] in a web worker.

but, this line is actually a polyfill. self does exist in a web worker, and we can polyfill self.document exactly like in a normal web page.

in a nutshell, if you change both instances of "this" to "self", this plugin works in a web worker in production.

this.location does not work in a web worker, but self.location does work both
in a web worker and in a normal page.
@Menci Menci merged commit 8006241 into Menci:main Aug 8, 2024
28 checks passed
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 this pull request may close these issues.

2 participants