-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document turbo:fetch-request-error
event
#110
Conversation
Thank you for proposing this change! Would it be worth differentiating between a For additional context, the originating call is made in the |
Could there be a distinction made with |
👍🏽 thanks! |
_source/reference/events.md
Outdated
@@ -37,3 +37,5 @@ Turbo emits events that allow you to track the navigation lifecycle and respond | |||
* `turbo:frame-render` fires right after `<turbo-frame>` element renders its view. The specific `<turbo-frame>` element is the event target. Access the `FetchResponse` object with `event.detail.fetchResponse` property. | |||
|
|||
* `turbo:frame-load` fires when `<turbo-frame>` element is navigated and finishes loading (fires after `turbo:frame-render`). The specific `<turbo-frame>` element is the event target. | |||
|
|||
* `turbo:fetch-request-error` fires when a form or frame fetch request fails due to network errors. This event fires on the respective element (turbo-frame or form element) which triggers it and can be accessed with `event.target` property. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this also fire during a Visit
from an <a>
click? Will the document.documentElement
be the target?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but perhaps it should? I think that would mean emitting this event here https://github.com/hotwired/turbo/blob/256418fee0178ee483d82cd9bb579bd5df5a151f/src/core/drive/visit.ts#L382
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in favor of that change!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've opened hotwired/turbo#685 to add that behavior.
It also makes the turbo:fetch-request-error
event cancelable, which is also worth noting here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when the event is canceled? Or is it enough to just say “This event can be canceled”.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to hotwired#640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
Follow-up to #640 Related to hotwired/turbo-site#110 When a `Visit` results in a `fetch` error (like when the browser is offline), dispatch a `turbo:fetch-request-error` event in the same style as `<turbo-frame>`- and `<form>`-initiated `fetch` errors. For the sake of consistency, also make the `TurboFetchRequestErrorEvent` cancelable. Along with the implementation change, this commit also adds test coverage to ensure that the `Event.target` is correct for `<turbo-frame>` and `<form>` error events.
See hotwired/turbo#640