Open srghma opened 4 years ago
This would be possible by having alternative build
functions to initialize the vdom machines. For example:
https://github.com/purescript-halogen/purescript-halogen-vdom/blob/8b91e55019060f50779dba20959f47cf4b60678d/src/Halogen/VDom/DOM.purs#L71-L75
This creates a text node, but a hypothetical hydration implementation would check the DOM for an existing node first and reuse that.
elm implementation https://github.com/elm/virtual-dom/blob/master/src/Elm/Kernel/VirtualDom.js#L1531
react implementation
e.g. here warning for text difference https://github.com/facebook/react/blob/823dc581fea8814a904579e85a62da6d18258830/packages/react-dom/src/client/ReactDOMComponent.js#L1072
also warned for extra attributes https://github.com/facebook/react/blob/823dc581fea8814a904579e85a62da6d18258830/packages/react-dom/src/client/ReactDOMComponent.js#L222
warnForPropDifference
I have found that prerendered html should not contain any newlines
because
with
<div id="app">
<div class="component">
<div class="label1">test label 1</div>
<div class="label2">test label 2</div>
</div>
</div>
componentNode.childNodes
will return newspaces too
the correct version is
<div id="app">
<div class="component"><div class="label1">test label 1</div><div class="label2">test label 2</div></div>
</div>
react does the same https://jsbin.com/majoxoqoje/edit?html,js,console,output
extraAttributeNames are defined here https://github.com/facebook/react/blob/823dc581fea8814a904579e85a62da6d18258830/packages/react-dom/src/client/ReactDOMComponent.js#L1029-L1050
unknown props are downcased and removed https://github.com/facebook/react/blob/823dc581fea8814a904579e85a62da6d18258830/packages/react-dom/src/client/ReactDOMComponent.js#L1134
I have mentioned it here https://github.com/purescript-halogen/purescript-halogen/issues/610#issuecomment-614393683
just like for:
The second link is just for reference. It builds VDOM from DOM node, but our
hydrate
method should