Skip to content

Commit

Permalink
avoid globalThis
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingbaoyu committed Jan 19, 2024
1 parent 8507136 commit c5c5424
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

let nativeSymbol = Symbol;
try {
delete globalThis.Symbol;
delete global.Symbol;

require("core-js/modules/es.symbol.js")

Expand All @@ -12,7 +12,7 @@ try {
expect(typeof symbol === "symbol").toBe(true);
expect(eval("_toPropertyKey(symbol)")).toBe(symbol);
} finally {
globalThis.Symbol = nativeSymbol;
global.Symbol = nativeSymbol;
}

return "done";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ System.register([], function (_export, _context) {
// Ref: https://github.com/babel/babel/issues/16219
nativeSymbol = Symbol;
try {
delete globalThis.Symbol;
delete global.Symbol;
require("core-js/modules/es.symbol.js");
symbol = Symbol("test");
expect(eval('typeof symbol === "object"')).toBe(true);
expect(_typeof(symbol) === "symbol").toBe(true);
expect(eval("_toPropertyKey(symbol)")).toBe(symbol);
} finally {
globalThis.Symbol = nativeSymbol;
global.Symbol = nativeSymbol;
}
return "done";
AxiosHeaders = /*#__PURE__*/function (_Symbol$iterator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ describe("systemjs exec", function () {
);
let ret;

globalThis.require = require;
globalThis.System = {
const System = {
register: function (_, module) {
ret = module().execute();
},
};
eval(content);

expect(ret).toBe("done");
expect((require, System, ret)).toBe("done");
});
});

0 comments on commit c5c5424

Please sign in to comment.