diff --git a/Userland/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp b/Userland/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp index 7f4eb2763a..06eb66cd47 100644 --- a/Userland/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp +++ b/Userland/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp @@ -114,7 +114,7 @@ WebIDL::ExceptionOr>> construct_entry_list(J for (auto const& option_element : select_element->list_of_options()) { if (option_element->selected() && !option_element->disabled()) { auto option_name = TRY_OR_THROW_OOM(vm, String::from_deprecated_string(option_element->name())); - auto option_value = TRY_OR_THROW_OOM(vm, String::from_deprecated_string(option_element->value())); + auto option_value = option_element->value(); TRY_OR_THROW_OOM(vm, entry_list.try_append(XHR::FormDataEntry { .name = move(option_name), .value = move(option_value) })); } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp index bc453b1d1d..aee6c046eb 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp @@ -60,18 +60,15 @@ void HTMLOptionElement::set_selected(bool selected) } // https://html.spec.whatwg.org/multipage/form-elements.html#dom-option-value -DeprecatedString HTMLOptionElement::value() const +String HTMLOptionElement::value() const { // The value of an option element is the value of the value content attribute, if there is one. - if (auto value_attr = get_attribute(HTML::AttributeNames::value); !value_attr.is_null()) - return value_attr; - // ...or, if there is not, the value of the element's text IDL attribute. - return text(); + return attribute(HTML::AttributeNames::value).value_or(text()); } // https://html.spec.whatwg.org/multipage/form-elements.html#dom-option-value -WebIDL::ExceptionOr HTMLOptionElement::set_value(DeprecatedString value) +WebIDL::ExceptionOr HTMLOptionElement::set_value(String const& value) { return set_attribute(HTML::AttributeNames::value, value); } @@ -89,7 +86,7 @@ static void concatenate_descendants_text_content(DOM::Node const* node, StringBu } // https://html.spec.whatwg.org/multipage/form-elements.html#dom-option-text -DeprecatedString HTMLOptionElement::text() const +String HTMLOptionElement::text() const { StringBuilder builder; @@ -101,13 +98,13 @@ DeprecatedString HTMLOptionElement::text() const }); // Return the result of stripping and collapsing ASCII whitespace from the above concatenation. - return Infra::strip_and_collapse_whitespace(builder.string_view()).release_value_but_fixme_should_propagate_errors().to_deprecated_string(); + return MUST(Infra::strip_and_collapse_whitespace(builder.string_view())); } // https://html.spec.whatwg.org/multipage/form-elements.html#dom-option-text -void HTMLOptionElement::set_text(DeprecatedString text) +void HTMLOptionElement::set_text(String const& text) { - string_replace_all(text); + string_replace_all(text.to_deprecated_string()); } // https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-index diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.h b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.h index 55fde71add..f8bc35d088 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.h @@ -20,11 +20,11 @@ public: bool selected() const { return m_selected; } void set_selected(bool); - DeprecatedString value() const; - WebIDL::ExceptionOr set_value(DeprecatedString); + String value() const; + WebIDL::ExceptionOr set_value(String const&); - DeprecatedString text() const; - void set_text(DeprecatedString); + String text() const; + void set_text(String const&); int index() const; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.idl index eb614b324c..b1807007ac 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.idl @@ -1,7 +1,7 @@ #import // https://html.spec.whatwg.org/multipage/form-elements.html#htmloptionelement -[Exposed=Window, LegacyFactoryFunction=Option(optional DOMString text = "", optional DOMString value, optional boolean defaultSelected = false, optional boolean selected = false), UseDeprecatedAKString] +[Exposed=Window, LegacyFactoryFunction=Option(optional DOMString text = "", optional DOMString value, optional boolean defaultSelected = false, optional boolean selected = false)] interface HTMLOptionElement : HTMLElement { [HTMLConstructor] constructor();