dyo / dyo

Dyo is a JavaScript library for building user interfaces.

Home Page:https://dyo.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug in the reconciler (branch 'hooks')

mcjazzyfunky opened this issue · comments

There seems to be a bug in the Reconciler (=> branch 'hooks'):

Is it possible that the line:
https://github.com/dyo/dyo/blob/hooks/src/Reconcile.js#L211

a.splice((atail = aend > 0 ? a[aend - 1] : a[aend + 1], aend--), 1)

should be

a.splice((atail = aend > 0 ? a[aend - 1] : a[aend], aend--), 1)

instead?
As I have a case where aend is 0 and a is an one-element array, so atail becomes undefined which is wrong.

There was a bug there but it was regarding not decrementing --alen. The latest commit reflects the diff.

a.splice((atail = aend > 0 ? a[aend - 1] : a[aend + 1], --alen, aend--), 1)

As you mention undefined is handled in src/Commit.js#L21 within the branch that determines a insert vs append operation.

Whatever you have changed, my tiny little demo is working now ... thanks 😃:
I will close this issue as it is fixed.