From 822d8f4787ab9db574b1dbb6e82d44e6986b4c1b Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 21 Apr 2022 20:21:32 -0700 Subject: [PATCH] feat: conditional defining continued (#342) --- packages/near-membrane-base/src/membrane.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/near-membrane-base/src/membrane.ts b/packages/near-membrane-base/src/membrane.ts index 7d38e68a..2229b997 100644 --- a/packages/near-membrane-base/src/membrane.ts +++ b/packages/near-membrane-base/src/membrane.ts @@ -279,11 +279,9 @@ export function createMembraneMarshall(isInShadowRealm?: boolean) { slice: ArrayProtoSlice, } = ArrayCtor.prototype; const { isView: ArrayBufferIsView } = ArrayBufferCtor; - const ArrayBufferProtoByteLengthGetter = ReflectApply( - ObjectProto__lookupGetter__, - ArrayBufferCtor.prototype, - ['byteLength'] - )!; + const ArrayBufferProtoByteLengthGetter = !isInShadowRealm + ? ReflectApply(ObjectProto__lookupGetter__, ArrayBufferCtor.prototype, ['byteLength'])! + : undefined; const BigIntProtoValueOf = SUPPORTS_BIG_INT ? BigInt.prototype.valueOf : undefined; const { valueOf: BooleanProtoValueOf } = Boolean.prototype; const { toString: ErrorProtoToString } = ErrorCtor.prototype; @@ -3839,7 +3837,7 @@ export function createMembraneMarshall(isInShadowRealm?: boolean) { // Section 25.1.5.1 get ArrayBuffer.prototype.byteLength // https://tc39.es/ecma262/#sec-get-arraybuffer.prototype.bytelength // Step 2: Perform ? RequireInternalSlot(O, [[ArrayBufferData]]). - ReflectApply(ArrayBufferProtoByteLengthGetter, target, []); + ReflectApply(ArrayBufferProtoByteLengthGetter!, target, []); return true; // eslint-disable-next-line no-empty } catch {}