-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: getPrototypeOf trap get called in safari #62
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ import { throwTantrum } from './utilities'; | |
*/ | ||
const alwaysThrowHandler = new Proxy(freeze({}), { | ||
get(target, prop) { | ||
throwTantrum(`unexpected scope handler trap called: ${prop}`); | ||
throwTantrum(`unexpected scope handler trap called: ${String(prop)}`); | ||
} | ||
}); | ||
|
||
|
@@ -25,6 +25,8 @@ const alwaysThrowHandler = new Proxy(freeze({}), { | |
* - route all other property lookups at the safeGlobal. | ||
* - hide the unsafeGlobal which lives on the scope chain above the 'with'. | ||
* - ensure the Proxy invariants despite some global properties being frozen. | ||
* | ||
* @returns {ProxyHandler<any> & Record<string, any>} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I never did learn this comment-type language, so I can't review whether this declaration is good. Since it is in a comment, I won't block a merge here on my own ignorance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's using jsdoc-like syntax to hint ts server about the type of the function |
||
*/ | ||
export function createScopeHandler(unsafeRec, safeGlobal, sloppyGlobals) { | ||
const { unsafeGlobal, unsafeEval } = unsafeRec; | ||
|
@@ -79,7 +81,6 @@ export function createScopeHandler(unsafeRec, safeGlobal, sloppyGlobals) { | |
return undefined; | ||
}, | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for catching this. Does anyone have an automated detection of |
||
set(target, prop, value) { | ||
// todo: allow modifications when target.hasOwnProperty(prop) and it | ||
// is writable, assuming we've already rejected overlap (see | ||
|
@@ -134,6 +135,13 @@ export function createScopeHandler(unsafeRec, safeGlobal, sloppyGlobals) { | |
} | ||
|
||
return false; | ||
}, | ||
|
||
// note: this is likely a bug of safari | ||
// https://bugs.webkit.org/show_bug.cgi?id=195534 | ||
|
||
getPrototypeOf() { | ||
return null; | ||
} | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's Typescript language server warned me about this.