Skip to content

Commit 2b7c09a

Browse files
committed
fixup! dont if cant
1 parent 4811b12 commit 2b7c09a

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

packages/non-trapping-shim/shim.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,25 @@
22
import { getEnvironmentOption } from '@endo/env-options';
33
import { ReflectPlus, ObjectPlus, ProxyPlus } from './src/non-trapping-pony.js';
44

5+
const { isFrozen } = Object;
6+
57
const nonTrappingShimOption = getEnvironmentOption(
68
'SES_NON_TRAPPING_SHIM',
79
'disabled',
810
['enabled'],
911
);
1012

1113
if (nonTrappingShimOption === 'enabled') {
12-
// TODO figure this out, either remove directive or change to
13-
// at-ts-expect-error.
14-
// @ts-ignore type of ReflectPlus vs Reflect, I think
15-
globalThis.Reflect = ReflectPlus;
14+
if (![Reflect, Object, Object.prototype, Proxy].some(isFrozen)) {
15+
// TODO figure this out, either remove directive or change to
16+
// at-ts-expect-error.
17+
// @ts-ignore type of ReflectPlus vs Reflect, I think
18+
globalThis.Reflect = ReflectPlus;
1619

17-
globalThis.Object = ObjectPlus;
18-
// eslint-disable-next-line no-extend-native
19-
Object.prototype.constructor = ObjectPlus;
20+
globalThis.Object = ObjectPlus;
21+
// eslint-disable-next-line no-extend-native
22+
Object.prototype.constructor = ObjectPlus;
2023

21-
globalThis.Proxy = ProxyPlus;
24+
globalThis.Proxy = ProxyPlus;
25+
}
2226
}

0 commit comments

Comments
 (0)