diff options
author | Linus Groh <mail@linusgroh.de> | 2021-06-07 23:07:13 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-06-07 23:07:13 +0100 |
commit | 3fdad563e2a845f356482d8917aba062cde30f81 (patch) | |
tree | d856f22c98d7845503c798fd3e718d3ece12bfaf /Userland | |
parent | 8c964ef9f88b95aff4db1cb4725df8b7837b9ffd (diff) | |
download | serenity-3fdad563e2a845f356482d8917aba062cde30f81.zip |
LibJS: Never omit setter/getter attributes in accessor descriptor object
These should not be omitted, an accessor with out getter or setter still
yields an undefined for the attribute in its descriptor object.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Object.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index e6a4816da6..2a21fd51f4 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -434,17 +434,14 @@ Value Object::get_own_property_descriptor_object(const PropertyName& property_na descriptor_object->define_property(vm.names.writable, Value(descriptor.attributes.is_writable())); if (vm.exception()) return {}; - } else if (descriptor.is_accessor_descriptor()) { - if (descriptor.getter) { - descriptor_object->define_property(vm.names.get, Value(descriptor.getter)); - if (vm.exception()) - return {}; - } - if (descriptor.setter) { - descriptor_object->define_property(vm.names.set, Value(descriptor.setter)); - if (vm.exception()) - return {}; - } + } else { + VERIFY(descriptor.is_accessor_descriptor()); + descriptor_object->define_property(vm.names.get, descriptor.getter ? Value(descriptor.getter) : js_undefined()); + if (vm.exception()) + return {}; + descriptor_object->define_property(vm.names.set, descriptor.setter ? Value(descriptor.setter) : js_undefined()); + if (vm.exception()) + return {}; } descriptor_object->define_property(vm.names.enumerable, Value(descriptor.attributes.is_enumerable())); if (vm.exception()) |