diff options
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime')
3 files changed, 23 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h b/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h index 82e304e8e1..30458e462b 100644 --- a/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h +++ b/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h @@ -71,6 +71,7 @@ namespace JS { P(atanh) \ P(big) \ P(bind) \ + P(blank) \ P(blink) \ P(bold) \ P(buffer) \ diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp index 0b894fbad9..6f673b1b78 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp @@ -36,6 +36,7 @@ void DurationPrototype::initialize(GlobalObject& global_object) define_native_accessor(vm.names.microseconds, microseconds_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.nanoseconds, nanoseconds_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.sign, sign_getter, {}, Attribute::Configurable); + define_native_accessor(vm.names.blank, blank_getter, {}, Attribute::Configurable); } static Duration* typed_this(GlobalObject& global_object) @@ -194,4 +195,24 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::sign_getter) return Value(duration_sign(duration->years(), duration->months(), duration->weeks(), duration->days(), duration->hours(), duration->minutes(), duration->seconds(), duration->milliseconds(), duration->microseconds(), duration->nanoseconds())); } +// 7.3.14 get Temporal.Duration.prototype.blank, https://tc39.es/proposal-temporal/#sec-get-temporal.duration.prototype.blank +JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::blank_getter) +{ + // 1. Let duration be the this value. + // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). + auto* duration = typed_this(global_object); + if (vm.exception()) + return {}; + + // 3. Let sign be ! DurationSign(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]). + auto sign = duration_sign(duration->years(), duration->months(), duration->weeks(), duration->days(), duration->hours(), duration->minutes(), duration->seconds(), duration->milliseconds(), duration->microseconds(), duration->nanoseconds()); + + // 4. If sign = 0, return true. + if (sign == 0) + return Value(true); + + // 5. Return false. + return Value(false); +} + } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.h index 719fe8aac9..e5d531f3f0 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.h @@ -30,6 +30,7 @@ private: JS_DECLARE_NATIVE_FUNCTION(microseconds_getter); JS_DECLARE_NATIVE_FUNCTION(nanoseconds_getter); JS_DECLARE_NATIVE_FUNCTION(sign_getter); + JS_DECLARE_NATIVE_FUNCTION(blank_getter); }; } |