1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:17:44 +00:00

LibJS: Let Object::delete_property() return a bool, not Value

Just like the various define_property functions, this should return a
bool directly and let the caller deal with wrapping it in a Value, if
necessary.
This commit is contained in:
Linus Groh 2021-04-10 17:44:12 +02:00 committed by Andreas Kling
parent 4788c94d34
commit ec62783af9
6 changed files with 20 additions and 20 deletions

View file

@ -390,33 +390,33 @@ bool ProxyObject::put(const PropertyName& name, Value value, Value receiver)
return true;
}
Value ProxyObject::delete_property(const PropertyName& name)
bool ProxyObject::delete_property(const PropertyName& name)
{
auto& vm = this->vm();
if (m_is_revoked) {
vm.throw_exception<TypeError>(global_object(), ErrorType::ProxyRevoked);
return {};
return false;
}
auto trap = get_method(global_object(), Value(&m_handler), vm.names.deleteProperty);
if (vm.exception())
return {};
return false;
if (!trap)
return m_target.delete_property(name);
auto trap_result = vm.call(*trap, Value(&m_handler), Value(&m_target), name.to_value(vm));
if (vm.exception())
return {};
return false;
if (!trap_result.to_boolean())
return Value(false);
return false;
auto target_desc = m_target.get_own_property_descriptor(name);
if (vm.exception())
return {};
return false;
if (!target_desc.has_value())
return Value(true);
return true;
if (!target_desc.value().attributes.is_configurable()) {
vm.throw_exception<TypeError>(global_object(), ErrorType::ProxyDeleteNonConfigurable);
return {};
return false;
}
return Value(true);
return true;
}
void ProxyObject::visit_edges(Cell::Visitor& visitor)