van
van copied to clipboard
van.hydrate is not working correctly?
I expect that when calling hydration, the entire DOM will be preserved and all reactivity/interactivity and events will be bound to it. However, I see that when calling hydration, all (even static) DOM is rendered.
Is this incorrect work of van.hydrate or am I doing something wrong?
For example, I modified the basic example: https://codesandbox.io/p/devbox/solitary-dream-fmqz28
Similar example in Vue (no re-rendering occurs): https://stackblitz.com/edit/vue-ssr-example-irrowjm5?file=client.js (auto-activation of hydrate after 7 seconds)
as mentioned in the document https://vanjs.org/ssr#hydration van.hydrate replaces the SSR component
In that case, it's strange that it's called hydrate. It's more correct to call it replace or update.
The point of hydration is to not run rendering and bind reactivity to the existing DOM.
I believe it's the callers of hydrate to ensure the new DOM hydrated element has the same semantic of the existing static element. It's the choice of implementation details in VanJS where we decided replacing the DOM element is the way to hydrate.