summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-07-05 19:37:15 +0300
committerLinus Groh <mail@linusgroh.de>2021-07-05 18:19:39 +0100
commit8195c31965ce687f92e82341de05d5913b97bafb (patch)
treeaba397d95be65b9b989f48695dfb720f03271213
parent8a295299f353f9490cbef1b23a2a3a9c8b4d776f (diff)
downloadserenity-8195c31965ce687f92e82341de05d5913b97bafb.zip
LibJS: Remove the non-standard get_own_property_descriptor helper
-rw-r--r--Userland/Libraries/LibJS/Runtime/Object.h1
-rw-r--r--Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp9
2 files changed, 8 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h
index 29bfdc7800..86374cfb48 100644
--- a/Userland/Libraries/LibJS/Runtime/Object.h
+++ b/Userland/Libraries/LibJS/Runtime/Object.h
@@ -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() });
diff --git a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp
index 21b1a2747f..c6a2f51c9a 100644
--- a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp
@@ -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);
}