From 906b83c470fb7ce28ad8ee5abf1ac001d85f2800 Mon Sep 17 00:00:00 2001 From: Kisaragi Hiu Date: Sun, 15 Sep 2024 00:36:56 +0900 Subject: [PATCH] fix(runtime): support runtimes without `global` --- internal/primordials.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/primordials.js b/internal/primordials.js index 63e23ab..94843d0 100644 --- a/internal/primordials.js +++ b/internal/primordials.js @@ -21,6 +21,9 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +A modification is made to always reference `globalThis` instead of referencing +both `global` and `globalThis`. See #157. */ 'use strict'; @@ -189,7 +192,7 @@ function copyPrototype(src, dest, prefix) { 'Reflect', ].forEach((name) => { // eslint-disable-next-line no-restricted-globals - copyPropsRenamed(global[name], primordials, name); + copyPropsRenamed(globalThis[name], primordials, name); }); // Create copies of intrinsic objects @@ -230,7 +233,7 @@ function copyPrototype(src, dest, prefix) { 'WeakSet', ].forEach((name) => { // eslint-disable-next-line no-restricted-globals - const original = global[name]; + const original = globalThis[name]; primordials[name] = original; copyPropsRenamed(original, primordials, name); copyPrototype(original.prototype, primordials, `${name}Prototype`); @@ -243,7 +246,7 @@ function copyPrototype(src, dest, prefix) { 'Promise', ].forEach((name) => { // eslint-disable-next-line no-restricted-globals - const original = global[name]; + const original = globalThis[name]; primordials[name] = original; copyPropsRenamedBound(original, primordials, name); copyPrototype(original.prototype, primordials, `${name}Prototype`);