Skip to content
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

turbo:frame-missing: Dispatch for 4xx and 5xx #693

Merged
merged 1 commit into from
Sep 13, 2022

Conversation

seanpdoyle
Copy link
Contributor

Closes #670

Re-use the existing 2xx and 3xx behavior for a response to handle
error responses. When the frame is missing from the page (likely for
error pages like 404), dispatch a turbo:frame-missing event.

Alongside that behavior, yield the Response instance and a
Turbo.visit-like callback that can transform the Response instance
into a Visit. It also accepts all the arguments that the Turbo.visit
call normally does.

When the event is not canceled, treat the Response as a Visit. When
the event is canceled, let the listener handle it.

Closes hotwired#670

Re-use the existing `2xx` and `3xx` behavior for a response to handle
error responses. When the frame is missing from the page (likely for
error pages like `404`), dispatch a `turbo:frame-missing` event.

Alongside that behavior, yield the [Response][] instance and a
`Turbo.visit`-like callback that can transform the `Response` instance
into a `Visit`. It also accepts all the arguments that the `Turbo.visit`
call normally does.

When the event is not canceled, treat the `Response` as a Visit. When
the event **is** canceled, let the listener handle it.

[Response]: https://developer.mozilla.org/en-US/docs/Web/API/Response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

turbo:frame-missing event not dispatched when code is not 200
2 participants