summaryrefslogtreecommitdiff
path: root/runtime/js
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/js')
-rw-r--r--runtime/js/98_global_scope_window.js12
-rw-r--r--runtime/js/99_main.js15
2 files changed, 19 insertions, 8 deletions
diff --git a/runtime/js/98_global_scope_window.js b/runtime/js/98_global_scope_window.js
index 63b346dd5..3188c4b4c 100644
--- a/runtime/js/98_global_scope_window.js
+++ b/runtime/js/98_global_scope_window.js
@@ -1,6 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-import { core, primordials } from "ext:core/mod.js";
+import { core, internals, primordials } from "ext:core/mod.js";
const {
op_bootstrap_language,
op_bootstrap_numcpus,
@@ -108,7 +108,15 @@ const mainRuntimeGlobalProperties = {
Location: location.locationConstructorDescriptor,
location: location.locationDescriptor,
Window: globalInterfaces.windowConstructorDescriptor,
- window: util.getterOnly(() => globalThis),
+ 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;
+ }),
self: util.getterOnly(() => globalThis),
Navigator: util.nonEnumerable(Navigator),
navigator: util.getterOnly(() => navigator),
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index 255c5fb6a..3fee1109b 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -99,7 +99,7 @@ let globalThis_;
let deprecatedApiWarningDisabled = false;
const ALREADY_WARNED_DEPRECATED = new SafeSet();
-function warnOnDeprecatedApi(apiName, stack, suggestion) {
+function warnOnDeprecatedApi(apiName, stack, ...suggestions) {
if (deprecatedApiWarningDisabled) {
return;
}
@@ -155,11 +155,14 @@ function warnOnDeprecatedApi(apiName, stack, suggestion) {
"%c\u251c This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then.",
"color: yellow;",
);
- console.error("%c\u2502", "color: yellow;");
- console.error(
- `%c\u251c Suggestion: ${suggestion}`,
- "color: yellow;",
- );
+ for (let i = 0; i < suggestions.length; i++) {
+ const suggestion = suggestions[i];
+ console.error("%c\u2502", "color: yellow;");
+ console.error(
+ `%c\u251c Suggestion: ${suggestion}`,
+ "color: yellow;",
+ );
+ }
if (isFromRemoteDependency) {
console.error("%c\u2502", "color: yellow;");
console.error(