fix: don't use globalThis when using this#562
fix: don't use globalThis when using this#562jluxenberg wants to merge 1 commit intocristianbote:masterfrom
globalThis when using this#562Conversation
Without "use strict", `this` will be set to `globalThis` which is typically the window object. If certain properties are set on the window object (e.g. "window.target"), this can cause problems for the `css` and `styled` functions. Instead, check that `this` has been set to something other than `globalThis` before using it. This ensures that `this` will only have a value if it is explicitly bound, and otherwise will be `undefined`. Note: I tried to add "use strict"; directives where needed, but couldn't get them to "survive" the build process -- they were removed. This fix seems to work just fine. Closes cristianbote#545
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 7a26f07:
|
This fork of Goober has this PR merged: cristianbote/goober#562 which fixes an issue caused by sites that set "window.target" to some non-undefined value.
|
Heya @jluxenberg, Thank you so much for this PR and for the details. |
I did try that (and added in all the places where microbundle is invoked) but it didn't seem to change the build artifacts at all. |
Without "use strict",
thiswill be set toglobalThiswhich is typically the window object. If certain properties are set on the window object (e.g. "window.target"), this can cause problems for thecssandstyledfunctions.Instead, check that
thishas been set to something other thanglobalThisbefore using it. This ensures thatthiswill only have a value if it is explicitly bound, and otherwise will beundefined.Note: I tried to add "use strict"; directives where needed, but couldn't get them to "survive" the build process -- they were removed. This fix seems to work just fine.
Closes #545