Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disconnect loaded Frame Element while rendering #454

Merged
merged 1 commit into from
Nov 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure of a way to add a test to guard against a regression.

The getEventListeners() function used to uncover this leak is defined in the console's suite of tools, and isn't available to the document.

I'm open to ideas!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe attach a listener that increments a global you can check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that the code within the connectedCallback() and disconnectedCallback() fire any events directly. It's also worth noting that we're manually invoking these methods within Turbo itself, so they're kind of "synthetic" connections, which makes a MutationObserver similarly unpredictable, since the underlying element itself might not be attached to the browser's document.

}
}

Expand Down