<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>282504</bug_id>
          
          <creation_ts>2024-11-02 22:47:55 -0700</creation_ts>
          <short_desc>`new Intl.Locale(&apos;und&apos;).language` returns `undefined`, not string `&apos;und&apos;`</short_desc>
          <delta_ts>2025-08-18 15:56:33 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>295853</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>lionel.rowe</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>iKonnyaku40</cc>
    
    <cc>karlcow</cc>
    
    <cc>vitor.roriz</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2072366</commentid>
    <comment_count>0</comment_count>
    <who name="">lionel.rowe</who>
    <bug_when>2024-11-02 22:47:55 -0700</bug_when>
    <thetext>`new Intl.Locale(&apos;und&apos;).language` (and other locales with a `language` of `und`) return `undefined`, rather than the expected string `&apos;und&apos;`. This behavior diverges from the ECMA-402 spec.

Repro:

```js
new Intl.Locale(&apos;xxx&apos;).language // &apos;xxx&apos; (correct result)
new Intl.Locale(&apos;und&apos;).language // undefined (expected &apos;und&apos;)
```

Per ECMA-402 spec:

https://tc39.es/ecma402/#sec-Intl.Locale.prototype.language

&gt; 3. Return GetLocaleLanguage(loc.[[Locale]]).

https://tc39.es/ecma402/#sec-getlocalelanguage

&gt; 1. Let baseName be GetLocaleBaseName(locale).
&gt; 2. Assert: The first subtag of baseName can be matched by the unicode_language_subtag Unicode locale nonterminal.
&gt; 3. Return the first subtag of baseName.

Other browsers/engines:

* Chromium/V8 suffers from the same issue, presumably with a similar cause: https://issues.chromium.org/issues/334251989
* Firefox has the correct behavior

I guess the offending code path is this one? https://github.com/WebKit/WebKit/blob/635a079e5128f24a69f90de3141943153e46e5bb/Source/JavaScriptCore/runtime/IntlLocale.cpp#L489-L494</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2072676</commentid>
    <comment_count>1</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2024-11-04 16:41:32 -0800</bug_when>
    <thetext>This is ICU issue around &quot;und&quot; support.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2072709</commentid>
    <comment_count>2</comment_count>
    <who name="">lionel.rowe</who>
    <bug_when>2024-11-04 18:36:46 -0800</bug_when>
    <thetext>(In reply to Yusuke Suzuki from comment #1)
&gt; This is ICU issue around &quot;und&quot; support.

Apologies for ignorance, this is my first bug report here. Do you mean it&apos;s an issue in ICU itself? Or it&apos;s relating to a preexisting issue against WebKit&apos;s ICU implementation? Or something else?

I don&apos;t think it can be an issue in ICU itself, as ICU doesn&apos;t specify how implementations should _represent_ the various semantics (i.e. there&apos;s nothing in ICU that says an &quot;und&quot; locale shouldn&apos;t be represented as having a nullish &quot;language&quot; field). The problem is rather that ECMA-402 specifies that `GetLocaleLanguage` should return the language subtag unchanged.

From a userland perspective, I first encountered this bug by creating `new Intl.Locale(&apos;und&apos;)` and noticing that its `language` was `undefined`, then noting that the TypeScript types appeared to be wrong. But upon checking the spec, I realized it was the implementation that was wrong, not the TS types.

![TypeScript logo superimposed over Seymour Skinner&apos;s face: &quot;Am I out of ~~touch~~ spec?&quot; &quot;No, it&apos;s the ~~children~~ implementations who are wrong!&quot;](skinner.jpg)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2074106</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-11-09 21:48:13 -0800</bug_when>
    <thetext>&lt;rdar://problem/139586863&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2137196</commentid>
    <comment_count>4</comment_count>
    <who name="Keita Nonaka">iKonnyaku40</who>
    <bug_when>2025-08-18 12:39:53 -0700</bug_when>
    <thetext>In the latest JSC, `new Intl.Locale(&apos;und&apos;).language` correctly returns &quot;und&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2137252</commentid>
    <comment_count>5</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2025-08-18 15:54:31 -0700</bug_when>
    <thetext>Safari TP 125
new Intl.Locale(&apos;und&apos;).language
undefined
new Intl.Locale(&apos;xxx&apos;).language
&quot;xxx&quot;

Firefox Nightly 143.0 and Chrome Canary 141.0
new Intl.Locale(&apos;und&apos;).language
&quot;und&quot;
new Intl.Locale(&apos;xxx&apos;).language
&quot;xxx&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2137253</commentid>
    <comment_count>6</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2025-08-18 15:56:33 -0700</bug_when>
    <thetext>This has been fixed in Bug 295853

*** This bug has been marked as a duplicate of bug 295853 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>