From 95590c442526fc27fd1542a7a8dc3d0478827bb8 Mon Sep 17 00:00:00 2001 From: Dom Christie Date: Sun, 21 Aug 2022 14:37:32 -0700 Subject: [PATCH] FetchRequest target could be any Element --- src/core/drive/visit.ts | 4 ++-- src/core/session.ts | 2 +- src/http/fetch_request.ts | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/core/drive/visit.ts b/src/core/drive/visit.ts index cf22f4f10..7c4ea55ed 100644 --- a/src/core/drive/visit.ts +++ b/src/core/drive/visit.ts @@ -51,7 +51,7 @@ export type VisitOptions = { shouldCacheSnapshot: boolean frame?: string acceptsStreamResponse: boolean - initiator?: HTMLAnchorElement | HTMLFormElement + initiator?: Element } const defaultOptions: VisitOptions = { @@ -87,7 +87,7 @@ export class Visit implements FetchRequestDelegate { readonly willRender: boolean readonly updateHistory: boolean readonly promise: Promise - readonly initiator?: HTMLAnchorElement | HTMLFormElement + readonly initiator?: Element private resolvingFunctions!: ResolvingFunctions diff --git a/src/core/session.ts b/src/core/session.ts index 814542d8d..c8477ee7a 100644 --- a/src/core/session.ts +++ b/src/core/session.ts @@ -191,7 +191,7 @@ export class Session ) } - followedLinkToLocation(link: HTMLAnchorElement, location: URL) { + followedLinkToLocation(link: Element, location: URL) { const action = this.getActionForLink(link) const acceptsStreamResponse = link.hasAttribute("data-turbo-stream") diff --git a/src/http/fetch_request.ts b/src/http/fetch_request.ts index 9370d7d6f..5563e1b5c 100644 --- a/src/http/fetch_request.ts +++ b/src/http/fetch_request.ts @@ -1,5 +1,4 @@ import { FetchResponse } from "./fetch_response" -import { FrameElement } from "../elements/frame_element" import { dispatch } from "../util" export type TurboBeforeFetchRequestEvent = CustomEvent<{ @@ -62,7 +61,7 @@ export class FetchRequest { readonly headers: FetchRequestHeaders readonly url: URL readonly body?: FetchRequestBody - readonly target?: FrameElement | HTMLFormElement | HTMLAnchorElement | null + readonly target?: Element | null readonly abortController = new AbortController() private resolveRequestPromise = (_value: any) => {} @@ -71,7 +70,7 @@ export class FetchRequest { method: FetchMethod, location: URL, body: FetchRequestBody = new URLSearchParams(), - target: FrameElement | HTMLFormElement | HTMLAnchorElement | null = null + target: Element | null = null ) { this.delegate = delegate this.method = method