From 25374a193ca2fda77f76e4e5beb07e19cb82ab65 Mon Sep 17 00:00:00 2001 From: stelar7 Date: Mon, 21 Oct 2024 02:03:11 +0200 Subject: [PATCH] LibWeb/Meta: Adjust how missing/invalid default values are generated (cherry picked from commit d81f31c6993a422e02d48b02872de436a07e73b7) --- .../LibWeb/BindingsGenerator/IDLGenerators.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index 9b673b93619..fad02597a68 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -3501,21 +3501,24 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.getter_callback@) // or that it is in a state of attributeDefinition with no associated keyword value, then return the empty string. // NOTE: @invalid_enum_default_value@ is set to the empty string if it isn't present. attribute_generator.append(R"~~~( - if (!contentAttributeValue.has_value()) + auto did_set_to_missing_value = false; + if (!contentAttributeValue.has_value()) { retval = "@missing_enum_default_value@"_string; + did_set_to_missing_value = true; + } Array valid_values { @valid_enum_values@ }; - auto found = false; + auto has_keyword = false; for (auto const& value : valid_values) { if (value.equals_ignoring_ascii_case(retval)) { - found = true; + has_keyword = true; retval = value; break; } } - if (!found) + if (!has_keyword && !did_set_to_missing_value) retval = "@invalid_enum_default_value@"_string; )~~~");