From f38d0a8d646e62508b6e8b1c831a85ffbe153364 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Sat, 28 Mar 2020 13:49:48 +0100 Subject: [PATCH] Fixed linting errors and enabled instant loading --- src/assets/javascripts/index.ts | 15 ++++++++++++--- .../javascripts/integrations/instant/index.ts | 1 - 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/assets/javascripts/index.ts b/src/assets/javascripts/index.ts index abe71482b..af7d13bd8 100644 --- a/src/assets/javascripts/index.ts +++ b/src/assets/javascripts/index.ts @@ -47,7 +47,8 @@ import { take, shareReplay, share, - pluck + pluck, + skip } from "rxjs/operators" import { @@ -352,8 +353,16 @@ export function initialize(config: unknown) { if (config.features.includes("instant")) { /* Disable automatic scroll restoration, as it doesn't work nicely */ - if ("scrollRestoration" in history) - history.scrollRestoration = "manual" + location$ + .pipe( + skip(1), + take(1) + ) + .subscribe(() => { + console.log("disabled automatic scroll restoration") + if ("scrollRestoration" in history) + history.scrollRestoration = "manual" + }) /* Resolve relative links for stability */ for (const selector of [ diff --git a/src/assets/javascripts/integrations/instant/index.ts b/src/assets/javascripts/integrations/instant/index.ts index 8a035eed4..f955437cf 100644 --- a/src/assets/javascripts/integrations/instant/index.ts +++ b/src/assets/javascripts/integrations/instant/index.ts @@ -135,7 +135,6 @@ export function setupInstantLoading( ) .subscribe(location$) - const dom = new DOMParser() const ajax$ = location$ .pipe(