mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibJS: Account for negative numbers in ToTemporalDurationRecord
This is a normative change in the Temporal spec. See: https://github.com/tc39/proposal-temporal/commit/fa9d547
This commit is contained in:
parent
0e6d503317
commit
3492fbf9cf
Notes:
sideshowbarker
2024-07-18 04:52:32 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/3492fbf9cf7 Pull-request: https://github.com/SerenityOS/serenity/pull/9752 Reviewed-by: https://github.com/IdanHo ✅
1 changed files with 3 additions and 10 deletions
|
@ -110,21 +110,14 @@ TemporalDuration to_temporal_duration_record(GlobalObject& global_object, Object
|
|||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
// iii. If val is NaN, +∞ or -∞, then
|
||||
if (value.is_nan() || value.is_infinity()) {
|
||||
// iii. If ! IsIntegralNumber(val) is false, then
|
||||
if (!value.is_integral_number()) {
|
||||
// 1. Throw a RangeError exception.
|
||||
vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidDurationPropertyValueNonIntegral, property.as_string(), value.to_string_without_side_effects());
|
||||
return {};
|
||||
}
|
||||
|
||||
// iv. If floor(val) ≠ val, then
|
||||
if (floor(value.as_double()) != value.as_double()) {
|
||||
// 1. Throw a RangeError exception.
|
||||
vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidDurationPropertyValueNonIntegral, property.as_string(), value.to_string_without_side_effects());
|
||||
return {};
|
||||
}
|
||||
|
||||
// v. Set result's internal slot whose name is the Internal Slot value of the current row to val.
|
||||
// iv. Set result's internal slot whose name is the Internal Slot value of the current row to val.
|
||||
result.*internal_slot = value.as_double();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue