1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:27:45 +00:00

LibWeb: Allow passing null to a nullable IDL union type

This fixes an issue on Twitter where they were instantiating an
IntersectionObserver with a null root. The root IDL type is
`(Element or Document)?` so null needs to be allowed.
This commit is contained in:
Andreas Kling 2022-09-18 12:50:01 +02:00
parent 0ca1b4b123
commit 9743849ddb

View file

@ -1334,7 +1334,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
if (!optional_default_value.has_value() || optional_default_value == "null"sv) { if (!optional_default_value.has_value() || optional_default_value == "null"sv) {
union_generator.append(R"~~~( union_generator.append(R"~~~(
Optional<@union_type@> @cpp_name@; Optional<@union_type@> @cpp_name@;
if (!@js_name@@js_suffix@.is_undefined()) if (!@js_name@@js_suffix@.is_nullish())
@cpp_name@ = TRY(@js_name@@js_suffix@_to_variant(@js_name@@js_suffix@)); @cpp_name@ = TRY(@js_name@@js_suffix@_to_variant(@js_name@@js_suffix@));
)~~~"); )~~~");
} else { } else {