0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-11-30 17:00:40 +01:00
svelte/test/hydration
Hasan Altan Birler 04bc37de31
Improve hydration by reordering optimally (#6395)
* Implement new hydration optimization

During hydration, greedily pick nodes that exist in the original HTML that should not be detached.
Detach the rest.

* Implement optimal reordering during hydration

During hydration we track the order in which children are claimed.
Afterwards, rather than reordering them greedily one-by-one, we reorder all claimed children during the first append optimally.
The optimal reordering first finds the longest subsequence of children that have been claimed in order.
These children will not be moved.
The rest of the children are reordered to where they have to go.
This algorithm is guaranteed to be optimal in the number of reorderings.

The hydration/head-meta-hydrate-duplicate test sample has been modified slightly.
The order in which the <title> tag is being generated changed, which does not affect correctness.

* Fix issue potentially causing extra reorders

Not sorting children before executing the `insertBefore` calls in `init_hydrate` potentially caused extra `insertBefore` calls in `append`

* Simplify`init_hydrate` sorting logic
2021-06-22 10:34:48 -04:00
..
samples Improve hydration by reordering optimally (#6395) 2021-06-22 10:34:48 -04:00
index.ts Curly braces linting fixes (#5585) 2020-10-26 13:25:03 -04:00