mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:48:12 +00:00
LibWeb+LibJS: Add [LegacyNullToEmptyString] attribute
If specified, to_string() returns an empty string instead of "null" for null values.
This commit is contained in:
parent
1745e503aa
commit
bb22b04d44
3 changed files with 7 additions and 6 deletions
|
@ -143,13 +143,13 @@ PrimitiveString* Value::to_primitive_string(GlobalObject& global_object)
|
|||
return js_string(global_object.heap(), string);
|
||||
}
|
||||
|
||||
String Value::to_string(GlobalObject& global_object) const
|
||||
String Value::to_string(GlobalObject& global_object, bool legacy_null_to_empty_string) const
|
||||
{
|
||||
switch (m_type) {
|
||||
case Type::Undefined:
|
||||
return "undefined";
|
||||
case Type::Null:
|
||||
return "null";
|
||||
return !legacy_null_to_empty_string ? "null" : String::empty();
|
||||
case Type::Boolean:
|
||||
return m_value.as_bool ? "true" : "false";
|
||||
case Type::Number:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue