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

Expose FrameRenderer so we can extend its behavior, e.g. vDOM. #568

Merged
merged 1 commit into from
Apr 30, 2022

Conversation

botandrose
Copy link
Contributor

Hello, thank you for Turbo, I really love it! This PR is basically the exact same motivation as exposing PageRenderer in #305

With this, its trivial to replace frame rendering with a Virtual DOM like so:

import morphdom from "morphdom";
import { FrameRenderer } from "@hotwired/turbo";

FrameRenderer.prototype.loadFrameElement = function() {
  morphdom(this.currentElement, this.newElement, {
    childrenOnly: true,
    onBeforeElUpdated: function(fromEl, toEl) {
      return !fromEl.isEqualNode(toEl);
    }
  });
}

I don't believe there's an alternative, at present. If a before-frame-render event gets added, like in #431, it might be possible to do it through that.

@dhh dhh merged commit 5e52e25 into hotwired:main Apr 30, 2022
@botandrose botandrose deleted the expose_frame_renderer branch April 30, 2022 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants