Skip to content

Commit

Permalink
Merge pull request #372 from XmiliaH/fix-371
Browse files Browse the repository at this point in the history
Fix if CallSite does not have all properties
  • Loading branch information
XmiliaH authored Oct 13, 2021
2 parents 4f0db94 + 469958d commit 4198060
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 4198060

Please sign in to comment.