From 0407abad6200aa398a745783d48773d29e010246 Mon Sep 17 00:00:00 2001 From: Michael Dellanoce Date: Thu, 8 Feb 2024 10:51:58 -0500 Subject: [PATCH] toString for patched methods returns original toString --- packages/rrweb/src/utils.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/rrweb/src/utils.ts b/packages/rrweb/src/utils.ts index 782fd3dd8e..106097bf5e 100644 --- a/packages/rrweb/src/utils.ts +++ b/packages/rrweb/src/utils.ts @@ -163,6 +163,9 @@ export function patch( // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work // otherwise it'll throw "TypeError: Object.defineProperties called on non-object" if (typeof wrapped === 'function') { + wrapped.toString = function() { + return original.toString(); + }; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment wrapped.prototype = wrapped.prototype || {}; Object.defineProperties(wrapped, {