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.
Make
Renderer
instance available to View
delegates
The changes proposed in [hotwired#1019][] require dispatching the new `Renderer.renderMethod` property as part of the `turbo:render` event. Similarly, there's an opportunity to include that information in the `turbo:before-render`, `turbo:before-frame-render`, and `turbo:frame-render` events. To simplify those chains of object access, this commit changes the `View` class delegate's `allowsImmediateRender` and `viewRenderedSnapshot` methods to accept the `Renderer` instance, instead of individual properties. With access to the instance, the delegate's can read properties like `isPreview` along with the `element` (transitively through the `newSnapshot` property). In order to dispatch the `turbo:frame-render` event closer to the moment in time that the view renders, this commit removes the `Session.frameRendered` callback, and replaces it with a `dispatch("turbo:frame-render")` call inside the `FrameController.viewRenderedSnapshot(renderer)` delegate method. In order to do so, this commit must work around the fact that `turbo:frame-render` events include the `FetchResponse` instance involved in the render. Since that instance isn't available at render time, this commit wraps the `await this.view.render(renderer)` in a utility function that injects the `FetchResponse` instance into the Custom event's `event.detail` object immediately after it's initially dispatched. Ideally, this work around will only be temporary, since the `turbo:frame-load` event also includes `event.detail.fetchResponse`. There's an opportunity to deprecate that property in `turbo:frame-render` events in the future. [hotwired#1019]: hotwired#1019
- Loading branch information
1 parent
c207f5b
commit 8b8aac3
Showing
3 changed files
with
33 additions
and
25 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