question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implement a fix for the `<title>` tag when rehydration is enabled

See original GitHub issue

I only have a shallow understanding of this issue so anyone who can do it more justice please feel free to edit this description 👍

As was reported in https://github.com/glimmerjs/glimmer-vm/issues/796 there have been some issues where Fastboot has been adding comment nodes to track rehydration to the <title> tag but because the browser does not “interpret” any html contained in the <title> tag, the full text of the comments will be output in the browser’s title. This will then immediately flash when Ember boots and the comments are removed.

As this is quite a high impact issue and it is likely to affect quite a few people who intend to use Fastboot in production we need to come up with a solution that is workable for everyone.

Current proposed potential solutions:

  • Special-case the title tag and make Fastboot more smart about the rendering and rehydration of this one tag.
  • Implement a linting system that warned about cases that would cause issues with the title tag
  • Implement some sort of AST in the Fastboot engine that would be able to rewrite any problematic tags (like <title>) in a more effective way.

One thing to consider when implementing a solution to this issue: we need to not just make sure that the HTML that is “returned from the server” is correct, we also need to make sure that the rehydration code also knows how to deal with the special case when trying to update the DOM. For example, if we took a purely naive approach to this we might end up with duplicate <title> tags, which would not give the desired behaviour because the second <title> tag would not “win” over the first 👍

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
CvXcommented, Jun 28, 2019

Btw. I also worked on an alternative, low-level solution (in simple-html-tokenizer and glimmer-vm). It supports <title>, <style>, and <script>.

I gotta fix remaining minor issues, but seems to be working overall! I’ll share the results shortly. 🙂

0reactions
CvXcommented, Jun 28, 2019

Cross-posting for those not following the glimmer-vm issue: 😉 https://github.com/glimmerjs/glimmer-vm/issues/796#issuecomment-506818798

Read more comments on GitHub >

github_iconTop Results From Across the Web

A title element received an array with more than 1 ... - GitHub
I would like to set the <title> tag dynamically from this input. ... markup and comments as text in the title and hydration...
Read more >
React 18: Hydration failed because the initial UI does not ...
I have react 18.2.0 with next 12.2.4 and I fix hydration with this code import { useEffect, useState } from 'react' import {...
Read more >
What is an HTML Title Tag and How You Can Change the ...
Update the text between the opening and closing title tags, i.e. <title> and </title>. For this to work, you must maintain the structure...
Read more >
Keeping Server-Side Rendering Cool With React Hydration
The purpose of this article is to share some helpful things to keep in mind to render a seamless experience as a Server-Side...
Read more >
The Document Title element - HTML - MDN Web Docs - Mozilla
The HTML element defines the document's title that is shown in a browser's title bar or a page's tab. It only contains text;...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found