LibWeb: Honor LegacyNullToEmptyString in union string conversion

The IDL generator was passing 'false' to generate_to_cpp when converting
a union containing a string type.
This broke WebIDL's LegacyNullToEmptyString behavior.

Pass the actual legacy_null_to_empty_string flag instead.
Fixes some WPTs:

domparsing/outerhtml-02
trusted-types/block-string-assignment-to-Element-outerHTML
trusted-types/block-string-assignment-to-HTMLElement-generic
trusted-types/block-string-assignment-to-ShadowRoot-innerHTML
This commit is contained in:
mikiubo
2025-12-06 23:06:13 +01:00
committed by Sam Atkins
parent 89870f82ba
commit de4e3ef63a
Notes: github-actions[bot] 2025-12-07 07:47:01 +00:00
6 changed files with 71 additions and 10 deletions

View File

@@ -1636,7 +1636,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
// NOTE: Currently all string types are converted to String.
IDL::Parameter parameter { .type = *string_type, .name = ByteString::empty(), .optional_default_value = {}, .extended_attributes = {} };
generate_to_cpp(union_generator, parameter, js_name, js_suffix, ByteString::formatted("{}{}_string", js_name, js_suffix), interface, false, false, {}, false, recursion_depth + 1);
generate_to_cpp(union_generator, parameter, js_name, js_suffix, ByteString::formatted("{}{}_string", js_name, js_suffix), interface, legacy_null_to_empty_string, false, {}, false, recursion_depth + 1);
union_generator.append(R"~~~(
return { @js_name@@js_suffix@_string };