mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
LibJS: Convert set_immutable_prototype() to ThrowCompletionOr
This commit is contained in:
parent
a7b1c7eb16
commit
0a49a2db60
4 changed files with 5 additions and 4 deletions
|
@ -841,12 +841,12 @@ ThrowCompletionOr<MarkedValueList> Object::internal_own_property_keys() const
|
|||
}
|
||||
|
||||
// 10.4.7.2 SetImmutablePrototype ( O, V ), https://tc39.es/ecma262/#sec-set-immutable-prototype
|
||||
bool Object::set_immutable_prototype(Object* prototype)
|
||||
ThrowCompletionOr<bool> Object::set_immutable_prototype(Object* prototype)
|
||||
{
|
||||
// 1. Assert: Either Type(V) is Object or Type(V) is Null.
|
||||
|
||||
// 2. Let current be ? O.[[GetPrototypeOf]]().
|
||||
auto* current = TRY_OR_DISCARD(internal_get_prototype_of());
|
||||
auto* current = TRY(internal_get_prototype_of());
|
||||
|
||||
// 3. If SameValue(V, current) is true, return true.
|
||||
if (prototype == current)
|
||||
|
|
|
@ -108,7 +108,7 @@ public:
|
|||
|
||||
// 10.4.7 Immutable Prototype Exotic Objects, https://tc39.es/ecma262/#sec-immutable-prototype-exotic-objects
|
||||
|
||||
bool set_immutable_prototype(Object* prototype);
|
||||
ThrowCompletionOr<bool> set_immutable_prototype(Object* prototype);
|
||||
|
||||
// 20.1 Object Objects, https://tc39.es/ecma262/#sec-object-objects
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ ObjectPrototype::~ObjectPrototype()
|
|||
// 10.4.7.1 [[SetPrototypeOf]] ( V ), https://tc39.es/ecma262/#sec-immutable-prototype-exotic-objects-setprototypeof-v
|
||||
ThrowCompletionOr<bool> ObjectPrototype::internal_set_prototype_of(Object* prototype)
|
||||
{
|
||||
// 1. Return ? SetImmutablePrototype(O, V).
|
||||
return set_immutable_prototype(prototype);
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::replace)
|
|||
JS::ThrowCompletionOr<bool> LocationObject::internal_set_prototype_of(Object* prototype)
|
||||
{
|
||||
// 1. Return ! SetImmutablePrototype(this, V).
|
||||
return set_immutable_prototype(prototype);
|
||||
return MUST(set_immutable_prototype(prototype));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/history.html#location-isextensible
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue