diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index 4eb4da0c340..5e049492374 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -1586,9 +1586,10 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter )~~~"); } else { if (!optional_default_value.has_value()) { + union_generator.set("nullish_or_undefined", union_type.is_nullable() ? "nullish" : "undefined"); union_generator.append(R"~~~( Optional<@union_type@> @cpp_name@; - if (!@js_name@@js_suffix@.is_undefined()) + if (!@js_name@@js_suffix@.is_@nullish_or_undefined@()) @cpp_name@ = TRY(@js_name@@js_suffix@_to_variant(@js_name@@js_suffix@)); )~~~"); } else { diff --git a/Tests/LibWeb/Text/expected/Fetch/request-constructor-does-not-throw-on-null-body-with-get-or-head-request.txt b/Tests/LibWeb/Text/expected/Fetch/request-constructor-does-not-throw-on-null-body-with-get-or-head-request.txt new file mode 100644 index 00000000000..235cae15ec7 --- /dev/null +++ b/Tests/LibWeb/Text/expected/Fetch/request-constructor-does-not-throw-on-null-body-with-get-or-head-request.txt @@ -0,0 +1,4 @@ +Successfully created GET request with body set to null +Successfully created HEAD request with body set to null +Successfully started GET fetch with body set to null +Successfully started HEAD fetch with body set to null diff --git a/Tests/LibWeb/Text/input/Fetch/request-constructor-does-not-throw-on-null-body-with-get-or-head-request.html b/Tests/LibWeb/Text/input/Fetch/request-constructor-does-not-throw-on-null-body-with-get-or-head-request.html new file mode 100644 index 00000000000..2a819c94bd3 --- /dev/null +++ b/Tests/LibWeb/Text/input/Fetch/request-constructor-does-not-throw-on-null-body-with-get-or-head-request.html @@ -0,0 +1,21 @@ + + +