You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
intl-displaynames shouldPolyfill incorrectly indicates that polyfill is required #5889
@formatjs/intl-displaynames version 7.1.2 (latest at time of writing)
Describe the bug
The shouldPolyfill function (source) returns a truthy value ('en', if no arguments are specified), even though the browser I am using fully supports Intl.DisplayNames.
This happens because the function decides that Chrome has a script bug (hasScriptBug). It does this by checking what the return value of new DisplayNames(['en'], { type: 'script' }).of('arab') is.
While this check works fine in Firefox, in Chrome this check appears to be case sensitive. The string 'arab' produces 'arab' whereas 'Arab' produces 'Arabic'. The same is true for (for example) 'maya' which gives 'maya' whereas 'Maya' gives 'Mayan hieroglyphs'.
The Unicode code list specifies these script codes with uppercase letters. Would it be sensible to use 'Arab' instead of 'arab' here?
This causes polyfills to be loaded unnecessarily in the site.
> new Intl.DisplayNames(["en"], { type: "script" }).of("arab")
< 'arab'
> new Intl.DisplayNames(["en"], { type: "script" }).of("Arab")
< 'Arabic'
To Reproduce
I am running this in Chrome 143, which as of this writing is the most up-to-date release.
Reproducible Steps/Repo
Steps to reproduce the behavior:
Run the following code:
import{shouldPolyfillasshouldPolyfillDisplayNames}from'@formatjs/intl-displaynames/should-polyfill.js';console.log(shouldPolyfillDisplayNames());// prints 'en' in Chrome, undefined in Firefox
Desktop (please complete the following information):
OS: Windows 11
Browsers: Chrome / Edge 143 (latest at time of writing); Firefox 148 (beta at time of writing; not affected).
Package version: 7.1.2
Expected behavior
I expect shouldPolyfill to return a falsy value in browsers that fully support the Intl.DisplayNames API. This could be solved by using 'Arab' instead of 'arab'. However, I don't know if this is the right way to approach this problem, so I'm opening an issue instead of creating a pull request.
4. Set code to ? [CanonicalCodeForDisplayNames](https://tc39.es/ecma402/#sec-canonicalcodefordisplaynames)(displayNames.[[Type]], code).
5. Let fields be displayNames.[[Fields]].
so browser's supposed to canonicalize arab to Arab before lookup, but it's not. This is why it's returning arab instead of Arabic
Activity
longlho commentedon Jan 14, 2026
Thanks for reporting. Looks like the spec canonicalize
codeto be title case. We'll take a looklonglho commentedon Jan 15, 2026
So this is indeed a Chrome bug still, according to https://tc39.es/ecma402/#sec-Intl.DisplayNames.prototype.of
so browser's supposed to canonicalize
arabtoArabbefore lookup, but it's not. This is why it's returningarabinstead ofArabictest(@formatjs/intl-displaynames): add conformance tests (#5909)