Giter VIP home page Giter VIP logo

udomdiff's Introduction

webreflection

WebReflection Ltd

udomdiff's People

Contributors

webreflection avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

udomdiff's Issues

Compare Function

Hi, I really like domdiff and found out about udomdiff recently.
I also saw that udomdiff is more performant and smaller but does not provide a compare function, like domdiff does.

So I replaced lines https://github.com/WebReflection/udomdiff/blob/master/index.js#L59,
https://github.com/WebReflection/udomdiff/blob/master/index.js#L63 and https://github.com/WebReflection/udomdiff/blob/master/index.js#L69 with the compare Function and run into Problems with insertBefore on line 49.

How would it be possible to add it again?

Unnecessary (?) extra move operation

Hey,

I've been testing out some diffing algos, curious to see which DOM operations they actually perform.

One of the libraries I tested was this one, and I've come across a case where it seems to do an unnecessary DOM operation.

Here's my test bench:

https://jsfiddle.net/mindplay/o4gbaqw0/

I've added console.log statements for every DOM operation - you can press the buttons to perform various array operations to change the sorting of the elements, and then watch the console output for the exact DOM operations resulting from the diff operation from one state to the next.

It looks good for all operations except "Rotate Up" - which basically means, "take the first item on the list and move it to the bottom", which should be doable with a single insertBefore.

Instead, the result is two operations - a seemingly unnecessary replaceChild operation, followed by the expected insertBefore operation. (The resulting DOM state is correct though.)

With devtools open, you can see two nodes are being affected:

image

It isn't explicitly stated in the README of either this project or the original domdiff, but presumably the point of diffing is to perform as few DOM operations as possible? Just figured I'd report my findings, in case you do consider this a subtle "bug". 🙂

Optimal way to handle fragments

This is really an awesome piece of code! Congrats!

I'm trying to incorporate it in sinuous/map.
I was wondering about a use case when an item is a document fragment.
I see it works nicely with arrays.

what do you recommend for handling fragments?
convert the list items to arrays first or use something like uwire?

thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.