Skip to content

Commit

Permalink
Stop reloading turbo frames when complete attribute changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Intrepidd committed Feb 8, 2024
1 parent aef1abd commit 510c9ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
22 changes: 6 additions & 16 deletions src/core/frames/frame_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,12 @@ export class FrameController {

sourceURLReloaded() {
const { src } = this.element
this.#ignoringChangesToAttribute("complete", () => {
this.element.removeAttribute("complete")
})
this.element.removeAttribute("complete")
this.element.src = null
this.element.src = src
return this.element.loaded
}

completeChanged() {
if (this.#isIgnoringChangesTo("complete")) return

this.#loadSourceURL()
}

loadingStyleChanged() {
if (this.loadingStyle == FrameLoadingStyle.lazy) {
this.appearanceObserver.start()
Expand Down Expand Up @@ -528,13 +520,11 @@ export class FrameController {
}

set complete(value) {
this.#ignoringChangesToAttribute("complete", () => {
if (value) {
this.element.setAttribute("complete", "")
} else {
this.element.removeAttribute("complete")
}
})
if (value) {
this.element.setAttribute("complete", "")
} else {
this.element.removeAttribute("complete")
}
}

get isActive() {
Expand Down
6 changes: 2 additions & 4 deletions src/elements/frame_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class FrameElement extends HTMLElement {
loaded = Promise.resolve()

static get observedAttributes() {
return ["disabled", "complete", "loading", "src"]
return ["disabled", "loading", "src"]
}

constructor() {
Expand All @@ -48,11 +48,9 @@ export class FrameElement extends HTMLElement {
attributeChangedCallback(name) {
if (name == "loading") {
this.delegate.loadingStyleChanged()
} else if (name == "complete") {
this.delegate.completeChanged()
} else if (name == "src") {
this.delegate.sourceURLChanged()
} else {
} else if (name == "disabled") {
this.delegate.disabledChanged()
}
}
Expand Down

0 comments on commit 510c9ef

Please sign in to comment.