Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "feat: deprecate window global (#22057)" #22084

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading