1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 07:44:48 -05:00

feat: make 'globalThis.location' a configurable property (#25812)

This commit changes `globalThis.location` property to be configurable
so that packages wanting to override it (or delete it) work properly.

Towards https://github.com/denoland/deno/issues/23882

This change makes reproduction from
https://github.com/denoland/deno/issues/23882#issuecomment-2340783437
pass properly.
This commit is contained in:
Bartek Iwańczuk 2024-09-23 13:18:07 +01:00 committed by GitHub
parent 8f32a1577e
commit 08d3f17110
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 38 additions and 0 deletions

View file

@ -654,6 +654,7 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
if (location_ == null) {
mainRuntimeGlobalProperties.location = {
writable: true,
configurable: true,
};
} else {
location.setLocationHref(location_);

View file

@ -0,0 +1,8 @@
{
"tests": {
"location_object_define_property": {
"args": "run location.js",
"output": "location.out"
}
}
}

View file

@ -0,0 +1,24 @@
let _location = undefined;
console.log(globalThis.location);
Object.defineProperty(globalThis, "location", {
get() {
return _location;
},
set(v) {
_location = v;
},
configurable: true,
});
console.log(globalThis.location);
globalThis.location = "https://deno.com";
console.log(_location);
console.log(location);
delete globalThis["location"];
console.log(globalThis.location);

View file

@ -0,0 +1,5 @@
undefined
undefined
https://deno.com
https://deno.com
undefined