Temporal helpers: format only ASCII identifiers specially

Using `\p{ID_Start}` and `\p{ID_Continue}` to match JS identifiers was not
supported everywhere. Let's assume that we only want to format ASCII
identifiers as bare property names. (This doesn't change any tests, just
the formatting of property names in lists of user-observable actions. No
tests currently checked for non-ASCII properties.)
This commit is contained in:
Philip Chimento 2023-06-07 01:59:16 -07:00 committed by Ms2ger
parent f4e31fc397
commit aecd10eec8
1 changed files with 2 additions and 2 deletions

View File

@ -7,7 +7,7 @@ defines: [TemporalHelpers]
features: [Symbol.species, Symbol.iterator, Temporal]
---*/
const IDENTIFIER = /^[$_\p{ID_Start}][$\u200C\u200D\p{ID_Continue}]*$/u;
const ASCII_IDENTIFIER = /^[$_a-zA-Z][$_a-zA-Z0-9]*$/u;
function formatPropertyName(propertyKey, objectName = "") {
switch (typeof propertyKey) {
@ -21,7 +21,7 @@ function formatPropertyName(propertyKey, objectName = "") {
}
case "string":
if (propertyKey !== String(Number(propertyKey))) {
if (IDENTIFIER.test(propertyKey)) {
if (ASCII_IDENTIFIER.test(propertyKey)) {
return objectName ? `${objectName}.${propertyKey}` : propertyKey;
}
return `${objectName}['${propertyKey.replace(/'/g, "\\'")}']`