mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 08:48:57 +00:00
LibJS: Read user options in a Temporal AO sooner
This is a normative change in the Temporal proposal. See:
9924aa4
This commit is contained in:
parent
355589a89e
commit
0c038bf12e
Notes:
github-actions[bot]
2025-08-28 23:15:36 +00:00
Author: https://github.com/trflynn89
Commit: 0c038bf12e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6019
Reviewed-by: https://github.com/gmta ✅
1 changed files with 13 additions and 13 deletions
|
@ -1693,34 +1693,34 @@ ThrowCompletionOr<DifferenceSettings> get_difference_settings(VM& vm, DurationOp
|
|||
// 2. Let largestUnit be ? GetTemporalUnitValuedOption(options, "largestUnit", UNSET).
|
||||
auto largest_unit = TRY(get_temporal_unit_valued_option(vm, options, vm.names.largestUnit, Unset {}));
|
||||
|
||||
// 3. Perform ? ValidateTemporalUnitValue(largestUnit, unitGroup, « AUTO »).
|
||||
// 3. Let roundingIncrement be ? GetRoundingIncrementOption(options).
|
||||
auto rounding_increment = TRY(get_rounding_increment_option(vm, options));
|
||||
|
||||
// 4. Let roundingMode be ? GetRoundingModeOption(options, TRUNC).
|
||||
auto rounding_mode = TRY(get_rounding_mode_option(vm, options, RoundingMode::Trunc));
|
||||
|
||||
// 5. Let smallestUnit be ? GetTemporalUnitValuedOption(options, "smallestUnit", UNSET).
|
||||
auto smallest_unit = TRY(get_temporal_unit_valued_option(vm, options, vm.names.smallestUnit, Unset {}));
|
||||
|
||||
// 6. Perform ? ValidateTemporalUnitValue(largestUnit, unitGroup, « AUTO »).
|
||||
TRY(validate_temporal_unit_value(vm, vm.names.largestUnit, largest_unit, unit_group, { { Auto {} } }));
|
||||
|
||||
// 4. If largestUnit is UNSET, then
|
||||
// 7. If largestUnit is UNSET, then
|
||||
if (largest_unit.has<Unset>()) {
|
||||
// a. Set largestUnit to AUTO.
|
||||
largest_unit = Auto {};
|
||||
}
|
||||
|
||||
// 5. If disallowedUnits contains largestUnit, throw a RangeError exception.
|
||||
// 8. If disallowedUnits contains largestUnit, throw a RangeError exception.
|
||||
if (auto* unit = largest_unit.get_pointer<Unit>(); unit && disallowed_units.contains_slow(*unit))
|
||||
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, temporal_unit_to_string(*unit), vm.names.largestUnit);
|
||||
|
||||
// 6. Let roundingIncrement be ? GetRoundingIncrementOption(options).
|
||||
auto rounding_increment = TRY(get_rounding_increment_option(vm, options));
|
||||
|
||||
// 7. Let roundingMode be ? GetRoundingModeOption(options, TRUNC).
|
||||
auto rounding_mode = TRY(get_rounding_mode_option(vm, options, RoundingMode::Trunc));
|
||||
|
||||
// 8. If operation is SINCE, then
|
||||
// 9. If operation is SINCE, then
|
||||
if (operation == DurationOperation::Since) {
|
||||
// a. Set roundingMode to NegateRoundingMode(roundingMode).
|
||||
rounding_mode = negate_rounding_mode(rounding_mode);
|
||||
}
|
||||
|
||||
// 9. Let smallestUnit be ? GetTemporalUnitValuedOption(options, "smallestUnit", UNSET).
|
||||
auto smallest_unit = TRY(get_temporal_unit_valued_option(vm, options, vm.names.smallestUnit, Unset {}));
|
||||
|
||||
// 10. Perform ? ValidateTemporalUnitValue(smallestUnit, unitGroup).
|
||||
TRY(validate_temporal_unit_value(vm, vm.names.smallestUnit, smallest_unit, unit_group));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue