LibJS: Remove the non-standard get_own_property_descriptor helper
This commit is contained in:
parent
8a295299f3
commit
8195c31965
Notes:
sideshowbarker
2024-07-18 10:22:25 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/8195c31965c Pull-request: https://github.com/SerenityOS/serenity/pull/8464 Reviewed-by: https://github.com/linusg ✅
2 changed files with 8 additions and 2 deletions
|
@ -125,7 +125,6 @@ public:
|
|||
// - Helpers using old, non-standard names but wrapping the standard methods.
|
||||
// FIXME: Update all the code relying on these and remove them.
|
||||
bool put(PropertyName const& property_name, Value value, Value receiver = {}) { return internal_set(property_name, value, receiver.value_or(this)); }
|
||||
Optional<PropertyDescriptor> get_own_property_descriptor(PropertyName const& property_name) const { return internal_get_own_property(property_name); }
|
||||
bool define_property(PropertyName const& property_name, Value value, PropertyAttributes attributes = default_attributes, bool = true)
|
||||
{
|
||||
return internal_define_own_property(property_name, { .value = value, .writable = attributes.is_writable(), .enumerable = attributes.is_enumerable(), .configurable = attributes.is_configurable() });
|
||||
|
|
|
@ -127,15 +127,22 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::value_of)
|
|||
// 20.1.3.4 Object.prototype.propertyIsEnumerable ( V ), https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
|
||||
JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::property_is_enumerable)
|
||||
{
|
||||
// 1. Let P be ? ToPropertyKey(V).
|
||||
auto property_key = vm.argument(0).to_property_key(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
// 2. Let O be ? ToObject(this value).
|
||||
auto* this_object = vm.this_value(global_object).to_object(global_object);
|
||||
if (!this_object)
|
||||
return {};
|
||||
auto property_descriptor = this_object->get_own_property_descriptor(property_key);
|
||||
// 3. Let desc be ? O.[[GetOwnProperty]](P).
|
||||
auto property_descriptor = this_object->internal_get_own_property(property_key);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
// 4. If desc is undefined, return false.
|
||||
if (!property_descriptor.has_value())
|
||||
return Value(false);
|
||||
// 5. Return desc.[[Enumerable]].
|
||||
return Value(*property_descriptor->enumerable);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue