nfl / react-helmet

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

Fixed determining primary attribute key for meta tags #692

Open alex-bukach opened 1 year ago

alex-bukach commented 1 year ago

Problem / Motivation

primaryAttributeKey is set to the last item in the primaryAttributes array which matches the conditions. If the last property value is null, the whole meta tag will be discarded.

An example: <meta content={'some-content'} property={'some-value'} name={null} />. Here primaryAttributeKey will be set to name (as it is last in the list of properties), and then the meta tag will not be rendered as name is null.

Proposed solution

To avoid such situations we should consider only properties with non-false values as candidates for primaryAttributeKey.

alexandermirzoyan commented 58 minutes ago

Can we write tests as well?