-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 #23882 This change makes reproduction from #23882 (comment) pass properly.
- Loading branch information
1 parent
8f32a15
commit 08d3f17
Showing
4 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"tests": { | ||
"location_object_define_property": { | ||
"args": "run location.js", | ||
"output": "location.out" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
undefined | ||
undefined | ||
https://deno.com | ||
https://deno.com | ||
undefined |