From a587078d1bcf631b06987fe9d916eac3ce8e762d Mon Sep 17 00:00:00 2001 From: Dom Christie Date: Tue, 9 Jan 2024 22:20:55 +0000 Subject: [PATCH] Revert #926. It is not necessary to pass along isPreview through various methods in order to determine whether a render is a preview since that can be determined via the data-turbo-preview attribute. (As discussed in https://github.com/hotwired/turbo/pull/926#issuecomment-1692292545) --- src/core/frames/frame_controller.js | 2 +- src/core/session.js | 16 ++++++++-------- src/core/view.js | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/core/frames/frame_controller.js b/src/core/frames/frame_controller.js index 5940ba761..02358d123 100644 --- a/src/core/frames/frame_controller.js +++ b/src/core/frames/frame_controller.js @@ -258,7 +258,7 @@ export class FrameController { // View delegate - allowsImmediateRender({ element: newFrame }, _isPreview, options) { + allowsImmediateRender({ element: newFrame }, options) { const event = dispatch("turbo:before-frame-render", { target: this.element, detail: { newFrame, ...options }, diff --git a/src/core/session.js b/src/core/session.js index bf653539a..8dafa6f13 100644 --- a/src/core/session.js +++ b/src/core/session.js @@ -298,8 +298,8 @@ export class Session { } } - allowsImmediateRender({ element }, isPreview, options) { - const event = this.notifyApplicationBeforeRender(element, isPreview, options) + allowsImmediateRender({ element }, options) { + const event = this.notifyApplicationBeforeRender(element, options) const { defaultPrevented, detail: { render } @@ -312,9 +312,9 @@ export class Session { return !defaultPrevented } - viewRenderedSnapshot(_snapshot, isPreview, renderMethod) { + viewRenderedSnapshot(_snapshot, _isPreview, renderMethod) { this.view.lastRenderedLocation = this.history.location - this.notifyApplicationAfterRender(isPreview, renderMethod) + this.notifyApplicationAfterRender(renderMethod) } preloadOnLoadLinksForView(element) { @@ -370,15 +370,15 @@ export class Session { return dispatch("turbo:before-cache") } - notifyApplicationBeforeRender(newBody, isPreview, options) { + notifyApplicationBeforeRender(newBody, options) { return dispatch("turbo:before-render", { - detail: { newBody, isPreview, ...options }, + detail: { newBody, ...options }, cancelable: true }) } - notifyApplicationAfterRender(isPreview, renderMethod) { - return dispatch("turbo:render", { detail: { isPreview, renderMethod } }) + notifyApplicationAfterRender(renderMethod) { + return dispatch("turbo:render", { detail: { renderMethod } }) } notifyApplicationAfterPageLoad(timing = {}) { diff --git a/src/core/view.js b/src/core/view.js index d077e9a24..8c5ae2e82 100644 --- a/src/core/view.js +++ b/src/core/view.js @@ -65,7 +65,7 @@ export class View { const renderInterception = new Promise((resolve) => (this.#resolveInterceptionPromise = resolve)) const options = { resume: this.#resolveInterceptionPromise, render: this.renderer.renderElement } - const immediateRender = this.delegate.allowsImmediateRender(snapshot, isPreview, options) + const immediateRender = this.delegate.allowsImmediateRender(snapshot, options) if (!immediateRender) await renderInterception await this.renderSnapshot(renderer)