From 6130a0d7ce099d631d70bc6ddb0dbe9cff826dc7 Mon Sep 17 00:00:00 2001 From: falsandtru Date: Tue, 13 Feb 2024 18:14:27 +0900 Subject: [PATCH] Refactoring --- src/layer/domain/router/api.ts | 2 +- src/layer/domain/router/module/fetch.ts | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/layer/domain/router/api.ts b/src/layer/domain/router/api.ts index b8b06402..1c3f055c 100644 --- a/src/layer/domain/router/api.ts +++ b/src/layer/domain/router/api.ts @@ -21,7 +21,7 @@ export async function route( ? Right(undefined) : Left(new Error(`Failed to match the areas`))) .fmap(() => - fetch(entity.event, entity.config, entity.state.process, io)) + fetch(entity.event, entity.config, entity.state.process)) .fmap(async p => (await p) .fmap(([res, seq]) => update(entity, res, seq, { diff --git a/src/layer/domain/router/module/fetch.ts b/src/layer/domain/router/module/fetch.ts index 9a1760e9..dfc02f28 100644 --- a/src/layer/domain/router/module/fetch.ts +++ b/src/layer/domain/router/module/fetch.ts @@ -5,9 +5,6 @@ import { xhr } from '../module/fetch/xhr'; import { Cancellee } from 'spica/cancellation'; import { Either } from 'spica/either'; import { wait as delay } from 'spica/timer'; -import { html } from 'typed-dom/dom'; - -const style = html('style'); export async function fetch( { @@ -31,14 +28,7 @@ export async function fetch( sequence, }: Config, process: Cancellee, - io: { - document: Document; - } ): Promise> { - const { scrollX, scrollY } = window; - if (type === RouterEventType.Popstate) { - io.document.documentElement.appendChild(style); - } headers = new Headers(headers); headers.has('Accept') || headers.set('Accept', 'text/html'); headers.has('X-Pjax') || headers.set('X-Pjax', JSON.stringify(areas)); @@ -56,10 +46,6 @@ export async function fetch( delay(wait), window.dispatchEvent(new Event('pjax:fetch')), ]); - if (type === RouterEventType.Popstate) { - style.parentNode?.removeChild(style); - window.scrollTo(scrollX, scrollY); - } return res .bind(process.either) .fmap(res => [res, seq] as const);