Skip to content

Commit

Permalink
Revert hotwired#926.
Browse files Browse the repository at this point in the history
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 hotwired#926 (comment))
  • Loading branch information
domchristie committed Jan 9, 2024
1 parent 0741543 commit a587078
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/core/frames/frame_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
16 changes: 8 additions & 8 deletions src/core/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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) {
Expand Down Expand Up @@ -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 = {}) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a587078

Please sign in to comment.