From eb0b1c432a0e9aa5a220c460e95694dd3fbb67b8 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sat, 5 Jun 2021 15:22:11 +0300 Subject: LibJS: Replace StringOrSymbol::from_value with Value::to_property_key This is a more specification compliant implementation of the abstract operation 7.1.19 ToPropertyKey which should handle boxed symbols correctly. --- Userland/Libraries/LibJS/Runtime/ReflectObject.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Userland/Libraries/LibJS/Runtime/ReflectObject.cpp') diff --git a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp index 1dfd68d14f..3e7f911db6 100644 --- a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp @@ -124,13 +124,13 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::define_property) auto* target = get_target_object_from(global_object, "defineProperty"); if (!target) return {}; + auto property_key = vm.argument(1).to_property_key(global_object); + if (vm.exception()) + return {}; if (!vm.argument(2).is_object()) { vm.throw_exception(global_object, ErrorType::ReflectBadDescriptorArgument); return {}; } - auto property_key = StringOrSymbol::from_value(global_object, vm.argument(1)); - if (vm.exception()) - return {}; auto& descriptor = vm.argument(2).as_object(); auto success = target->define_property(property_key, descriptor, false); if (vm.exception()) -- cgit v1.2.3