diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp index 1348eacf13..643e54e073 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp @@ -21,9 +21,9 @@ void WeakSetPrototype::initialize(GlobalObject& global_object) Object::initialize(global_object); u8 attr = Attribute::Writable | Attribute::Configurable; - define_old_native_function(vm.names.add, add, 1, attr); - define_old_native_function(vm.names.delete_, delete_, 1, attr); - define_old_native_function(vm.names.has, has, 1, attr); + define_native_function(vm.names.add, add, 1, attr); + define_native_function(vm.names.delete_, delete_, 1, attr); + define_native_function(vm.names.has, has, 1, attr); // 24.4.3.5 WeakSet.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-weakset.prototype-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.WeakSet.as_string()), Attribute::Configurable); @@ -34,22 +34,20 @@ WeakSetPrototype::~WeakSetPrototype() } // 24.4.3.1 WeakSet.prototype.add ( value ), https://tc39.es/ecma262/#sec-weakset.prototype.add -JS_DEFINE_OLD_NATIVE_FUNCTION(WeakSetPrototype::add) +JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::add) { - auto* weak_set = TRY_OR_DISCARD(typed_this_object(global_object)); + auto* weak_set = TRY(typed_this_object(global_object)); auto value = vm.argument(0); - if (!value.is_object()) { - vm.throw_exception(global_object, ErrorType::NotAnObject, value.to_string_without_side_effects()); - return {}; - } + if (!value.is_object()) + return vm.throw_completion(global_object, ErrorType::NotAnObject, value.to_string_without_side_effects()); weak_set->values().set(&value.as_object(), AK::HashSetExistingEntryBehavior::Keep); return weak_set; } // 24.4.3.3 WeakSet.prototype.delete ( value ), https://tc39.es/ecma262/#sec-weakset.prototype.delete -JS_DEFINE_OLD_NATIVE_FUNCTION(WeakSetPrototype::delete_) +JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::delete_) { - auto* weak_set = TRY_OR_DISCARD(typed_this_object(global_object)); + auto* weak_set = TRY(typed_this_object(global_object)); auto value = vm.argument(0); if (!value.is_object()) return Value(false); @@ -57,9 +55,9 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(WeakSetPrototype::delete_) } // 24.4.3.4 WeakSet.prototype.has ( value ), https://tc39.es/ecma262/#sec-weakset.prototype.has -JS_DEFINE_OLD_NATIVE_FUNCTION(WeakSetPrototype::has) +JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::has) { - auto* weak_set = TRY_OR_DISCARD(typed_this_object(global_object)); + auto* weak_set = TRY(typed_this_object(global_object)); auto value = vm.argument(0); if (!value.is_object()) return Value(false); diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h index 9dbb6e9de1..50351c2684 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h @@ -20,9 +20,9 @@ public: virtual ~WeakSetPrototype() override; private: - JS_DECLARE_OLD_NATIVE_FUNCTION(add); - JS_DECLARE_OLD_NATIVE_FUNCTION(delete_); - JS_DECLARE_OLD_NATIVE_FUNCTION(has); + JS_DECLARE_NATIVE_FUNCTION(add); + JS_DECLARE_NATIVE_FUNCTION(delete_); + JS_DECLARE_NATIVE_FUNCTION(has); }; }