LibWeb: Properly propagate errors for Node set_text_content

This function was supposed to throw errors even before the TrustedTypes
spec thanks to the CharacterData replaceData call but had a MUST.

This changes this to ensure this function can throw an error
This commit is contained in:
Tete17 2025-08-08 02:25:57 +02:00 committed by Luke Wilde
parent 887537b061
commit 2fa84f1683
Notes: github-actions[bot] 2025-10-27 16:16:17 +00:00
7 changed files with 19 additions and 19 deletions

View file

@ -1082,7 +1082,7 @@ void HTMLInputElement::create_text_input_shadow_tree()
m_text_node = realm().create<DOM::Text>(document(), Utf16String {});
if (type_state() == TypeAttributeState::Password)
m_text_node->set_is_password_input({}, true);
m_text_node->set_text_content(m_value);
MUST(m_text_node->set_text_content(m_value));
handle_maxlength_attribute();
MUST(m_inner_text_element->append_child(*m_text_node));
@ -1225,15 +1225,15 @@ void HTMLInputElement::update_file_input_shadow_tree()
return;
auto files_label = has_attribute(HTML::AttributeNames::multiple) ? "files"sv : "file"sv;
m_file_button->set_text_content(Utf16String::formatted("Select {}...", files_label));
MUST(m_file_button->set_text_content(Utf16String::formatted("Select {}...", files_label)));
if (m_selected_files && m_selected_files->length() > 0) {
if (m_selected_files->length() == 1)
m_file_label->set_text_content(Utf16String::from_utf8(m_selected_files->item(0)->name()));
MUST(m_file_label->set_text_content(Utf16String::from_utf8(m_selected_files->item(0)->name())));
else
m_file_label->set_text_content(Utf16String::formatted("{} files selected.", m_selected_files->length()));
MUST(m_file_label->set_text_content(Utf16String::formatted("{} files selected.", m_selected_files->length())));
} else {
m_file_label->set_text_content(Utf16String::formatted("No {} selected.", files_label));
MUST(m_file_label->set_text_content(Utf16String::formatted("No {} selected.", files_label)));
}
}