Skip to content

Commit

Permalink
Change approach to shadowing "toString" property for frames
Browse files Browse the repository at this point in the history
  • Loading branch information
jportner committed Mar 10, 2023
1 parent 7b5b81e commit 6f40a78
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
18 changes: 9 additions & 9 deletions browser-source-map-support.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion source-map-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,13 @@ function cloneCallSite(frame) {
Object.getOwnPropertyNames(Object.getPrototypeOf(frame)).forEach(function(name) {
object[name] = /^(?:is|get)/.test(name) ? function() { return frame[name].call(frame); } : frame[name];
});
object.toString = CallSiteToString;

// If the Object prototype is frozen, the "toString" property is non-writable. This means that any objects which inherit this property
// cannot have the property changed using an assignment. If using strict mode, attempting that will cause an error. If not using strict
// mode, attempting that will be silently ignored.
// However, we can still explicitly shadow the prototype's "toString" property by defining a new "toString" property on this object.
Object.defineProperty(object, 'toString', { value: CallSiteToString });

return object;
}

Expand Down

0 comments on commit 6f40a78

Please sign in to comment.