diff options
author | Linus Groh <mail@linusgroh.de> | 2021-10-11 23:23:52 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-10-11 23:36:03 +0100 |
commit | 44e70d1bc0508f8c65ae83fa21f1642654364f4c (patch) | |
tree | 1b4f82fd8b3ce0ece364fe7a25e244793cf43409 /Userland/Libraries/LibJS | |
parent | 8ea79c05dbb2d2e3e9d775737bc608dc3dd976a9 (diff) | |
download | serenity-44e70d1bc0508f8c65ae83fa21f1642654364f4c.zip |
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);
Diffstat (limited to 'Userland/Libraries/LibJS')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Value.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Value.h | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index 7078eb1369..ff85981e95 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -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: diff --git a/Userland/Libraries/LibJS/Runtime/Value.h b/Userland/Libraries/LibJS/Runtime/Value.h index db22c57ebd..6e0757f3db 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.h +++ b/Userland/Libraries/LibJS/Runtime/Value.h @@ -303,7 +303,7 @@ public: u64 encoded() const { return m_value.encoded; } - String to_string(GlobalObject&, bool legacy_null_to_empty_string = false) const; + String to_string(GlobalObject&) const; Utf16String to_utf16_string(GlobalObject&) const; PrimitiveString* to_primitive_string(GlobalObject&); Value to_primitive(GlobalObject&, PreferredType preferred_type = PreferredType::Default) const; |