Skip to content

Commit

Permalink
Disconnect loaded Frame Element while rendering
Browse files Browse the repository at this point in the history
Closes [#453]

---

While loading a matching `<turbo-frame>` element from a response body,
the `FrameController` "activates" it by invoking
`FrameElement.connectedCallback()` after importing it into the document.

During that activation, several event listeners are attached, including
some on the `document`.

Unfortunately, that `FrameElement.connectedCallback()` invocation is
never mirrored with a `FrameElement.disconnectedCallback()` invocation,
so the attached listeners are never detached, causing an accumulation.

This commit invokes the `disconnectedCallback()` after loaded element's
contents are extracted into the browser's document.

[#453]: #453
  • Loading branch information
seanpdoyle committed Nov 18, 2021
1 parent ca1117b commit 666429f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/core/frames/frame_renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class FrameRenderer extends Renderer<FrameElement> {
if (sourceRange) {
sourceRange.selectNodeContents(frameElement)
this.currentElement.appendChild(sourceRange.extractContents())
frameElement.disconnectedCallback()
}
}

Expand Down

0 comments on commit 666429f

Please sign in to comment.