mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 23:10:02 -04:00
location proxy still buggy
This commit is contained in:
parent
077302aada
commit
8217897d1e
1 changed files with 6 additions and 4 deletions
|
@ -14,6 +14,8 @@ export function createLocationProxy(
|
|||
Object.setPrototypeOf(fakeLocation, Location.prototype);
|
||||
fakeLocation.constructor = Location;
|
||||
|
||||
// for some reason it's on the object for Location and on the prototype for WorkerLocation??
|
||||
const descriptorSource = iswindow ? self.location : Location.prototype;
|
||||
const urlprops = [
|
||||
"protocol",
|
||||
"hash",
|
||||
|
@ -26,7 +28,7 @@ export function createLocationProxy(
|
|||
"search",
|
||||
];
|
||||
for (const prop of urlprops) {
|
||||
const native = nativeGetOwnPropertyDescriptor(self.location, prop);
|
||||
const native = nativeGetOwnPropertyDescriptor(descriptorSource, prop);
|
||||
if (!native) continue;
|
||||
|
||||
const desc = {
|
||||
|
@ -75,20 +77,20 @@ export function createLocationProxy(
|
|||
fakeLocation.assign = new Proxy(self.location.assign, {
|
||||
apply(target, thisArg, args) {
|
||||
args[0] = encodeUrl(args[0]);
|
||||
Reflect.apply(target, thisArg, args);
|
||||
Reflect.apply(target, self.location, args);
|
||||
},
|
||||
});
|
||||
if (self.location.reload)
|
||||
fakeLocation.reload = new Proxy(self.location.reload, {
|
||||
apply(target, thisArg, args) {
|
||||
Reflect.apply(target, thisArg, args);
|
||||
Reflect.apply(target, self.location, args);
|
||||
},
|
||||
});
|
||||
if (self.location.replace)
|
||||
fakeLocation.replace = new Proxy(self.location.replace, {
|
||||
apply(target, thisArg, args) {
|
||||
args[0] = encodeUrl(args[0]);
|
||||
Reflect.apply(target, thisArg, args);
|
||||
Reflect.apply(target, self.location, args);
|
||||
},
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue