Skip to content

Commit 6f40a78

Browse files
committed
Change approach to shadowing "toString" property for frames
1 parent 7b5b81e commit 6f40a78

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

browser-source-map-support.js

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source-map-support.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,13 @@ function cloneCallSite(frame) {
361361
Object.getOwnPropertyNames(Object.getPrototypeOf(frame)).forEach(function(name) {
362362
object[name] = /^(?:is|get)/.test(name) ? function() { return frame[name].call(frame); } : frame[name];
363363
});
364-
object.toString = CallSiteToString;
364+
365+
// If the Object prototype is frozen, the "toString" property is non-writable. This means that any objects which inherit this property
366+
// cannot have the property changed using an assignment. If using strict mode, attempting that will cause an error. If not using strict
367+
// mode, attempting that will be silently ignored.
368+
// However, we can still explicitly shadow the prototype's "toString" property by defining a new "toString" property on this object.
369+
Object.defineProperty(object, 'toString', { value: CallSiteToString });
370+
365371
return object;
366372
}
367373

0 commit comments

Comments
 (0)