1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-27 01:29:14 -05:00
denoland-deno/cli/tests
Bartek Iwańczuk 930ce20870
feat: deprecate window global (#22057)
This commit deprecates `window` global and adds deprecation
notice on each use of `window`.

We decided to proceed with removal of `window` global variable in Deno
2.0. There's a lot of code
in the wild that uses pattern like this:
```
if (typeof window !== "undefined) {
  ...
}
```
to check if the code is being run in browser. However, this check passes
fine in Deno and
most often libraries that do this check try to access some browser API
that is not available
in Deno, or use DOM APIs (which are also not available in Deno).

This situation has occurred multiple times already
and it's unfeasible to expect the whole ecosystem to migrate to new
check (and even if that
happened there's a ton of code that's already shipped and won't change).

The migration is straightfoward - replace all usages of `window` with
`globalThis` or `self`.
When Deno encounters use of `window` global it will now issue a warning,
steering users
towards required changes:

```
Warning
├ Use of deprecated "window" API.
│
├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then.
│
├ Suggestion: Use `globalThis` or `self` instead.
│
├ Suggestion: You can provide `window` in the current scope with: `const window = globalThis`.
│
└ Stack trace:
  └─ at file:///Users/ib/dev/deno/foo.js:7:1
```

Ref https://github.com/denoland/deno/issues/13367.
2024-01-24 14:20:51 +01:00
..
integration feat: TC39 decorator proposal support (#22040) 2024-01-24 18:46:23 +05:30
node_compat feat(web): ImageBitmap (#21898) 2024-01-22 12:08:01 +01:00
testdata feat: deprecate window global (#22057) 2024-01-24 14:20:51 +01:00
unit fix(ext/cron): automatically override unspecified values (#22042) 2024-01-24 00:45:11 +00:00
unit_node feat: deprecate Deno.read() and Deno.readSync() (#22063) 2024-01-24 09:42:03 +05:30
integration_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00