Skip to content

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

Merged
dhh merged 1 commit intohotwired:mainfrom
botandrose:expose_frame_renderer
Apr 30, 2022
Merged

Expose FrameRenderer so we can extend its behavior, e.g. vDOM.#568
dhh merged 1 commit intohotwired:mainfrom
botandrose:expose_frame_renderer

Conversation

@botandrose
Copy link
Copy Markdown
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