From 0cb3efe2e492a8356382d093cb2a7b987f207ae3 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 --- .changeset/unlucky-beers-tap.md | 5 +++++ packages/rrweb/src/utils.ts | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 .changeset/unlucky-beers-tap.md diff --git a/.changeset/unlucky-beers-tap.md b/.changeset/unlucky-beers-tap.md new file mode 100644 index 0000000000..43c85ea4ec --- /dev/null +++ b/.changeset/unlucky-beers-tap.md @@ -0,0 +1,5 @@ +--- +'rrweb': patch +--- + +toString for patched methods returns original toString diff --git a/packages/rrweb/src/utils.ts b/packages/rrweb/src/utils.ts index f426689d2f..671f42b9a0 100644 --- a/packages/rrweb/src/utils.ts +++ b/packages/rrweb/src/utils.ts @@ -144,6 +144,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, {