1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:57:44 +00:00

LibJS: Add and use the CreateNonEnumerableDataPropertyOrThrow AO

This commit is contained in:
Idan Horowitz 2021-07-06 00:13:19 +03:00 committed by Linus Groh
parent 6da7f43580
commit 6787e86a3a
5 changed files with 67 additions and 59 deletions

View file

@ -190,6 +190,19 @@ bool Object::create_data_property_or_throw(PropertyName const& property_name, Va
return success;
}
// 7.3.6 CreateNonEnumerableDataPropertyOrThrow ( O, P, V ), https://tc39.es/proposal-error-cause/#sec-createnonenumerabledatapropertyorthrow
bool Object::create_non_enumerable_data_property_or_throw(PropertyName const& property_name, Value value)
{
VERIFY(!value.is_empty());
VERIFY(property_name.is_valid());
// 1. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }.
auto new_description = PropertyDescriptor { .value = value, .writable = true, .enumerable = false, .configurable = true };
// 2. Return ? DefinePropertyOrThrow(O, P, newDesc).
return define_property_or_throw(property_name, new_description);
}
// 7.3.8 DefinePropertyOrThrow ( O, P, desc ), https://tc39.es/ecma262/#sec-definepropertyorthrow
bool Object::define_property_or_throw(PropertyName const& property_name, PropertyDescriptor const& property_descriptor)
{