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

options._diff not called for implicit Fragments #317

Open
marvinhagemeister opened this issue Sep 23, 2023 · 2 comments
Open

options._diff not called for implicit Fragments #317

marvinhagemeister opened this issue Sep 23, 2023 · 2 comments

Comments

@marvinhagemeister
Copy link
Member

import { render, h,options, Fragment}  from "preact"
import renderToString from "preact-render-to-string"

const oldDiff = options.__b;
options.__b = (vnode) => {
  if (vnode.type === Fragment) {
    console.log(vnode.type === Fragment ? vnode.props:null)
  }
  if (oldDiff) oldDiff(vnode)
}

function App() {
  return <div>
    <h1>test</h1>
    {[
      <p key="1">1</p>,
      <p key="2">2</p>,
      <p key="3">3</p>,
    ]}
  </div>
}

const app = document.getElementById("app");
render(<App />, app)

console.log("=====")

// Fragments not visible in options._diff with RTS
renderToString(<App />);
@JoviDeCroock
Copy link
Member

Hmmm, most likely because we do this different compared to Preact diffing, in RTS we just go over the Array, child by child while in Preact we stub in a new element

@marvinhagemeister
Copy link
Member Author

Yeah, admittedly my use case is pretty esoteric. I doubt the current behavior leads to problems. Need to put some more thought into it, as there might be a way to work around it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants