mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:37:37 +00:00
LibJS: Fix TemporalDurationLike property order
The table is sorted alphabetically and supposed to be iterated in that oder. Also move this to a templated lambda for later re-use with different target structs and value types.
This commit is contained in:
parent
152251f5a7
commit
7355c23e17
2 changed files with 26 additions and 18 deletions
|
@ -87,25 +87,8 @@ PartialDuration to_partial_duration(GlobalObject& global_object, Value temporal_
|
|||
// 3. Let any be false.
|
||||
auto any = false;
|
||||
|
||||
struct PartialDurationProperty {
|
||||
Optional<double> PartialDuration::*internal_slot { nullptr };
|
||||
PropertyName property;
|
||||
};
|
||||
auto properties = AK::Array<PartialDurationProperty, 10> {
|
||||
PartialDurationProperty { &PartialDuration::years, vm.names.years },
|
||||
PartialDurationProperty { &PartialDuration::months, vm.names.months },
|
||||
PartialDurationProperty { &PartialDuration::weeks, vm.names.weeks },
|
||||
PartialDurationProperty { &PartialDuration::days, vm.names.days },
|
||||
PartialDurationProperty { &PartialDuration::hours, vm.names.hours },
|
||||
PartialDurationProperty { &PartialDuration::minutes, vm.names.minutes },
|
||||
PartialDurationProperty { &PartialDuration::seconds, vm.names.seconds },
|
||||
PartialDurationProperty { &PartialDuration::milliseconds, vm.names.milliseconds },
|
||||
PartialDurationProperty { &PartialDuration::microseconds, vm.names.microseconds },
|
||||
PartialDurationProperty { &PartialDuration::nanoseconds, vm.names.nanoseconds },
|
||||
};
|
||||
|
||||
// 4. For each row of Table 7, except the header row, in table order, do
|
||||
for (auto& [internal_slot, property] : properties) {
|
||||
for (auto& [internal_slot, property] : temporal_duration_like_properties<PartialDuration, Optional<double>>(vm)) {
|
||||
// a. Let property be the Property value of the current row.
|
||||
|
||||
// b. Let value be ? Get(temporalDurationLike, property).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue