Skip to content

Commit 40d8f04

Browse files
committed
feat: Use globalThis if available
1 parent 00c89dc commit 40d8f04

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
},
6666
"eslintConfig": {
6767
"extends": "./node_modules/kcd-scripts/eslint.js",
68+
"globals": {
69+
"globalThis": "readonly"
70+
},
6871
"rules": {
6972
"react/prop-types": "off",
7073
"react/no-adjacent-inline-elements": "off",

src/act-compat.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import * as testUtils from 'react-dom/test-utils'
33
const domAct = testUtils.act
44

55
function getGlobalThis() {
6+
/* istanbul ignore else */
7+
if (typeof globalThis !== 'undefined') {
8+
return globalThis
9+
}
610
/* istanbul ignore else */
711
if (typeof self !== 'undefined') {
812
return self

0 commit comments

Comments
 (0)