-
Notifications
You must be signed in to change notification settings - Fork 514
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
Interactions avec Javascript should use globalThis
instead of window
#2524
Comments
Note: I think self is standard in window environment and Webworker, but might not be in other environment (even if they seem to implement it). So at least, examples should use |
Also : |
I agree with the idea of providing a universal name for all contexts, but In the commit above I introduce the name |
I think "scope" alone may be confusing. It seems this corresponds to a "global scope" (cf https://developer.mozilla.org/en-US/docs/Glossary/Global_scope ), but "globalScope" might be too long. A "gscope" or "gs" would not be explicit enough i think. from browser import globalScope
gs = globalScope But this is kind of not practical. So "scope" isn't ideal, but I do not really have a better idea. |
In the documentation : https://brython.info/static_doc/3.13/fr/jsobjects.html
Examples should use
globalThis
instead ofwindow
:Indeed,
globalThis
is the standard way to access global values, working in window and non-window context, cf https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThisBrython does remove
browser.window
in Node and WebWorker contexts.The text was updated successfully, but these errors were encountered: