mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibJS: Add parameter to delete_property since we need DeleteOrThrow
This commit is contained in:
parent
8a06a93ce2
commit
16b87b85e3
Notes:
sideshowbarker
2024-07-18 11:39:38 +09:00
Author: https://github.com/davidot Commit: https://github.com/SerenityOS/serenity/commit/16b87b85e39 Pull-request: https://github.com/SerenityOS/serenity/pull/8191
|
@ -768,18 +768,25 @@ bool Object::put_own_property_by_index(u32 property_index, Value value, Property
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Object::delete_property(const PropertyName& property_name)
|
||||
bool Object::delete_property(PropertyName const& property_name, bool force_throw_exception)
|
||||
{
|
||||
VERIFY(property_name.is_valid());
|
||||
|
||||
if (property_name.is_number())
|
||||
return m_indexed_properties.remove(property_name.as_number());
|
||||
if (property_name.is_number()) {
|
||||
if (!m_indexed_properties.remove(property_name.as_number())) {
|
||||
if (force_throw_exception || vm().in_strict_mode())
|
||||
vm().throw_exception<TypeError>(global_object(), ErrorType::DescChangeNonConfigurable, property_name.as_number());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
auto metadata = shape().lookup(property_name.to_string_or_symbol());
|
||||
if (!metadata.has_value())
|
||||
return true;
|
||||
if (!metadata.value().attributes.is_configurable()) {
|
||||
if (vm().in_strict_mode())
|
||||
if (force_throw_exception || vm().in_strict_mode())
|
||||
vm().throw_exception<TypeError>(global_object(), ErrorType::DescChangeNonConfigurable, property_name.to_string_or_symbol().to_display_string());
|
||||
return false;
|
||||
}
|
||||
|
@ -879,7 +886,7 @@ bool Object::put_by_index(u32 property_index, Value value)
|
|||
if (vm().exception())
|
||||
return {};
|
||||
}
|
||||
return put_own_property_by_index(property_index, value, default_attributes, PutOwnPropertyMode::Put);
|
||||
return put_own_property_by_index(property_index, value, default_attributes, PutOwnPropertyMode::Put, vm().in_strict_mode());
|
||||
}
|
||||
|
||||
bool Object::put(const PropertyName& property_name, Value value, Value receiver)
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
|
||||
void define_properties(Value properties);
|
||||
|
||||
virtual bool delete_property(const PropertyName&);
|
||||
virtual bool delete_property(PropertyName const&, bool force_throw_exception = false);
|
||||
|
||||
virtual bool is_array() const { return false; }
|
||||
virtual bool is_function() const { return false; }
|
||||
|
|
|
@ -375,7 +375,7 @@ bool ProxyObject::put(const PropertyName& name, Value value, Value receiver)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ProxyObject::delete_property(const PropertyName& name)
|
||||
bool ProxyObject::delete_property(PropertyName const& name, bool force_throw_exception)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
if (m_is_revoked) {
|
||||
|
@ -386,7 +386,7 @@ bool ProxyObject::delete_property(const PropertyName& name)
|
|||
if (vm.exception())
|
||||
return false;
|
||||
if (!trap)
|
||||
return m_target.delete_property(name);
|
||||
return m_target.delete_property(name, force_throw_exception);
|
||||
auto trap_result = vm.call(*trap, Value(&m_handler), Value(&m_target), name.to_value(vm));
|
||||
if (vm.exception())
|
||||
return false;
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
virtual bool has_property(const PropertyName& name) const override;
|
||||
virtual Value get(const PropertyName& name, Value receiver, AllowSideEffects = AllowSideEffects::Yes) const override;
|
||||
virtual bool put(const PropertyName& name, Value value, Value receiver) override;
|
||||
virtual bool delete_property(const PropertyName& name) override;
|
||||
virtual bool delete_property(PropertyName const& name, bool force_throw_exception = false) override;
|
||||
|
||||
bool is_revoked() const { return m_is_revoked; }
|
||||
void revoke() { m_is_revoked = true; }
|
||||
|
|
Loading…
Reference in a new issue