-
Notifications
You must be signed in to change notification settings - Fork 1
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
Prototypes and Privacy #2
Comments
After reviewing a bit, this is actually how the current "spec text" works. Since the proxy is transparent when it comes to private symbols, the Although it was my intention to have an observable call to |
Further proof: const target = { test: true }
const proxy = new Proxy(target, {
get(target, key) {
// Imitate "transparent" proxy
return Reflct.get(...arguments);
},
getPrototypeOf() {
throw new Error('observable');
}
});
console.assert(proxy.test === true);
const sub = Object.create(proxy);
console.assert(sub.test === true); In fact, no traps are fired (minus the const target = { test: true }
const proxy = new Proxy(target, new Proxy({}, {
get(target, key) {
// Imitate "transparent" proxy
if (key === 'get') return;
throw new Error('observable');
}
}));
console.assert(proxy.test === true);
const sub = Object.create(proxy);
console.assert(sub.test === true); |
These are both arguing that private symbols are not actually private because they fire observable
getPrototypeOf
traps (assuming a proxy is somewhere in the prototype chain, or the proxy is the base object).If this is a necessary requirement for privacy, why not just skip the
getPrototypeOf
trap during prototype lookup? The same asget
/set
handler tunnel directly to the target, we can define the private symbol lookup algorithm to tunnel directly when traversing the prototype.The text was updated successfully, but these errors were encountered: