1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:37:35 +00:00

LibWeb: Remove Element::set_attribute(name, value?)

That API came from a mistake in the IDL compiler, where reflected
nullable attributes would try to call set_attribute(name, null).
This commit fixes the mistake in the IDL generator, and removes the
meaningless API.
This commit is contained in:
Ali Mohammad Pur 2023-10-13 23:06:47 +03:30 committed by Tim Flynn
parent d2c7e1ea7d
commit 988c6568a9
4 changed files with 20 additions and 11 deletions

View file

@ -2951,9 +2951,18 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.setter_callback@)
if (attribute.extended_attributes.contains("Reflect")) {
if (attribute.type->name() != "boolean") {
attribute_generator.append(R"~~~(
if (attribute.type->is_nullable()) {
attribute_generator.append(R"~~~(
if (!cpp_value.has_value())
impl->remove_attribute(HTML::AttributeNames::@attribute.reflect_name@);
else
MUST(impl->set_attribute(HTML::AttributeNames::@attribute.reflect_name@, cpp_value.value()));
)~~~");
} else {
attribute_generator.append(R"~~~(
MUST(impl->set_attribute(HTML::AttributeNames::@attribute.reflect_name@, cpp_value));
)~~~");
}
} else {
attribute_generator.append(R"~~~(
if (!cpp_value)