-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
globalThis shim #16054
globalThis shim #16054
Conversation
For reference: And |
web developers dont want this tiny change breaking their code. company dont want lose their clients. |
@@ -2598,6 +2598,13 @@ proc genHeader(): Rope = | |||
var framePtr = null; | |||
var excHandler = 0; | |||
var lastJSError = null; | |||
var globalThis; | |||
if(typeof globalThis == 'undefined') globalThis = (function () { |
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.
When would this not be true? You start with var globalThis;
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.
var a; typeof a == "undefined";
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.
Exactly, you just wrote if (true)
. I think in order to emulate globalThis
you must not predeclare it at all.
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.
a= 1; var a; typeof a == "undefined"; it's not like you think.
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.
declare it here just note it as global variable, this line can be safely delete.
Related docs about var getGlobal = function () {
/* global self, window */
// the only reliable means to get the global object is
// `Function('return this')()`
// However, this causes CSP violations in Chrome apps.
if (typeof self !== 'undefined') { return self; }
if (typeof window !== 'undefined') { return window; }
if (typeof global !== 'undefined') { return global; }
throw new Error('unable to locate global object');
}; |
As far as I can tell, Nim only uses |
Unfortunately, there is one or more variables labeled as |
I will make a PR to undefine some stuff in JS backend(which is unnecessary for JS backend). Then I guess Edited: |
99.22% browsers support Typed Arrays, it's the time to remove them all. https://caniuse.com/?search=Typed%20Arrays I will make a PR, at least we could remove them eventually in the future. |
we should instead have a module there are more use cases of polyfills besides globalThis links |
Can't assuming users using no-ie and node version >= 12.