forked from hotwired/turbo
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dispatch
turbo:frame-render
when Frame connects
Closes hotwired/turbo-rails#379 Currently, a `<turbo-frame>` element only dispatches events when its contents are fetched over HTTP. The `turbo:frame-render` and `turbo:frame-load` events are dispatched sequentially and immediately following one another. The `turbo:frame-render` detail exposes a reference to the `FetchResponse`, while the `turbo:frame-load` event has no details. Consumer applications might expect a `<turbo-frame>` to dispatch a `turbo:frame-render` event immediately whenever a `<turbo-frame>` is connected to the document (similar to the way that `turbo:render` is dispatched prior to `turbo:load`, even on restoration Visits). For the sake of consistency and distinguishing between two events that are more or less equivalent and temporally interchangeable, this commit proposes that a `<turbo-frame>` should dispatch a `turbo:frame-render` _whenever its contents change_, including its initial render. As a complementary change to that behavior, the `turbo:frame-load` events will be dispatched with `detail.fetchResponse` as a reference to the `FetchResponse`. Ideally, the `turbo:frame-render` would not expose the `detail.fetchResponse` reference. However, removing it would be a breaking change. To that end, this commit dispatches a `detail` that prints a console warning (encouraging a migration to `turbo:frame-load`) whenever a `turbo:frame-render` listener reads the `detail.fetchResponse` property. Future major releases can remove the property and warning.
- Loading branch information
1 parent
2f0d46f
commit 47fb78d
Showing
4 changed files
with
45 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters