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
Notes: sideshowbarker 2024-07-17 08:37:36 +09:00

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) {
union_generator.append(R"~~~(
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@));
)~~~");
} else {