ractivejs/ractive — pull request #1300 by Rich-Harris (2014-10-02 23:52:18+00:00)
Title: gh-1209

**Not ready for merge**

This doesn't yet solve #1209 and #1275 (which is essentially the same bug), but lays the groundwork. Previously, splice and merge operations were handled differently, even though they're both quite similar (shuffling round chunks of DOM, rather than modifying DOM unnecessarily), and this added a fair bit of complexity.

Now, both operations go through the same basic process. This will make it easier to propagate 'smart updates' through component layers, and has made it possible to delete some fairly gnarly code.

There is one caveat - updating sections is now done using a bit of brute force. Previously, fragments that needed to move inside a section were, during a merge operation, detached and reinserted from and to the *real* DOM at the same time as the *virtual* DOM was being updated. That wasn't great, since everywhere else, the virtual DOM gets updated first, then the real DOM gets updated in one go. But now we have a different problem - the DOM gets updated at the right time, but we don't know which fragments need to move where, so we just strip the entire section out and reinsert it in the correct order, which we can safely assume is a step backwards performance-wise. Need to come up with something more elegant before this gets merged in.