mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:07:35 +00:00
LibJS: Convert Intl.NumberFormat functions to ThrowCompletionOr
This commit is contained in:
parent
351f0b70bd
commit
66770de264
4 changed files with 9 additions and 9 deletions
|
@ -29,7 +29,7 @@ void NumberFormatConstructor::initialize(GlobalObject& global_object)
|
|||
define_direct_property(vm.names.prototype, global_object.intl_number_format_prototype(), 0);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_old_native_function(vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
define_native_function(vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
|
||||
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ ThrowCompletionOr<Object*> NumberFormatConstructor::construct(FunctionObject& ne
|
|||
}
|
||||
|
||||
// 15.3.2 Intl.NumberFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.numberformat.supportedlocalesof
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(NumberFormatConstructor::supported_locales_of)
|
||||
JS_DEFINE_NATIVE_FUNCTION(NumberFormatConstructor::supported_locales_of)
|
||||
{
|
||||
auto locales = vm.argument(0);
|
||||
auto options = vm.argument(1);
|
||||
|
@ -73,10 +73,10 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(NumberFormatConstructor::supported_locales_of)
|
|||
// 1. Let availableLocales be %NumberFormat%.[[AvailableLocales]].
|
||||
|
||||
// 2. Let requestedLocales be ? CanonicalizeLocaleList(locales).
|
||||
auto requested_locales = TRY_OR_DISCARD(canonicalize_locale_list(global_object, locales));
|
||||
auto requested_locales = TRY(canonicalize_locale_list(global_object, locales));
|
||||
|
||||
// 3. Return ? SupportedLocales(availableLocales, requestedLocales, options).
|
||||
return TRY_OR_DISCARD(supported_locales(global_object, requested_locales, options));
|
||||
return TRY(supported_locales(global_object, requested_locales, options));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
private:
|
||||
virtual bool has_constructor() const override { return true; }
|
||||
|
||||
JS_DECLARE_OLD_NATIVE_FUNCTION(supported_locales_of);
|
||||
JS_DECLARE_NATIVE_FUNCTION(supported_locales_of);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -27,17 +27,17 @@ void NumberFormatPrototype::initialize(GlobalObject& global_object)
|
|||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.NumberFormat"), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_old_native_function(vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
define_native_function(vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
}
|
||||
|
||||
// 15.4.5 Intl.NumberFormat.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.numberformat.prototype.resolvedoptions
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(NumberFormatPrototype::resolved_options)
|
||||
JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::resolved_options)
|
||||
{
|
||||
// 1. Let nf be the this value.
|
||||
// 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 = TRY_OR_DISCARD(typed_this_object(global_object));
|
||||
auto* number_format = TRY(typed_this_object(global_object));
|
||||
|
||||
// 4. Let options be ! OrdinaryObjectCreate(%Object.prototype%).
|
||||
auto* options = Object::create(global_object, global_object.object_prototype());
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
virtual ~NumberFormatPrototype() override = default;
|
||||
|
||||
private:
|
||||
JS_DECLARE_OLD_NATIVE_FUNCTION(resolved_options);
|
||||
JS_DECLARE_NATIVE_FUNCTION(resolved_options);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue