Skip to content

Commit

Permalink
Revert "feat: deprecate window global (#22057)" (#22084)
Browse files Browse the repository at this point in the history
This reverts commit 930ce20.

This is producing false-positives that are not actionable to users.
We're gonna address this in another release.
  • Loading branch information
bartlomieju authored Jan 24, 2024
1 parent 300eeb3 commit 8e67bf8
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 16 deletions.
1 change: 0 additions & 1 deletion cli/tests/testdata/npm/compare_globals/main.out
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ false
true
true
true
[WILDCARD]
true
false
false
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/testdata/run/webstorage/logger.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
console.log(globalThis.localStorage);
console.log(window.localStorage);
6 changes: 3 additions & 3 deletions cli/tests/testdata/run/webstorage/serialization.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
globalThis.sessionStorage.setItem("hello", "deno");
window.sessionStorage.setItem("hello", "deno");

console.log(globalThis.localStorage);
console.log(globalThis.sessionStorage);
console.log(window.localStorage);
console.log(window.sessionStorage);
2 changes: 1 addition & 1 deletion cli/tests/testdata/run/webstorage/setter.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
globalThis.localStorage.setItem("hello", "deno");
window.localStorage.setItem("hello", "deno");
12 changes: 2 additions & 10 deletions runtime/js/98_global_scope_window.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.

import { core, internals, primordials } from "ext:core/mod.js";
import { core, primordials } from "ext:core/mod.js";
const {
op_bootstrap_language,
op_bootstrap_numcpus,
Expand Down Expand Up @@ -108,15 +108,7 @@ const mainRuntimeGlobalProperties = {
Location: location.locationConstructorDescriptor,
location: location.locationDescriptor,
Window: globalInterfaces.windowConstructorDescriptor,
window: util.getterOnly(() => {
internals.warnOnDeprecatedApi(
"window",
new Error().stack,
"Use `globalThis` or `self` instead.",
"You can provide `window` in the current scope with: `const window = globalThis`.",
);
return globalThis;
}),
window: util.getterOnly(() => globalThis),
self: util.getterOnly(() => globalThis),
Navigator: util.nonEnumerable(Navigator),
navigator: util.getterOnly(() => navigator),
Expand Down
1 change: 1 addition & 0 deletions runtime/js/99_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ function warnOnDeprecatedApi(apiName, stack, ...suggestions) {
"font-weight: bold;",
);
}

if (isFromRemoteDependency) {
console.error(
`%chint: It appears this API is used by a remote dependency. Try upgrading to the latest version of that dependency.`,
Expand Down

0 comments on commit 8e67bf8

Please sign in to comment.