mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 00:25:12 +00:00
LibWeb: Allow null for optional, nullable, no default value union types
For these types, it would previously only accept `undefined` for the `null` state. Fixes GET requests in the Turbo library always failing:9e057f284a/src/http/fetch_request.js (L219-L220)9e057f284a/src/http/fetch_request.js (L51-L64)This was found on https://www.fangamer.com/.
This commit is contained in:
committed by
Andreas Kling
parent
16662ab230
commit
198cec481a
@@ -1586,9 +1586,10 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||||||
)~~~");
|
)~~~");
|
||||||
} else {
|
} else {
|
||||||
if (!optional_default_value.has_value()) {
|
if (!optional_default_value.has_value()) {
|
||||||
|
union_generator.set("nullish_or_undefined", union_type.is_nullable() ? "nullish" : "undefined");
|
||||||
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_or_undefined@())
|
||||||
@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 {
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
asyncTest(async (done) => {
|
||||||
|
try {
|
||||||
|
const dataUrl = "data:,hello";
|
||||||
|
new Request(dataUrl, { method: "GET", body: null });
|
||||||
|
println("Successfully created GET request with body set to null");
|
||||||
|
new Request(dataUrl, { method: "HEAD", body: null });
|
||||||
|
println("Successfully created HEAD request with body set to null");
|
||||||
|
await fetch(dataUrl, { method: "GET", body: null });
|
||||||
|
println("Successfully started GET fetch with body set to null");
|
||||||
|
await fetch(dataUrl, { method: "HEAD", body: null });
|
||||||
|
println("Successfully started HEAD fetch with body set to null");
|
||||||
|
} catch (e) {
|
||||||
|
println(`Unexpected throw: ${e}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user