mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:27:45 +00:00
LibJS: Stop coercing Date.prototype[Symbol.toPrimitive] hint to string
This commit is contained in:
parent
9295f1936c
commit
6ef56f79bd
1 changed files with 6 additions and 3 deletions
|
@ -860,12 +860,15 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::symbol_to_primitive)
|
||||||
{
|
{
|
||||||
auto this_value = vm.this_value(global_object);
|
auto this_value = vm.this_value(global_object);
|
||||||
if (!this_value.is_object()) {
|
if (!this_value.is_object()) {
|
||||||
vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObject);
|
vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObject, this_value.to_string_without_side_effects());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
auto hint = vm.argument(0).to_string(global_object);
|
auto hint_value = vm.argument(0);
|
||||||
if (vm.exception())
|
if (!hint_value.is_string()) {
|
||||||
|
vm.throw_exception<TypeError>(global_object, ErrorType::InvalidHint, hint_value.to_string_without_side_effects());
|
||||||
return {};
|
return {};
|
||||||
|
}
|
||||||
|
auto& hint = hint_value.as_string().string();
|
||||||
Value::PreferredType try_first;
|
Value::PreferredType try_first;
|
||||||
if (hint == "string" || hint == "default") {
|
if (hint == "string" || hint == "default") {
|
||||||
try_first = Value::PreferredType::String;
|
try_first = Value::PreferredType::String;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue