Skip to content

Commit

Permalink
toString for patched methods returns original toString
Browse files Browse the repository at this point in the history
  • Loading branch information
mdellanoce authored and guntherjh committed Feb 28, 2024
1 parent edc4299 commit 0407aba
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/rrweb/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit 0407aba

Please sign in to comment.