Skip to content

Commit

Permalink
Fix if CallSite does not have all properties
Browse files Browse the repository at this point in the history
  • Loading branch information
XmiliaH committed Oct 13, 2021
1 parent 4f0db94 commit 469958d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/contextify.js
Original file line number Diff line number Diff line change
Expand Up @@ -1076,14 +1076,15 @@ if (typeof OriginalCallSite === 'function') {
(function setupCallSite() {
for (let i=0; i<callSiteGetters.length; i++) {
const name = callSiteGetters[i].name;
const funcProp = Object.getOwnPropertyDescriptor(OriginalCallSite.prototype, name);
if (funcProp === undefined) continue;
const propertyName = callSiteGetters[i].propName;
const func = {func() {
return this[propertyName];
}}.func;
const nameProp = Object.getOwnPropertyDescriptor(func, 'name');
nameProp.value = name;
Object.defineProperty(func, 'name', nameProp);
const funcProp = Object.getOwnPropertyDescriptor(OriginalCallSite.prototype, name);
funcProp.value = func;
Object.defineProperty(CallSite.prototype, name, funcProp);
}
Expand Down

0 comments on commit 469958d

Please sign in to comment.