LibJS: Convert Intl.NumberFormat.prototype to be a PrototypeObject
This commit is contained in:
parent
b0c1179ff8
commit
8253e14818
Notes:
sideshowbarker
2024-07-18 04:01:51 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/8253e148182 Pull-request: https://github.com/SerenityOS/serenity/pull/10015 Reviewed-by: https://github.com/trflynn89 ✅
2 changed files with 6 additions and 21 deletions
|
@ -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 {};
|
||||
|
||||
|
|
|
@ -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&);
|
||||
|
|
Loading…
Add table
Reference in a new issue