Skip to content

Commit 8038b6f

Browse files
authored
fix(runtime): support runtimes without global (#158)
1 parent d2f6c87 commit 8038b6f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

internal/primordials.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2121
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2222
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2323
IN THE SOFTWARE.
24+
25+
A modification is made to always reference `globalThis` instead of referencing
26+
both `global` and `globalThis`. See #157.
2427
*/
2528

2629
'use strict';
@@ -189,7 +192,7 @@ function copyPrototype(src, dest, prefix) {
189192
'Reflect',
190193
].forEach((name) => {
191194
// eslint-disable-next-line no-restricted-globals
192-
copyPropsRenamed(global[name], primordials, name);
195+
copyPropsRenamed(globalThis[name], primordials, name);
193196
});
194197

195198
// Create copies of intrinsic objects
@@ -230,7 +233,7 @@ function copyPrototype(src, dest, prefix) {
230233
'WeakSet',
231234
].forEach((name) => {
232235
// eslint-disable-next-line no-restricted-globals
233-
const original = global[name];
236+
const original = globalThis[name];
234237
primordials[name] = original;
235238
copyPropsRenamed(original, primordials, name);
236239
copyPrototype(original.prototype, primordials, `${name}Prototype`);
@@ -243,7 +246,7 @@ function copyPrototype(src, dest, prefix) {
243246
'Promise',
244247
].forEach((name) => {
245248
// eslint-disable-next-line no-restricted-globals
246-
const original = global[name];
249+
const original = globalThis[name];
247250
primordials[name] = original;
248251
copyPropsRenamedBound(original, primordials, name);
249252
copyPrototype(original.prototype, primordials, `${name}Prototype`);

0 commit comments

Comments
 (0)