ihp icon indicating copy to clipboard operation
ihp copied to clipboard

SSC inserts nodes as child nodes when it shouldn't

Open neongreen opened this issue 3 years ago • 3 comments

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);
}

neongreen avatar Nov 25 '21 14:11 neongreen

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

leobm avatar Dec 11 '22 16:12 leobm

Unfortunately not, because I stopped using IHP. Feel free to close the issue or keep it open as you see fit

neongreen avatar Dec 17 '22 02:12 neongreen

OK, I will try to simulate such a case myself. Thanks for your answer anyway

leobm avatar Dec 17 '22 13:12 leobm