neomjs / neo

The application worker driven frontend framework
https://neomjs.com
MIT License
2.75k stars 147 forks source link

vdom.Helper: createDeltas() => add support for replacing a node with an array of child nodes #5518

Closed tobiu closed 6 days ago

tobiu commented 6 days ago

This is a mix of a bug report and a feature request.

The engine can handle moving a child node upwards inside the DOM tree => replacing a parent.

example:

old tree:

div id="level-1"
    div id="level-2"
        div id="level-3"

new tree:

div id="level-1"
    div id="level-3"

In this case we get a delta telling "level-3" to replace "level-2". all good.

What does not work: old tree:

div id="level-1"
    div id="level-2"
        div id="level-3-1"
        div id="level-3-2"

new tree:

div id="level-1"
    div id="level-3-1"
    div id="level-3-2"

In this case we get the same delta as before: "level-3-1" will replace "level-2" and all other siblings "level-3-x" will get lost.

The desired output would be to move all "level-3-x" nodes into the parentNode "level-1" and then delete the node "level-2".

We need it for layout.Cube, in case we want to switch the owner container to a different layout (e.g. VBox). We might need this one for the Portal App.

I will write a breaking Siesta Test first, then take a look into the engine. If there is not an easy (and not too expensive performance wise) way to fix it, I will do it.

Otherwise we could manually create the desired deltas.

tobiu commented 6 days ago

Screenshot 2024-07-03 at 19 22 52