Skip to content

Commit

Permalink
Revert "feat: deprecate window global (denoland#22057)"
Browse files Browse the repository at this point in the history
This reverts commit 930ce20.
  • Loading branch information
bartlomieju committed Jan 24, 2024
1 parent 48c19d0 commit f6132b1
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 17 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
3 changes: 2 additions & 1 deletion runtime/js/99_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ let globalThis_;
let deprecatedApiWarningDisabled = false;
const ALREADY_WARNED_DEPRECATED = new SafeSet();

function warnOnDeprecatedApi(apiName, stack, ...suggestions) {
function warnOnDeprecatedApi(apiName, stack, suggestions) {
if (deprecatedApiWarningDisabled) {
return;
}
Expand Down 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 f6132b1

Please sign in to comment.