nfl / react-helmet

A document head manager for React
MIT License
17.28k stars 657 forks source link

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

Open asilgag opened 2 years ago

asilgag commented 2 years ago

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:

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.

CLAassistant commented 2 years ago

CLA assistant check
All committers have signed the CLA.