react/scripts
Josh Story 978fae4b4f
[Float][Fiber] implement a faster hydration match for hoistable elements (#26154)
This PR is now based on #26256 

The original matching function for `hydrateHoistable` some challenging
time complexity since we built up the list of matchable nodes for each
link of that type and then had to check to exclusion. This new
implementation aims to improve the complexity

For hoisted title tags we match the first title if it is valid (not in
SVG context and does not have `itemprop`, the two ways you opt out of
hoisting when rendering titles). This path is much faster than others
and we use it because valid Documents only have 1 title anyway and if we
did have a mismatch the rendered title still ends up as the
Document.title so there is no functional degradation for misses.

For hoisted link and meta tags we track all potentially hydratable
Elements of this type in a cache per Document. The cache is refreshed
once each commit if and only if there is a title or meta hoistable
hydrating. The caches are partitioned by a natural key for each type
(href for link and content for meta). Then secondary attributes are
checked to see if the potential match is matchable.

For link we check `rel`, `title`, and `crossorigin`. These should
provide enough entropy that we never have collisions except is contrived
cases and even then it should not affect functionality of the page. This
should also be tolerant of links being injected in arbitrary places in
the Document by 3rd party scripts and browser extensions

For meta we check `name`, `property`, `http-equiv`, and `charset`. These
should provide enough entropy that we don't have meaningful collisions.
It is concievable with og tags that there may be true duplciates `<meta
property="og:image:size:height" content="100" />` but even if we did
bind to the wrong instance meta tags are typically only read from SSR by
bots and rarely inserted by 3rd parties so an adverse functional outcome
is not expected.
2023-03-06 19:52:35 -08:00
..
babel Upgrade prettier (#26081) 2023-01-31 08:25:05 -05:00
bench Upgrade prettier (#26081) 2023-01-31 08:25:05 -05:00
circleci Add snapshot testing on e2e test failure (#24672) 2022-06-06 10:36:58 -07:00
devtools Bypass packages that are already published when confirmed by users (#26141) 2023-02-10 11:28:31 -05:00
error-codes [Float][Fiber] implement a faster hydration match for hoistable elements (#26154) 2023-03-06 19:52:35 -08:00
eslint [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
eslint-rules Upgrade prettier (#26081) 2023-01-31 08:25:05 -05:00
flow Upgrade Flow to 0.201 (#26326) 2023-03-06 10:33:22 -05:00
git Remove leftover env variable logic in pre-commit hook 2015-09-01 14:35:47 -07:00
jest SchedulerMock.unstable_yieldValue -> SchedulerMock.log (#26312) 2023-03-06 11:09:07 -05:00
perf-counters [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
prettier Upgrade prettier (#26081) 2023-01-31 08:25:05 -05:00
print-warnings Upgrade prettier (#26081) 2023-01-31 08:25:05 -05:00
release SchedulerMock.unstable_yieldValue -> SchedulerMock.log (#26312) 2023-03-06 11:09:07 -05:00
rollup Use content hash for facebook-www builds (#26331) 2023-03-06 17:13:17 -05:00
shared Split out Edge and Node implementations of the Flight Client (#26187) 2023-02-21 13:18:24 -05:00
tasks Bug: yarn flow dom does not exist, so console should suggest yarn flow dom-node (#26213) 2023-02-21 21:30:34 +01:00
yarn chore: upgrade to jest 24 (#15778) 2019-10-03 22:44:18 +05:30
authors AUTHORS 2013-09-09 23:42:54 -07:00