yassinedoghri / astro-i18next

An astro integration of i18next + some utility components to help you translate your astro websites!
https://astro-i18next.yassinedoghri.com
MIT License
502 stars 38 forks source link

fix: Update LanguageSelector.astro as value must be omitted for boolean attributes in html tags #186

Open guinetn opened 8 months ago

guinetn commented 8 months ago
<select class="language-selector"…>  
  👎 <option value="/" selected='true'> English </option>       👈 Change from this  
  👍 <option value="/" selected> English </option>              👈 to this  

According HTML5 spec on boolean attributes
If the attribute is present, its value must either be the empty string or a value that is a case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace.

Describe your changes

The code create a single selected attribute instead of a selected='true' as required by the html5 spec.
An empty attribute object is first created.
It is populated with the selected attribute if needed, using js spread syntax.
Finally the attribute object is injected in the option tag.

Fixes

Warnings with html syntax checkers.

Checklist