From 0a9e1f11d6e1737034f29be35129d5bbd08a996a Mon Sep 17 00:00:00 2001 From: Topper Bowers Date: Tue, 19 Dec 2023 22:29:53 +0100 Subject: [PATCH] allow overwriting array methods even on frozen objects --- packages/core/src/array.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/core/src/array.ts b/packages/core/src/array.ts index 14b820f..61e70ac 100644 --- a/packages/core/src/array.ts +++ b/packages/core/src/array.ts @@ -132,7 +132,11 @@ function arrayImplementation(arr: Y.Array) { const ret = []; for (let method in methods) { - ret[method] = methods[method]; + Object.defineProperty(ret, method, { + value: methods[method], + writable: true, + configurable: true + }) } // this is necessary to prevent errors like "trap reported non-configurability for property 'length' which is either non-existent or configurable in the proxy target" when adding support for ownKeys and Reflect.keysx