Bug 250903 - toLocaleLowerCase and toLocaleUpperCase do not throw on empty string
Summary: toLocaleLowerCase and toLocaleUpperCase do not throw on empty string
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: Safari 16
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: BrowserCompat, InRadar
Depends on:
Blocks:
 
Reported: 2023-01-20 08:58 PST by Robert Flack
Modified: 2023-01-23 14:22 PST (History)
4 users (show)

See Also:


Attachments
Demonstrates the error thrown with a string passed and none without. (515 bytes, text/html)
2023-01-20 08:58 PST, Robert Flack
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Flack 2023-01-20 08:58:30 PST
Created attachment 464579 [details]
Demonstrates the error thrown with a string passed and none without.

I believe by spec toLocaleLowerCase / toLocaleUpperCase are required to throw a RangeError if you specify an invalid locale per section 9.2.1 CanicalizeLocaleList with the exception thrown in step 7.c.v (https://tc39.es/ecma402/#sec-canonicalizelocalelist)

Firefox throws a RangeError for both of the following:
''.toLocaleLowerCase('');
''.toLocaleUpperCase('');

Chrome throws a RangeError for ''.toLocaleUpperCase('') and before M109 did for ''.toLocaleLowerCase(''), the lack of error for lowercase is tracked as https://crbug.com/1409058

Safari does not throw an error if the string being converted is empty, but does if you have a non-empty string being converted.
Comment 1 Radar WebKit Bug Importer 2023-01-23 12:22:28 PST
<rdar://problem/104568214>
Comment 2 Yusuke Suzuki 2023-01-23 12:24:12 PST
Pull request: https://github.com/WebKit/WebKit/pull/8986
Comment 3 EWS 2023-01-23 14:22:17 PST
Committed 259242@main (e99f5f69bf90): <https://commits.webkit.org/259242@main>

Reviewed commits have been landed. Closing PR #8986 and removing active labels.