LearnNewsExamplesServices
Frontmatter
id5549
titlevdom.Helper: createDeltas() => oldChildNode which exists somewhere inside the new vnode tree edge case
stateClosed
labels
enhancement
assignees[]
createdAtJul 9, 2024, 7:31 PM
updatedAtJul 9, 2024, 8:58 PM
githubUrlhttps://github.com/neomjs/neo/issues/5549
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJul 9, 2024, 8:58 PM

vdom.Helper: createDeltas() => oldChildNode which exists somewhere inside the new vnode tree edge case

Closed v8.1.0 enhancement
tobiu
tobiu commented on Jul 9, 2024, 7:31 PM

For the given edge case, we can move the item as needed without(!) triggering further createDeltas() calls.

This should be able to resolve a low prio edge-case, where we are still moving items to their same index:

        vdom =
        {id: 'neo-calendar-week', cn: [
            {id: 'neo-column-1', cls: ['neo-c-w-column'], cn: [
                {id: 'neo-event-2', cls: ['neo-event', 'foo']},
                {id: 'neo-event-1', cls: ['neo-event']}
            ]},
            {id: 'neo-column-2', cls: ['neo-c-w-column'], cn: []}
        ]};

        output = VdomHelper.update({vdom, vnode}); deltas = output.deltas; vnode = output.vnode;

        t.is(deltas.length, 2, 'Count deltas equals 2');

        t.isDeeplyStrict(deltas, [
            {action: 'moveNode', id: 'neo-event-2', index: 0, parentId: 'neo-column-1'},
            {cls: {add: ['foo']}, id: 'neo-event-2'}
        ], 'deltas got created successfully');

        t.diag('Revert operation');

        vdom =
        {id: 'neo-calendar-week', cn: [
            {id: 'neo-column-1', cls: ['neo-c-w-column'], cn: [
                {id: 'neo-event-1', cls: ['neo-event']}
            ]},
            {id: 'neo-column-2', cls: ['neo-c-w-column'], cn: [
                {id: 'neo-event-2', cls: ['neo-event']}
            ]}
        ]};

        output = VdomHelper.update({vdom, vnode}); deltas = output.deltas; vnode = output.vnode;

        t.is(deltas.length, 3, 'Count deltas equals 3');

        t.isDeeplyStrict(deltas, [
            {action: 'moveNode', id: 'neo-event-1', index: 0, parentId: 'neo-column-1'}, // todo: does not hurt, but not needed
            {action: 'moveNode', id: 'neo-event-2', index: 0, parentId: 'neo-column-2'},
            {cls: {remove: ['foo']}, id: 'neo-event-2'}
        ], 'deltas got created successfully');
tobiu added the enhancement label on Jul 9, 2024, 7:31 PM
tobiu referenced in commit 1eb368f - "vdom.Helper: createDeltas() => oldChildNode which exists somewhere inside the new vnode tree edge case #5549" on Jul 9, 2024, 8:57 PM
tobiu
tobiu Jul 9, 2024, 8:58 PM

A pretty complex change, but it did reduce the amount of deltas from 3 to 2.

tobiu closed this issue on Jul 9, 2024, 8:58 PM