1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:17:44 +00:00

LibWeb: Handle null values when making args for attributeChangedCallback

JS::PrimitiveString::create uses `is_empty()` on DeprecatedString to
use the empty string cache on the VM. However, this also considers the
DeprecatedString null state to be empty, giving an empty string instead
of `null` for null DeprecatedStrings.
This commit is contained in:
Luke Wilde 2023-04-11 22:19:42 +01:00 committed by Linus Groh
parent f816a24b86
commit dc5f213fa0

View file

@ -99,9 +99,9 @@ void Attr::handle_attribute_changes(Element& element, DeprecatedString const& ol
JS::MarkedVector<JS::Value> arguments { vm.heap() }; JS::MarkedVector<JS::Value> arguments { vm.heap() };
arguments.append(JS::PrimitiveString::create(vm, local_name())); arguments.append(JS::PrimitiveString::create(vm, local_name()));
arguments.append(JS::PrimitiveString::create(vm, old_value)); arguments.append(old_value.is_null() ? JS::js_null() : JS::PrimitiveString::create(vm, old_value));
arguments.append(JS::PrimitiveString::create(vm, new_value)); arguments.append(new_value.is_null() ? JS::js_null() : JS::PrimitiveString::create(vm, new_value));
arguments.append(JS::PrimitiveString::create(vm, namespace_uri())); arguments.append(namespace_uri().is_null() ? JS::js_null() : JS::PrimitiveString::create(vm, namespace_uri()));
element.enqueue_a_custom_element_callback_reaction(HTML::CustomElementReactionNames::attributeChangedCallback, move(arguments)); element.enqueue_a_custom_element_callback_reaction(HTML::CustomElementReactionNames::attributeChangedCallback, move(arguments));
} }