mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:17:44 +00:00
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.
This commit is contained in:
parent
e72e621d89
commit
eb0b1c432a
8 changed files with 29 additions and 29 deletions
|
@ -202,14 +202,14 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::define_property_)
|
|||
vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObject, "Object argument");
|
||||
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<TypeError>(global_object, ErrorType::NotAnObject, "Descriptor argument");
|
||||
return {};
|
||||
}
|
||||
auto& object = vm.argument(0).as_object();
|
||||
auto property_key = StringOrSymbol::from_value(global_object, vm.argument(1));
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto& descriptor = vm.argument(2).as_object();
|
||||
if (!object.define_property(property_key, descriptor)) {
|
||||
if (!vm.exception()) {
|
||||
|
@ -316,10 +316,10 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::has_own)
|
|||
auto* object = vm.argument(0).to_object(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto string_or_symbol = StringOrSymbol::from_value(global_object, vm.argument(1));
|
||||
auto property_key = vm.argument(1).to_property_key(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
return Value(object->has_own_property(string_or_symbol));
|
||||
return Value(object->has_own_property(property_key));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue