diff options
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp | 20 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h | 7 |
2 files changed, 6 insertions, 21 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp index cb3477d1b3..40f7d7e4f9 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp @@ -11,25 +11,9 @@ namespace JS::Intl { -static NumberFormat* typed_this(GlobalObject& global_object) -{ - auto& vm = global_object.vm(); - - auto* this_object = vm.this_value(global_object).to_object(global_object); - if (!this_object) - return nullptr; - - if (!is<NumberFormat>(this_object)) { - vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Intl.NumberFormat"); - return nullptr; - } - - return static_cast<NumberFormat*>(this_object); -} - // 15.4 Properties of the Intl.NumberFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-numberformat-prototype-object NumberFormatPrototype::NumberFormatPrototype(GlobalObject& global_object) - : Object(*global_object.object_prototype()) + : PrototypeObject(*global_object.object_prototype()) { } @@ -53,7 +37,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::resolved_options) // 2. If the implementation supports the normative optional constructor mode of 4.3 Note 1, then // a. Set nf to ? UnwrapNumberFormat(nf). // 3. Perform ? RequireInternalSlot(nf, [[InitializedNumberFormat]]). - auto* number_format = typed_this(global_object); + auto* number_format = typed_this_object(global_object); if (vm.exception()) return {}; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h index f392ab7824..16a7408c58 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h @@ -6,12 +6,13 @@ #pragma once -#include <LibJS/Runtime/Object.h> +#include <LibJS/Runtime/Intl/NumberFormat.h> +#include <LibJS/Runtime/PrototypeObject.h> namespace JS::Intl { -class NumberFormatPrototype final : public Object { - JS_OBJECT(NumberFormatPrototype, Object); +class NumberFormatPrototype final : public PrototypeObject<NumberFormatPrototype, NumberFormat> { + JS_PROTOTYPE_OBJECT(NumberFormatPrototype, NumberFormat, Intl.NumberFormat); public: explicit NumberFormatPrototype(GlobalObject&); |