From 8f7028d112cea4c4f8e28e96aa49be3eaf5bd42a Mon Sep 17 00:00:00 2001 From: Kevin <46825870+nekevss@users.noreply.github.com> Date: Wed, 31 Jan 2024 14:04:23 -0500 Subject: [PATCH] Temporal: attribute/property and custom calendar fixes (#3639) * Fix accessor attribute and toStringTag property * Fix calendar methods and custom extends calendar calling * Complete attribute update * run cargo fmt --- .../src/builtins/temporal/calendar/mod.rs | 62 ++++++++++--------- .../src/builtins/temporal/calendar/object.rs | 36 ++++++----- .../src/builtins/temporal/duration/mod.rs | 56 +++++++++++++---- .../src/builtins/temporal/instant/mod.rs | 10 +-- .../src/builtins/temporal/plain_date/mod.rs | 40 +++++++----- .../builtins/temporal/plain_date_time/mod.rs | 2 +- .../builtins/temporal/plain_month_day/mod.rs | 2 +- .../src/builtins/temporal/plain_time/mod.rs | 12 ++-- .../builtins/temporal/plain_year_month/mod.rs | 28 ++++++--- .../src/builtins/temporal/time_zone/mod.rs | 2 +- .../builtins/temporal/zoned_date_time/mod.rs | 2 +- core/temporal/src/components/date.rs | 4 +- core/temporal/src/components/datetime.rs | 4 +- 13 files changed, 159 insertions(+), 101 deletions(-) diff --git a/core/engine/src/builtins/temporal/calendar/mod.rs b/core/engine/src/builtins/temporal/calendar/mod.rs index df034de8d8..56c6368d1a 100644 --- a/core/engine/src/builtins/temporal/calendar/mod.rs +++ b/core/engine/src/builtins/temporal/calendar/mod.rs @@ -73,12 +73,12 @@ impl IntrinsicObject for Calendar { .build(); BuiltInBuilder::from_standard_constructor::(realm) - .static_property( + .property( JsSymbol::to_string_tag(), Self::NAME, Attribute::CONFIGURABLE, ) - .accessor(utf16!("id"), Some(get_id), None, Attribute::default()) + .accessor(utf16!("id"), Some(get_id), None, Attribute::CONFIGURABLE) .static_method(Self::from, js_string!("from"), 1) .method(Self::date_from_fields, js_string!("dateFromFields"), 2) .method( @@ -174,8 +174,9 @@ impl Calendar { .as_object() .and_then(JsObject::downcast_ref::) .ok_or_else(|| { - JsNativeError::typ() - .with_message("the this value of Calendar must be a Calendar object.") + JsNativeError::typ().with_message( + "the this value of Calendar.prototype.id must be a Calendar object.", + ) })?; Ok(JsString::from(calendar.slot.identifier(context)?.as_str()).into()) @@ -193,8 +194,9 @@ impl Calendar { .as_object() .and_then(JsObject::downcast_ref::) .ok_or_else(|| { - JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + JsNativeError::typ().with_message( + "this value of Calendar dateFromFields must be a Calendar object.", + ) })?; // 3. If Type(fields) is not Object, throw a TypeError exception. @@ -273,8 +275,9 @@ impl Calendar { .as_object() .and_then(JsObject::downcast_ref::) .ok_or_else(|| { - JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + JsNativeError::typ().with_message( + "this value of Calendar yearMonthFromFields must be a Calendar object.", + ) })?; let fields = args.get_or_undefined(0); @@ -349,8 +352,9 @@ impl Calendar { .as_object() .and_then(JsObject::downcast_ref::) .ok_or_else(|| { - JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + JsNativeError::typ().with_message( + "this value of Calendar monthDayFromFields must be a Calendar object.", + ) })?; // 3. If Type(fields) is not Object, throw a TypeError exception. @@ -422,7 +426,7 @@ impl Calendar { .and_then(JsObject::downcast_ref::) .ok_or_else(|| { JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + .with_message("this value of Calendar dateAdd must be a Calendar object.") })?; // 4. Set date to ? ToTemporalDate(date). @@ -461,7 +465,7 @@ impl Calendar { .and_then(JsObject::downcast_ref::) .ok_or_else(|| { JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + .with_message("this value of Calendar dateUntil must be a Calendar object.") })?; // 4. Set one to ? ToTemporalDate(one). @@ -497,7 +501,7 @@ impl Calendar { .and_then(JsObject::downcast_ref::) .ok_or_else(|| { JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + .with_message("this value of Calendar era must be a Calendar object.") })?; let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?; @@ -517,7 +521,7 @@ impl Calendar { .and_then(JsObject::downcast_ref::) .ok_or_else(|| { JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + .with_message("this value of Calendar eraYear must be a Calendar object.") })?; let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?; @@ -537,7 +541,7 @@ impl Calendar { .and_then(JsObject::downcast_ref::) .ok_or_else(|| { JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + .with_message("this value of Calendar year must be a Calendar object.") })?; let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?; @@ -554,7 +558,7 @@ impl Calendar { .and_then(JsObject::downcast_ref::) .ok_or_else(|| { JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + .with_message("this value of Calendar month must be a Calendar object.") })?; let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?; @@ -576,7 +580,7 @@ impl Calendar { .and_then(JsObject::downcast_ref::) .ok_or_else(|| { JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + .with_message("this value of Calendar monthCode must be a Calendar object.") })?; let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?; @@ -593,7 +597,7 @@ impl Calendar { .and_then(JsObject::downcast_ref::) .ok_or_else(|| { JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + .with_message("this value of Calendar day must be a Calendar object.") })?; let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?; @@ -612,7 +616,7 @@ impl Calendar { .and_then(JsObject::downcast_ref::) .ok_or_else(|| { JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + .with_message("this value of Calendar dayOfWeek must be a Calendar object.") })?; // 3. Let temporalDate be ? ToTemporalDate(temporalDateLike). @@ -632,7 +636,7 @@ impl Calendar { .and_then(JsObject::downcast_ref::) .ok_or_else(|| { JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + .with_message("this value of Calendar dayOfYear must be a Calendar object.") })?; // 3. Let temporalDate be ? ToTemporalDate(temporalDateLike). @@ -652,7 +656,7 @@ impl Calendar { .and_then(JsObject::downcast_ref::) .ok_or_else(|| { JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + .with_message("this value of Calendar weekOfYear must be a Calendar object.") })?; // 3. Let temporalDate be ? ToTemporalDate(temporalDateLike). @@ -672,7 +676,7 @@ impl Calendar { .and_then(JsObject::downcast_ref::) .ok_or_else(|| { JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + .with_message("this value of Calendar yearOfWeek must be a Calendar object.") })?; // 3. Let temporalDate be ? ToTemporalDate(temporalDateLike). @@ -692,7 +696,7 @@ impl Calendar { .and_then(JsObject::downcast_ref::) .ok_or_else(|| { JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + .with_message("this value of Calendar daysInWeek must be a Calendar object.") })?; // 3. Let temporalDate be ? ToTemporalDate(temporalDateLike). @@ -712,7 +716,7 @@ impl Calendar { .and_then(JsObject::downcast_ref::) .ok_or_else(|| { JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + .with_message("this value of Calendar daysInMonth must be a Calendar object.") })?; let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?; @@ -729,7 +733,7 @@ impl Calendar { .and_then(JsObject::downcast_ref::) .ok_or_else(|| { JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + .with_message("this value of Calendar daysInYear must be a Calendar object.") })?; let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?; @@ -749,7 +753,7 @@ impl Calendar { .and_then(JsObject::downcast_ref::) .ok_or_else(|| { JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + .with_message("this value of Calendar monthsInYear must be a Calendar object.") })?; let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?; @@ -766,7 +770,7 @@ impl Calendar { .and_then(JsObject::downcast_ref::) .ok_or_else(|| { JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + .with_message("this value of Calendar inLeapYear must be a Calendar object.") })?; let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?; @@ -785,7 +789,7 @@ impl Calendar { .and_then(JsObject::downcast_ref::) .ok_or_else(|| { JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + .with_message("this value of Calendar Fields must be a Calendar object.") })?; // Custom Calendars override the `fields` method. @@ -902,7 +906,7 @@ impl Calendar { .and_then(JsObject::downcast_ref::) .ok_or_else(|| { JsNativeError::typ() - .with_message("this value of Calendar must be a Calendar object.") + .with_message("this value of Calendar mergeFields must be a Calendar object.") })?; let fields = args.get_or_undefined(0).to_object(context)?; diff --git a/core/engine/src/builtins/temporal/calendar/object.rs b/core/engine/src/builtins/temporal/calendar/object.rs index 3f1d385d7d..bbb93de6d7 100644 --- a/core/engine/src/builtins/temporal/calendar/object.rs +++ b/core/engine/src/builtins/temporal/calendar/object.rs @@ -267,7 +267,7 @@ impl CalendarProtocol for JsCustomCalendar { let val = method .as_callable() .expect("is method") - .call(&method, &[date_like], context) + .call(&self.calendar.clone().into(), &[date_like], context) .map_err(|err| TemporalError::general(err.to_string()))?; // Validate the return value. @@ -314,7 +314,7 @@ impl CalendarProtocol for JsCustomCalendar { let val = method .as_callable() .expect("is method") - .call(&method, &[date_like], context) + .call(&self.calendar.clone().into(), &[date_like], context) .map_err(|err| TemporalError::general(err.to_string()))?; // Validate the return value. @@ -361,7 +361,7 @@ impl CalendarProtocol for JsCustomCalendar { let val = method .as_callable() .expect("is method") - .call(&method, &[date_like], context) + .call(&self.calendar.clone().into(), &[date_like], context) .map_err(|err| TemporalError::general(err.to_string()))?; let JsValue::String(result) = val else { @@ -393,7 +393,7 @@ impl CalendarProtocol for JsCustomCalendar { let val = method .as_callable() .expect("is method") - .call(&method, &[date_like], context) + .call(&self.calendar.clone().into(), &[date_like], context) .map_err(|err| TemporalError::general(err.to_string()))?; // Validate the return value. @@ -440,7 +440,7 @@ impl CalendarProtocol for JsCustomCalendar { let val = method .as_callable() .expect("is method") - .call(&method, &[date_like], context) + .call(&self.calendar.clone().into(), &[date_like], context) .map_err(|err| TemporalError::general(err.to_string()))?; // Validate the return value. @@ -489,7 +489,7 @@ impl CalendarProtocol for JsCustomCalendar { let val = method .as_callable() .expect("is method") - .call(&method, &[date_like], context) + .call(&self.calendar.clone().into(), &[date_like], context) .map_err(|err| TemporalError::general(err.to_string()))?; // Validate the return value. @@ -538,7 +538,7 @@ impl CalendarProtocol for JsCustomCalendar { let val = method .as_callable() .expect("is method") - .call(&method, &[date_like], context) + .call(&self.calendar.clone().into(), &[date_like], context) .map_err(|err| TemporalError::general(err.to_string()))?; // Validate the return value. @@ -587,7 +587,7 @@ impl CalendarProtocol for JsCustomCalendar { let val = method .as_callable() .expect("is method") - .call(&method, &[date_like], context) + .call(&self.calendar.clone().into(), &[date_like], context) .map_err(|err| TemporalError::general(err.to_string()))?; // Validate the return value. @@ -629,7 +629,7 @@ impl CalendarProtocol for JsCustomCalendar { let val = method .as_callable() .expect("is method") - .call(&method, &[date_like], context) + .call(&self.calendar.clone().into(), &[date_like], context) .map_err(|err| TemporalError::general(err.to_string()))?; // Validate the return value. @@ -677,7 +677,7 @@ impl CalendarProtocol for JsCustomCalendar { let val = method .as_callable() .expect("is method") - .call(&method, &[date_like], context) + .call(&self.calendar.clone().into(), &[date_like], context) .map_err(|err| TemporalError::general(err.to_string()))?; // Validate the return value. @@ -728,7 +728,7 @@ impl CalendarProtocol for JsCustomCalendar { let val = method .as_callable() .expect("is method") - .call(&method, &[date_like], context) + .call(&self.calendar.clone().into(), &[date_like], context) .map_err(|err| TemporalError::general(err.to_string()))?; // Validate the return value. @@ -777,7 +777,7 @@ impl CalendarProtocol for JsCustomCalendar { let val = method .as_callable() .expect("is method") - .call(&method, &[date_like], context) + .call(&self.calendar.clone().into(), &[date_like], context) .map_err(|err| TemporalError::general(err.to_string()))?; // Validate the return value. @@ -828,7 +828,7 @@ impl CalendarProtocol for JsCustomCalendar { let val = method .as_callable() .expect("is method") - .call(&method, &[date_like], context) + .call(&self.calendar.clone().into(), &[date_like], context) .map_err(|err| TemporalError::general(err.to_string()))?; let JsValue::Boolean(result) = val else { @@ -858,7 +858,7 @@ impl CalendarProtocol for JsCustomCalendar { let result = method .as_callable() .expect("is method") - .call(&method, &[fields_js.into()], context) + .call(&self.calendar.clone().into(), &[fields_js.into()], context) .map_err(|e| TemporalError::general(e.to_string()))?; // validate result and map to a `Vec` @@ -909,7 +909,11 @@ impl CalendarProtocol for JsCustomCalendar { let value = method .as_callable() .expect("is method") - .call(&method, &[fields.into(), add_fields.into()], context) + .call( + &self.calendar.clone().into(), + &[fields.into(), add_fields.into()], + context, + ) .map_err(|e| TemporalError::general(e.to_string()))?; let JsValue::Object(o) = value else { @@ -930,7 +934,7 @@ impl CalendarProtocol for JsCustomCalendar { .calendar .__get__( &PropertyKey::from(utf16!("id")), - JsValue::undefined(), + self.calendar.clone().into(), &mut context.into(), ) .expect("method must exist on a object that implements the CalendarProtocol."); diff --git a/core/engine/src/builtins/temporal/duration/mod.rs b/core/engine/src/builtins/temporal/duration/mod.rs index 0b22282e0f..57c40760f3 100644 --- a/core/engine/src/builtins/temporal/duration/mod.rs +++ b/core/engine/src/builtins/temporal/duration/mod.rs @@ -101,53 +101,83 @@ impl IntrinsicObject for Duration { .build(); BuiltInBuilder::from_standard_constructor::(realm) - .static_property( + .property( JsSymbol::to_string_tag(), Self::NAME, Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ) - .accessor(utf16!("years"), Some(get_years), None, Attribute::default()) + .accessor( + utf16!("years"), + Some(get_years), + None, + Attribute::CONFIGURABLE, + ) .accessor( utf16!("months"), Some(get_months), None, - Attribute::default(), + Attribute::CONFIGURABLE, + ) + .accessor( + utf16!("weeks"), + Some(get_weeks), + None, + Attribute::CONFIGURABLE, + ) + .accessor( + utf16!("days"), + Some(get_days), + None, + Attribute::CONFIGURABLE, + ) + .accessor( + utf16!("hours"), + Some(get_hours), + None, + Attribute::CONFIGURABLE, ) - .accessor(utf16!("weeks"), Some(get_weeks), None, Attribute::default()) - .accessor(utf16!("days"), Some(get_days), None, Attribute::default()) - .accessor(utf16!("hours"), Some(get_hours), None, Attribute::default()) .accessor( utf16!("minutes"), Some(get_minutes), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("seconds"), Some(get_seconds), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("milliseconds"), Some(get_milliseconds), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("microseconds"), Some(get_microseconds), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("nanoseconds"), Some(get_nanoseconds), None, - Attribute::default(), + Attribute::CONFIGURABLE, + ) + .accessor( + utf16!("sign"), + Some(get_sign), + None, + Attribute::CONFIGURABLE, + ) + .accessor( + utf16!("blank"), + Some(is_blank), + None, + Attribute::CONFIGURABLE, ) - .accessor(utf16!("sign"), Some(get_sign), None, Attribute::default()) - .accessor(utf16!("blank"), Some(is_blank), None, Attribute::default()) .method(Self::with, js_string!("with"), 1) .method(Self::negated, js_string!("negated"), 0) .method(Self::abs, js_string!("abs"), 0) diff --git a/core/engine/src/builtins/temporal/instant/mod.rs b/core/engine/src/builtins/temporal/instant/mod.rs index 777c8f53a6..de62f8c621 100644 --- a/core/engine/src/builtins/temporal/instant/mod.rs +++ b/core/engine/src/builtins/temporal/instant/mod.rs @@ -58,7 +58,7 @@ impl IntrinsicObject for Instant { .build(); BuiltInBuilder::from_standard_constructor::(realm) - .static_property( + .property( JsSymbol::to_string_tag(), Self::NAME, Attribute::CONFIGURABLE, @@ -67,25 +67,25 @@ impl IntrinsicObject for Instant { utf16!("epochSeconds"), Some(get_seconds), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("epochMilliseconds"), Some(get_millis), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("epochMicroseconds"), Some(get_micros), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("epochNanoseconds"), Some(get_nanos), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .method(Self::add, js_string!("add"), 1) .method(Self::subtract, js_string!("subtract"), 1) diff --git a/core/engine/src/builtins/temporal/plain_date/mod.rs b/core/engine/src/builtins/temporal/plain_date/mod.rs index 9fa62b5c0f..beeba836f6 100644 --- a/core/engine/src/builtins/temporal/plain_date/mod.rs +++ b/core/engine/src/builtins/temporal/plain_date/mod.rs @@ -103,7 +103,7 @@ impl IntrinsicObject for PlainDate { .build(); BuiltInBuilder::from_standard_constructor::(realm) - .static_property( + .property( JsSymbol::to_string_tag(), Self::NAME, Attribute::CONFIGURABLE, @@ -112,70 +112,80 @@ impl IntrinsicObject for PlainDate { utf16!("calendarId"), Some(get_calendar_id), None, - Attribute::default(), + Attribute::CONFIGURABLE, + ) + .accessor( + utf16!("year"), + Some(get_year), + None, + Attribute::CONFIGURABLE, + ) + .accessor( + utf16!("month"), + Some(get_month), + None, + Attribute::CONFIGURABLE, ) - .accessor(utf16!("year"), Some(get_year), None, Attribute::default()) - .accessor(utf16!("month"), Some(get_month), None, Attribute::default()) .accessor( utf16!("monthCode"), Some(get_month_code), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) - .accessor(utf16!("day"), Some(get_day), None, Attribute::default()) + .accessor(utf16!("day"), Some(get_day), None, Attribute::CONFIGURABLE) .accessor( utf16!("dayOfWeek"), Some(get_day_of_week), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("dayOfYear"), Some(get_day_of_year), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("weekOfYear"), Some(get_week_of_year), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("yearOfWeek"), Some(get_year_of_week), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("daysInWeek"), Some(get_days_in_week), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("daysInMonth"), Some(get_days_in_month), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("daysInYear"), Some(get_days_in_year), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("monthsInYear"), Some(get_months_in_year), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("inLeapYear"), Some(get_in_leap_year), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .method(Self::to_plain_year_month, js_string!("toPlainYearMonth"), 0) .method(Self::to_plain_month_day, js_string!("toPlainMonthDay"), 0) 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 78e9319e2a..31e994795c 100644 --- a/core/engine/src/builtins/temporal/plain_date_time/mod.rs +++ b/core/engine/src/builtins/temporal/plain_date_time/mod.rs @@ -127,7 +127,7 @@ impl IntrinsicObject for PlainDateTime { .build(); BuiltInBuilder::from_standard_constructor::(realm) - .static_property( + .property( JsSymbol::to_string_tag(), Self::NAME, Attribute::CONFIGURABLE, 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 719061dd51..a4a664ccad 100644 --- a/core/engine/src/builtins/temporal/plain_month_day/mod.rs +++ b/core/engine/src/builtins/temporal/plain_month_day/mod.rs @@ -38,7 +38,7 @@ impl IntrinsicObject for PlainMonthDay { let _timer = Profiler::global().start_event(std::any::type_name::(), "init"); BuiltInBuilder::from_standard_constructor::(realm) - .static_property( + .property( JsSymbol::to_string_tag(), Self::NAME, Attribute::CONFIGURABLE, diff --git a/core/engine/src/builtins/temporal/plain_time/mod.rs b/core/engine/src/builtins/temporal/plain_time/mod.rs index 781db45587..b0cf38caf9 100644 --- a/core/engine/src/builtins/temporal/plain_time/mod.rs +++ b/core/engine/src/builtins/temporal/plain_time/mod.rs @@ -66,7 +66,7 @@ impl IntrinsicObject for PlainTime { .build(); BuiltInBuilder::from_standard_constructor::(realm) - .static_property( + .property( JsSymbol::to_string_tag(), Self::NAME, Attribute::CONFIGURABLE, @@ -76,31 +76,31 @@ impl IntrinsicObject for PlainTime { utf16!("minute"), Some(get_minute), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("second"), Some(get_second), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("millisecond"), Some(get_millisecond), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("microsecond"), Some(get_microsecond), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("nanosecond"), Some(get_nanosecond), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .method(Self::add, js_string!("add"), 1) .method(Self::subtract, js_string!("subtract"), 1) 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 b3808f546f..97b580d2f8 100644 --- a/core/engine/src/builtins/temporal/plain_year_month/mod.rs +++ b/core/engine/src/builtins/temporal/plain_year_month/mod.rs @@ -70,7 +70,7 @@ impl IntrinsicObject for PlainYearMonth { .build(); BuiltInBuilder::from_standard_constructor::(realm) - .static_property( + .property( JsSymbol::to_string_tag(), Self::NAME, Attribute::CONFIGURABLE, @@ -79,39 +79,49 @@ impl IntrinsicObject for PlainYearMonth { utf16!("calendarId"), Some(get_calendar_id), None, - Attribute::default(), + Attribute::CONFIGURABLE, + ) + .accessor( + utf16!("year"), + Some(get_year), + None, + Attribute::CONFIGURABLE, + ) + .accessor( + utf16!("month"), + Some(get_month), + None, + Attribute::CONFIGURABLE, ) - .accessor(utf16!("year"), Some(get_year), None, Attribute::default()) - .accessor(utf16!("month"), Some(get_month), None, Attribute::default()) .accessor( utf16!("monthCode"), Some(get_month_code), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("daysInMonth"), Some(get_days_in_month), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("daysInYear"), Some(get_days_in_year), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("monthsInYear"), Some(get_months_in_year), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .accessor( utf16!("inLeapYear"), Some(get_in_leap_year), None, - Attribute::default(), + Attribute::CONFIGURABLE, ) .method(Self::with, js_string!("with"), 2) .method(Self::add, js_string!("add"), 2) diff --git a/core/engine/src/builtins/temporal/time_zone/mod.rs b/core/engine/src/builtins/temporal/time_zone/mod.rs index 109f59b87f..d906b54e8a 100644 --- a/core/engine/src/builtins/temporal/time_zone/mod.rs +++ b/core/engine/src/builtins/temporal/time_zone/mod.rs @@ -85,7 +85,7 @@ impl IntrinsicObject for TimeZone { ) .method(Self::to_string, js_string!("toString"), 0) .method(Self::to_string, js_string!("toJSON"), 0) - .static_property( + .property( JsSymbol::to_string_tag(), Self::NAME, Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, diff --git a/core/engine/src/builtins/temporal/zoned_date_time/mod.rs b/core/engine/src/builtins/temporal/zoned_date_time/mod.rs index 355d806ed6..b1e089c8e2 100644 --- a/core/engine/src/builtins/temporal/zoned_date_time/mod.rs +++ b/core/engine/src/builtins/temporal/zoned_date_time/mod.rs @@ -44,7 +44,7 @@ impl IntrinsicObject for ZonedDateTime { let _timer = Profiler::global().start_event(std::any::type_name::(), "init"); BuiltInBuilder::from_standard_constructor::(realm) - .static_property( + .property( JsSymbol::to_string_tag(), Self::NAME, Attribute::CONFIGURABLE, diff --git a/core/temporal/src/components/date.rs b/core/temporal/src/components/date.rs index 85a4279393..6f8d5f647a 100644 --- a/core/temporal/src/components/date.rs +++ b/core/temporal/src/components/date.rs @@ -195,7 +195,7 @@ impl Date { /// Returns the calendar day of year value with provided context. pub fn contextual_day_of_year(&self, context: &mut dyn Any) -> TemporalResult { - self.calendar.day_of_week( + self.calendar.day_of_year( &super::calendar::CalendarDateLike::Date(self.clone()), context, ) @@ -203,7 +203,7 @@ impl Date { /// Returns the calendar day of year value. pub fn day_of_year(&self) -> TemporalResult { - self.contextual_day_of_week(&mut ()) + self.contextual_day_of_year(&mut ()) } /// Returns the calendar week of year value with provided context. diff --git a/core/temporal/src/components/datetime.rs b/core/temporal/src/components/datetime.rs index 0b16669062..12cdcdd62e 100644 --- a/core/temporal/src/components/datetime.rs +++ b/core/temporal/src/components/datetime.rs @@ -238,7 +238,7 @@ impl DateTime { /// Returns the calendar day of year value with provided context. pub fn contextual_day_of_year(&self, context: &mut dyn Any) -> TemporalResult { - self.calendar.day_of_week( + self.calendar.day_of_year( &super::calendar::CalendarDateLike::DateTime(self.clone()), context, ) @@ -246,7 +246,7 @@ impl DateTime { /// Returns the calendar day of year value. pub fn day_of_year(&self) -> TemporalResult { - self.contextual_day_of_week(&mut ()) + self.contextual_day_of_year(&mut ()) } /// Returns the calendar week of year value with provided context.