mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:48:10 +00:00
LibWeb: Port HTMLOptionElement interface from DeprecatedString to String
This commit is contained in:
parent
c405ba6b08
commit
7206f1777a
4 changed files with 13 additions and 16 deletions
|
@ -114,7 +114,7 @@ WebIDL::ExceptionOr<Optional<Vector<XHR::FormDataEntry>>> 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) }));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<void> HTMLOptionElement::set_value(DeprecatedString value)
|
||||
WebIDL::ExceptionOr<void> 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
|
||||
|
|
|
@ -20,11 +20,11 @@ public:
|
|||
bool selected() const { return m_selected; }
|
||||
void set_selected(bool);
|
||||
|
||||
DeprecatedString value() const;
|
||||
WebIDL::ExceptionOr<void> set_value(DeprecatedString);
|
||||
String value() const;
|
||||
WebIDL::ExceptionOr<void> set_value(String const&);
|
||||
|
||||
DeprecatedString text() const;
|
||||
void set_text(DeprecatedString);
|
||||
String text() const;
|
||||
void set_text(String const&);
|
||||
|
||||
int index() const;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#import <HTML/HTMLElement.idl>
|
||||
|
||||
// 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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue