diff --git a/core/engine/src/builtins/temporal/duration/mod.rs b/core/engine/src/builtins/temporal/duration/mod.rs index 379e4f33100..aca0c835a7e 100644 --- a/core/engine/src/builtins/temporal/duration/mod.rs +++ b/core/engine/src/builtins/temporal/duration/mod.rs @@ -191,6 +191,7 @@ impl IntrinsicObject for Duration { .method(Self::total, js_string!("total"), 1) .method(Self::to_string, js_string!("toString"), 1) .method(Self::to_json, js_string!("toJSON"), 0) + .method(Self::value_of, js_string!("valueOf"), 0) .build(); } @@ -786,24 +787,30 @@ impl Duration { // TODO: Implement the rest of the new `Temporal.Duration.prototype.total` - Err(JsNativeError::range() + Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } /// 7.3.22 `Temporal.Duration.prototype.toString ( [ options ] )` pub(crate) fn to_string(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { - Err(JsNativeError::range() + Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } /// 7.3.23 `Temporal.Duration.prototype.toJSON ( )` pub(crate) fn to_json(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { - Err(JsNativeError::range() + Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } + + pub(crate) fn value_of(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { + Err(JsNativeError::error() + .with_message("valueOf not implemented for Temporal objects. See 'compare', 'equals', or `toString`") + .into()) + } } // -- Duration Abstract Operations -- diff --git a/core/engine/src/builtins/temporal/instant/mod.rs b/core/engine/src/builtins/temporal/instant/mod.rs index 6e8d3b22d54..826024a65fd 100644 --- a/core/engine/src/builtins/temporal/instant/mod.rs +++ b/core/engine/src/builtins/temporal/instant/mod.rs @@ -111,6 +111,7 @@ impl IntrinsicObject for Instant { .method(Self::round, js_string!("round"), 1) .method(Self::equals, js_string!("equals"), 1) .method(Self::to_zoned_date_time, js_string!("toZonedDateTime"), 1) + .method(Self::value_of, js_string!("valueOf"), 0) .method( Self::to_zoned_date_time_iso, js_string!("toZonedDateTimeISO"), @@ -532,6 +533,12 @@ impl Instant { .with_message("not yet implemented.") .into()) } + + pub(crate) fn value_of(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { + Err(JsNativeError::error() + .with_message("valueOf not implemented for Temporal objects. See 'compare', 'equals', or `toString`") + .into()) + } } // -- Instant Abstract Operations -- diff --git a/core/engine/src/builtins/temporal/plain_date/mod.rs b/core/engine/src/builtins/temporal/plain_date/mod.rs index c3f2b43789b..17c4882de8b 100644 --- a/core/engine/src/builtins/temporal/plain_date/mod.rs +++ b/core/engine/src/builtins/temporal/plain_date/mod.rs @@ -212,6 +212,7 @@ impl IntrinsicObject for PlainDate { .method(Self::since, js_string!("since"), 1) .method(Self::equals, js_string!("equals"), 1) .method(Self::to_plain_datetime, js_string!("toPlainDateTime"), 0) + .method(Self::value_of, js_string!("valueOf"), 0) .build(); } @@ -778,6 +779,12 @@ impl PlainDate { // 4. Return ? CreateTemporalDateTime(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], temporalDate.[[Calendar]]). create_temporal_datetime(date.inner.to_date_time(time)?, None, context).map(Into::into) } + + pub(crate) fn value_of(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { + Err(JsNativeError::error() + .with_message("valueOf not implemented for Temporal objects. See 'compare', 'equals', or `toString`") + .into()) + } } // -- `PlainDate` Abstract Operations -- diff --git a/core/engine/src/builtins/temporal/plain_date_time/mod.rs b/core/engine/src/builtins/temporal/plain_date_time/mod.rs index 18cb14c3e56..7685b971c4a 100644 --- a/core/engine/src/builtins/temporal/plain_date_time/mod.rs +++ b/core/engine/src/builtins/temporal/plain_date_time/mod.rs @@ -277,6 +277,7 @@ impl IntrinsicObject for PlainDateTime { .method(Self::since, js_string!("since"), 1) .method(Self::round, js_string!("round"), 1) .method(Self::equals, js_string!("equals"), 1) + .method(Self::value_of, js_string!("valueOf"), 0) .build(); } @@ -904,6 +905,12 @@ impl PlainDateTime { // 6. Return ? CalendarEquals(dateTime.[[Calendar]], other.[[Calendar]]). Ok((dt.inner == other).into()) } + + pub(crate) fn value_of(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { + Err(JsNativeError::error() + .with_message("valueOf not implemented for Temporal objects. See 'compare', 'equals', or `toString`") + .into()) + } } // ==== `PlainDateTime` Abstract Operations` ==== diff --git a/core/engine/src/builtins/temporal/plain_month_day/mod.rs b/core/engine/src/builtins/temporal/plain_month_day/mod.rs index c2dce5b9d9e..ba6308d39a0 100644 --- a/core/engine/src/builtins/temporal/plain_month_day/mod.rs +++ b/core/engine/src/builtins/temporal/plain_month_day/mod.rs @@ -115,6 +115,12 @@ impl PlainMonthDay { Ok(month_day_to_string(inner, show_calendar)) } + + pub(crate) fn value_of(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { + Err(JsNativeError::error() + .with_message("valueOf not implemented for Temporal objects. See 'compare', 'equals', or `toString`") + .into()) + } } impl BuiltInObject for PlainMonthDay { @@ -161,6 +167,7 @@ impl IntrinsicObject for PlainMonthDay { Attribute::CONFIGURABLE, ) .method(Self::to_string, js_string!("toString"), 1) + .method(Self::value_of, js_string!("valueOf"), 0) .static_method(Self::from, js_string!("from"), 2) .build(); } diff --git a/core/engine/src/builtins/temporal/plain_time/mod.rs b/core/engine/src/builtins/temporal/plain_time/mod.rs index ffa97d54531..b496e5af23c 100644 --- a/core/engine/src/builtins/temporal/plain_time/mod.rs +++ b/core/engine/src/builtins/temporal/plain_time/mod.rs @@ -580,10 +580,10 @@ impl PlainTime { } /// 4.3.22 Temporal.PlainTime.prototype.valueOf ( ) - fn value_of(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { + pub(crate) fn value_of(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Throw a TypeError exception. - Err(JsNativeError::typ() - .with_message("valueOf cannot be called on PlainTime.") + Err(JsNativeError::error() + .with_message("valueOf not implemented for Temporal objects. See 'compare', 'equals', or `toString`") .into()) } } diff --git a/core/engine/src/builtins/temporal/plain_year_month/mod.rs b/core/engine/src/builtins/temporal/plain_year_month/mod.rs index 673d570f384..38da96805ed 100644 --- a/core/engine/src/builtins/temporal/plain_year_month/mod.rs +++ b/core/engine/src/builtins/temporal/plain_year_month/mod.rs @@ -140,6 +140,7 @@ impl IntrinsicObject for PlainYearMonth { .method(Self::since, js_string!("since"), 2) .method(Self::equals, js_string!("equals"), 1) .method(Self::to_string, js_string!("toString"), 1) + .method(Self::value_of, js_string!("valueOf"), 0) .build(); } @@ -406,6 +407,12 @@ impl PlainYearMonth { Ok(year_month_to_string(inner, show_calendar)) } + + pub(crate) fn value_of(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { + Err(JsNativeError::error() + .with_message("valueOf not implemented for Temporal objects. See 'compare', 'equals', or `toString`") + .into()) + } } // ==== Abstract Operations ====