ihp
ihp copied to clipboard
SSC inserts nodes as child nodes when it shouldn't
Let's say we are diffing and patching from the first HTML snippet into the second one:
<ul>
<li>a</li>
<li>b</li>
<li>c</li>
</ul>
<ul>
<li>b</li>
<li>c</li>
<li>d</li>
</ul>
Here is the produced patch:
[ DeleteNode {node = Node {tagName = "li", attributes = [], children = [TextNode {textContent = "a"}], startOffset = 4, endOffset = 14}, path = [0,0]}
, CreateNode {html = "<li>d</li>", path = [2,0]}
]
Here is what I get in the browser after ihp-ssc.js applies the patch:
<ul>
<li>b</li>
<li>c
<li>d</li>
</li>
</ul>
Not sure where the problem is, on the Haskell side or the JS side.
The JS side does appendChild
but I don't know what the semantics of the path in createNode
supposed to be — maybe it should do something like prependSibling
instead.
function createNode(component, nodeOperation) {
var newElement = htmlStringToDomNode(nodeOperation.html);
nodeOperation.domNode.appendChild(newElement);
}
can you please build a simple example component that generates diseb patch? Then I'll have a look at it, because I had already patched something last time.
thanks
Unfortunately not, because I stopped using IHP. Feel free to close the issue or keep it open as you see fit
OK, I will try to simulate such a case myself. Thanks for your answer anyway