-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
3 changed files
with
225 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
test/hydration/samples/head-meta-hydrate-duplicate/_after_head.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<title>Some Title</title> | ||
<link href="/" rel="canonical"> | ||
<meta content="some description" name="description"> | ||
<meta content="some keywords" name="keywords"> | ||
<meta content="some keywords" name="keywords"> | ||
<title>Some Title</title> |