Commit 470d8a2e authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

[Intl] Fix extra propertes in resolvedOptions

While dateStyle or timeStye is specified, we should not
add property listed in "Table Components of date and time formats"
per https://tc39.github.io/proposal-intl-datetime-style/#sec-initializedatetimeformat

Bug: v8:9107
Change-Id: I3e39112ed5f99b05f30b2f50f3cd3102d094f98e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1559213Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60725}
parent cb989656
...@@ -495,16 +495,22 @@ MaybeHandle<JSObject> JSDateTimeFormat::ResolvedOptions( ...@@ -495,16 +495,22 @@ MaybeHandle<JSObject> JSDateTimeFormat::ResolvedOptions(
} }
} }
for (const auto& item : GetPatternItems()) { // If dateStyle and timeStyle are undefined, then internal slots
for (const auto& pair : item.pairs) { // listed in "Table 1: Components of date and time formats" will be set
if (pattern.find(pair.pattern) != std::string::npos) { // in Step 33.f.iii.1 of InitializeDateTimeFormat
CHECK(JSReceiver::CreateDataProperty( if (date_time_format->date_style() == DateTimeStyle::kUndefined &&
isolate, options, date_time_format->time_style() == DateTimeStyle::kUndefined) {
factory->NewStringFromAsciiChecked(item.property.c_str()), for (const auto& item : GetPatternItems()) {
factory->NewStringFromAsciiChecked(pair.value.c_str()), for (const auto& pair : item.pairs) {
Just(kDontThrow)) if (pattern.find(pair.pattern) != std::string::npos) {
.FromJust()); CHECK(JSReceiver::CreateDataProperty(
break; isolate, options,
factory->NewStringFromAsciiChecked(item.property.c_str()),
factory->NewStringFromAsciiChecked(pair.value.c_str()),
Just(kDontThrow))
.FromJust());
break;
}
} }
} }
} }
......
...@@ -36,10 +36,6 @@ var expectedProperties = [ ...@@ -36,10 +36,6 @@ var expectedProperties = [
'timeZone', 'timeZone',
'hourCycle', 'hourCycle',
'hour12', 'hour12',
'weekday',
'year',
'month',
'day',
'dateStyle', 'dateStyle',
]; ];
......
...@@ -36,14 +36,6 @@ var expectedProperties = [ ...@@ -36,14 +36,6 @@ var expectedProperties = [
'timeZone', 'timeZone',
'hourCycle', 'hourCycle',
'hour12', 'hour12',
'weekday',
'year',
'month',
'day',
'hour',
'minute',
'second',
'timeZoneName',
'dateStyle', 'dateStyle',
'timeStyle', 'timeStyle',
]; ];
......
...@@ -36,10 +36,6 @@ var expectedProperties = [ ...@@ -36,10 +36,6 @@ var expectedProperties = [
'timeZone', 'timeZone',
'hourCycle', 'hourCycle',
'hour12', 'hour12',
'hour',
'minute',
'second',
'timeZoneName',
'timeStyle', 'timeStyle',
]; ];
......
...@@ -51,6 +51,7 @@ FEATURE_FLAGS = { ...@@ -51,6 +51,7 @@ FEATURE_FLAGS = {
'String.prototype.matchAll': '--harmony-string-matchall', 'String.prototype.matchAll': '--harmony-string-matchall',
'Symbol.matchAll': '--harmony-string-matchall', 'Symbol.matchAll': '--harmony-string-matchall',
'numeric-separator-literal': '--harmony-numeric-separator', 'numeric-separator-literal': '--harmony-numeric-separator',
'Intl.DateTimeFormat-datetimestyle': '--harmony-intl-datetime-style',
'Intl.Locale': '--harmony-locale', 'Intl.Locale': '--harmony-locale',
'Intl.Segmenter': '--harmony-intl-segmenter', 'Intl.Segmenter': '--harmony-intl-segmenter',
'Symbol.prototype.description': '--harmony-symbol-description', 'Symbol.prototype.description': '--harmony-symbol-description',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment