Closed silverwind closed 8 months ago
Upon further investigation, I think MDN is in error. The "unknown" word only appears in old W3C specs, but as literal text:
The default value of this attribute is unknown
The WHATWG spec recommends the empty string as the default.
Its value must be a valid BCP 47 language tag, or the empty string. Setting the attribute to the empty string indicates that the primary language is unknown.
On the other hand, API's like Intl.RelativeTimeFormat
and Intl.DateTimeFormatOptions
reject the empty string for their locales
option, and it seems the best thing to pass to those APIs would be a empty array.
I have a feeling it's likely better to not touch this any further, lest we break those whacky Intl
APIs.
Yeah default
was carefully chosen as I think it doesn't reject. In reality I think this is somewhat undefined behavior for this element as anywhere we expect it to be used should have at minimum a lang
attribute on the HTML element.
I think for lang
being a HTML attribute, empty string makes most sense. Intl APIs like Intl.DateTimeFormat
not accepting empty string is a interop issue, but it also raises the question whether a lang
is also a locale
or whether they are different concepts.
As far as I understand lang=''
is equivalent to locales=[]
, both result in "current locale" behaviour.
I submitted https://github.com/mdn/content/pull/32604 to correct MDN.
As per MDN:
I'm pretty sure the previous value
default
was actually invalid.