-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): add hydration protected elements
With this commit, we are now able to handle hydration-protected elements and their attributes. This enhancement is aimed at improving UX and reducing the number of HTTP requests made by browsers to external resources during the hydration process. Take, for example, the `iframe` element with a static `src` attribute, which is rendered on the server. When we begin hydrating that element on the client, it attempts to set up the static attributes again. This includes setting the `src` attribute again with the same value it already has. Browsers interpret each change to the `src` attribute as a new request to load the specified resource. Consequently, the video may flicker as the browser attempts to reload it. We now maintain a map of elements that should be protected from hydration. Each element (acting as a key) maps to a list of attributes, for instance, `iframe -> ['src']`. When we look up an existing element, we check its tag name and if there's a list of attributes associated with it. If we encounter an `iframe` (or other protected element), we iterate over its protected attributes and check whether that element already has those attributes set. If it does, we save this information in the hydration info map to use it when calling `setAttributes`.
- Loading branch information
Showing
19 changed files
with
331 additions
and
44 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
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
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
Oops, something went wrong.