Skip to content

Commit

Permalink
Update LanguageSelector.astro: value must be omitted for boolean attr…
Browse files Browse the repository at this point in the history
…ibutes in html tags

<select>
  👎<option value="/" selected='true'> English </option>       👈 Change from this
  👍<option value="/" selected> English </option>              👈 to this

According HTML5 spec on boolean attributes
- https://www.w3.org/TR/2008/WD-html5-20080610/semantics.html#boolean
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.
  • Loading branch information
guinetn authored Jan 23, 2024
1 parent 681e838 commit effa5c8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/LanguageSelector.astro
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ const { showFlag = false, languageMapping, ...attributes } = Astro.props;

const label = flag + nativeName;

let selectedAttr = {};
if (supportedLanguage === currentLanguage)
selectedAttr = { ...selectedAttr, selected: ''};

return (
<option value={value} selected={supportedLanguage === currentLanguage}>
<option value={value} {...selectedAttr}>
{label}
</option>
);
Expand Down

0 comments on commit effa5c8

Please sign in to comment.