mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00: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
Notes:
github-actions[bot]
2025-06-21 08:01:47 +00:00
Author: https://github.com/gmta
Commit: 8f3fe0c39e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5143
1 changed files with 4 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue