mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibWeb: Support nullable attributes in generated toJSON()
Any optional or nullable attribute will end up in an `if/else` branch
when we collect the attribute values, and this is inherently
incompatibly with an `auto {attr}_wrapped = ...` expression. Define the
variable as an `JS::Value` before generating the wrap statement so we
can properly support `toJSON()` for an attribute like:
readonly attribute double? altitude;
This commit is contained in:
parent
30efcd0d00
commit
8f3fe0c39e
|
|
@ -3161,7 +3161,10 @@ static void collect_attribute_values_of_an_inheritance_stack(SourceGenerator& fu
|
|||
)~~~");
|
||||
}
|
||||
|
||||
generate_wrap_statement(attribute_generator, return_value_name, attribute.type, interface_in_chain, ByteString::formatted("auto {}_wrapped =", return_value_name));
|
||||
attribute_generator.append(R"~~~(
|
||||
JS::Value @attribute.return_value_name@_wrapped;
|
||||
)~~~");
|
||||
generate_wrap_statement(attribute_generator, return_value_name, attribute.type, interface_in_chain, ByteString::formatted("{}_wrapped =", return_value_name));
|
||||
|
||||
attribute_generator.append(R"~~~(
|
||||
MUST(result->create_data_property("@attribute.name@"_fly_string, @attribute.return_value_name@_wrapped));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user