Rewriting sync and patch
tbranyen opened this issue · 1 comments
tbranyen commented
I think diffHTML is pretty rad right now and the API is solid, but there's some imperfect logic and stability that needs correcting before 1.0. While closing in on #64 I was hitting lots of issues and code duplication with insufficient tests to safely refactor all the code with complete confidence.
So before tagging 1.0, I'll be putting my focus into rewriting both the tree synchronization (diff) and the DOM Node patching. Part of this is dramatically reducing the amount of duplicative syncing and patching logic which will bring down the lib filesize as well as thinking about each mutation operation distinctly from the ground up.
Some of the ideas I have are:
- Removing the
MODIFY_ELEMENT
operation in favor ofAPPEND
,PREPEND
,REPLACE
, andREMOVE
. TheMODIFY_ATTRIBUTE
is so simple and accounts for all cases, so that will most likely stay. - Changing the patch from
__do__
totype
which aligns better with Redux actions. - Having a
baton
that carries thepatches
and current operation allowing for a more standardized approach to applying patches. If multiple of the same type of patch occurs, they can be batched into DocumentFragments. I'm not sure if many developers know this, butremoveChild
andinsertBefore
both support Fragments. - Remove
REMOVE_ENTIRE_ELEMENT
,REPLACE_ENTIRE_ELEMENT
, andREMOVE_ELEMENT_CHILDREN
in favor of the new aforementioned element operation types. - Writing more unit tests while refactoring so in the future this is even easier...