fix: no-window lint error (#2272)

Latest PR runs are failing with linting errors, e.g.
https://github.com/denoland/fresh/actions/runs/7625625084/job/20770308634?pr=2266

Maybe this shouldn't be happening like this right now, but we'll still
need to clean these up eventually.
This commit is contained in:
Reed von Redwitz
2024-01-23 21:51:38 +01:00
committed by GitHub
parent 4bd556970a
commit a83765efaa
7 changed files with 16 additions and 10 deletions
+5 -3
View File
@@ -1,3 +1,4 @@
// deno-lint-ignore-file ban-unknown-rule-code ban-unused-ignore
import "../polyfills.ts";
import {
Component,
@@ -111,6 +112,7 @@ export function revive(
);
};
// deno-lint-ignore no-window
"scheduler" in window
// `scheduler.postTask` is async but that can easily
// fire in the background. We don't want waiting for
@@ -892,11 +894,11 @@ function maybeUpdateHistory(nextUrl: URL) {
// Only add history entry when URL is new. Still apply
// the partials because sometimes users click a link to
// "refresh" the current page.
if (nextUrl.href !== window.location.href) {
if (nextUrl.href !== globalThis.location.href) {
const state: FreshHistoryState = {
index,
scrollX: window.scrollX,
scrollY: window.scrollY,
scrollX: globalThis.scrollX,
scrollY: globalThis.scrollY,
};
// Store current scroll position
+2
View File
@@ -1,5 +1,7 @@
// deno-lint-ignore-file ban-unknown-rule-code ban-unused-ignore
// Polyfill for old safari versions
if (typeof globalThis === "undefined") {
// @ts-ignore polyfill
// deno-lint-ignore no-window
window.globalThis = window;
}