fix illegal invocation

This commit is contained in:
velzie 2024-07-14 15:04:54 -04:00
parent ed1ba01d3a
commit 4fedcea1d4
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F

View file

@ -1,7 +1,7 @@
import { locationProxy } from "./location"; import { locationProxy } from "./location";
export const windowProxy = new Proxy(window, { export const windowProxy = new Proxy(window, {
get(target, prop) { get(target, prop, reciever) {
const propIsString = typeof prop === "string"; const propIsString = typeof prop === "string";
if (propIsString && prop === "location") { if (propIsString && prop === "location") {
return locationProxy; return locationProxy;
@ -19,7 +19,13 @@ export const windowProxy = new Proxy(window, {
}) })
} }
return target[prop]; const value = Reflect.get(target, prop, reciever);
if (typeof value === "function") {
return value.bind(target);
}
return value;
}, },
set(target, prop, newValue) { set(target, prop, newValue) {