summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-06-07 23:02:52 +0100
committerLinus Groh <mail@linusgroh.de>2021-06-07 23:02:52 +0100
commit8c964ef9f88b95aff4db1cb4725df8b7837b9ffd (patch)
tree816d0fa3dca4e33159c4c868344291e83f0bba36
parent4e555fae22f2e92bfa57388f74b3bdf02f6067ec (diff)
downloadserenity-8c964ef9f88b95aff4db1cb4725df8b7837b9ffd.zip
LibJS: Fix get_own_property_descriptor_object() field name order
This is defined by the spec: enumerable and configurable come last.
-rw-r--r--Userland/Libraries/LibJS/Runtime/Object.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp
index 9af14a02ea..e6a4816da6 100644
--- a/Userland/Libraries/LibJS/Runtime/Object.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Object.cpp
@@ -414,6 +414,8 @@ Optional<PropertyDescriptor> Object::get_own_property_descriptor(const PropertyN
return descriptor;
}
+// Equivalent to:
+// 6.2.5.4 FromPropertyDescriptor, https://tc39.es/ecma262/#sec-frompropertydescriptor
Value Object::get_own_property_descriptor_object(const PropertyName& property_name) const
{
VERIFY(property_name.is_valid());
@@ -425,12 +427,6 @@ Value Object::get_own_property_descriptor_object(const PropertyName& property_na
auto descriptor = descriptor_opt.value();
auto* descriptor_object = Object::create_empty(global_object());
- descriptor_object->define_property(vm.names.enumerable, Value(descriptor.attributes.is_enumerable()));
- if (vm.exception())
- return {};
- descriptor_object->define_property(vm.names.configurable, Value(descriptor.attributes.is_configurable()));
- if (vm.exception())
- return {};
if (descriptor.is_data_descriptor()) {
descriptor_object->define_property(vm.names.value, descriptor.value.value_or(js_undefined()));
if (vm.exception())
@@ -450,6 +446,12 @@ Value Object::get_own_property_descriptor_object(const PropertyName& property_na
return {};
}
}
+ descriptor_object->define_property(vm.names.enumerable, Value(descriptor.attributes.is_enumerable()));
+ if (vm.exception())
+ return {};
+ descriptor_object->define_property(vm.names.configurable, Value(descriptor.attributes.is_configurable()));
+ if (vm.exception())
+ return {};
return descriptor_object;
}