1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:38:12 +00:00

LibJS+LibWeb: Let WrapperGenerator deal with legacy_null_to_empty_string

This concept is not present in ECMAScript, and it bothers me every time
I see it.
It's only used by WrapperGenerator, and even there only relevant in two
places, so let's fully remove it from LibJS and use a simple ternary
expression instead:

    cpp_name = js_name.is_null() && legacy_null_to_empty_string
        ? String::empty()
        : js_name.to_string(global_object);
This commit is contained in:
Linus Groh 2021-10-11 23:23:52 +01:00
parent 8ea79c05db
commit 44e70d1bc0
3 changed files with 10 additions and 6 deletions

View file

@ -333,13 +333,13 @@ PrimitiveString* Value::to_primitive_string(GlobalObject& global_object)
}
// 7.1.17 ToString ( argument ), https://tc39.es/ecma262/#sec-tostring
String Value::to_string(GlobalObject& global_object, bool legacy_null_to_empty_string) const
String Value::to_string(GlobalObject& global_object) const
{
switch (m_type) {
case Type::Undefined:
return "undefined";
case Type::Null:
return !legacy_null_to_empty_string ? "null" : String::empty();
return "null";
case Type::Boolean:
return m_value.as_bool ? "true" : "false";
case Type::Int32: