Skip to content

Commit

Permalink
FetchRequest target could be any Element
Browse files Browse the repository at this point in the history
  • Loading branch information
domchristie committed Aug 21, 2022
1 parent 59aa86f commit 95590c4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/core/drive/visit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export type VisitOptions = {
shouldCacheSnapshot: boolean
frame?: string
acceptsStreamResponse: boolean
initiator?: HTMLAnchorElement | HTMLFormElement
initiator?: Element
}

const defaultOptions: VisitOptions = {
Expand Down Expand Up @@ -87,7 +87,7 @@ export class Visit implements FetchRequestDelegate {
readonly willRender: boolean
readonly updateHistory: boolean
readonly promise: Promise<void>
readonly initiator?: HTMLAnchorElement | HTMLFormElement
readonly initiator?: Element

private resolvingFunctions!: ResolvingFunctions<void>

Expand Down
2 changes: 1 addition & 1 deletion src/core/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
5 changes: 2 additions & 3 deletions src/http/fetch_request.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { FetchResponse } from "./fetch_response"
import { FrameElement } from "../elements/frame_element"
import { dispatch } from "../util"

export type TurboBeforeFetchRequestEvent = CustomEvent<{
Expand Down Expand Up @@ -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) => {}

Expand All @@ -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
Expand Down

0 comments on commit 95590c4

Please sign in to comment.