react-helmet icon indicating copy to clipboard operation
react-helmet copied to clipboard

Ensure "data-react-helmet" always renders its value as "true"

Open asilgag opened this issue 4 years ago • 1 comments

The value of "data-react-helmet" attribute is set several times and in several contexts across react-helmet. In all cases is set as a string ("true"), except in generateTitleAsReactComponent() and generateTagsAsReactComponent(), where it's value is a boolean (true).

This subtle inconsistency has no effect in most cases, except when using Preact + preact-compat:

  • React renders a boolean value as data-react-helmet="true" (it might change in the future)
  • Preact renders a boolean value as data-react-helmet (it might change in the future)

Both are valid syntax, but I have encountered that some social media scrappers (like Whatsapp) do not understand a meta tag if it contains an empty data attribute. Hence, <meta data-react-helmet property="og:title" content="My title" /> is considered incorrect and thus not parsed.

We should ensure the consistency of values for that data attribute, to ensure it's always rendered the same way, regardless the fact of using React of Preact. At this moment, it's relaying on React's interpretation of boolean values, that could be changed in the future, which could lead to unexpected results.

asilgag avatar Oct 06 '21 09:10 asilgag

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Oct 06 '21 09:10 CLAassistant