mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:18:12 +00:00
LibWeb: Remove duplicated HTMLInputElement::name
This is already implemented by Element with a cache. Remove it - and make use of this function where applicable.
This commit is contained in:
parent
0695236408
commit
2a94cddb02
3 changed files with 6 additions and 10 deletions
|
@ -125,8 +125,8 @@ WebIDL::ExceptionOr<Optional<Vector<XHR::FormDataEntry>>> construct_entry_list(J
|
||||||
value = "on"_string;
|
value = "on"_string;
|
||||||
|
|
||||||
// 2. Create an entry with name and value, and append it to entry list.
|
// 2. Create an entry with name and value, and append it to entry list.
|
||||||
auto checkbox_or_radio_element_name = TRY_OR_THROW_OOM(vm, String::from_byte_string(checkbox_or_radio_element->name()));
|
auto checkbox_or_radio_element_name = checkbox_or_radio_element->name();
|
||||||
entry_list.append(XHR::FormDataEntry { .name = move(checkbox_or_radio_element_name), .value = move(value) });
|
entry_list.append(XHR::FormDataEntry { .name = checkbox_or_radio_element_name->to_string(), .value = move(value) });
|
||||||
}
|
}
|
||||||
// 8. Otherwise, if the field element is an input element whose type attribute is in the File Upload state, then:
|
// 8. Otherwise, if the field element is an input element whose type attribute is in the File Upload state, then:
|
||||||
else if (auto* file_element = dynamic_cast<HTML::HTMLInputElement*>(control.ptr()); file_element && file_element->type_state() == HTMLInputElement::TypeAttributeState::FileUpload) {
|
else if (auto* file_element = dynamic_cast<HTML::HTMLInputElement*>(control.ptr()); file_element && file_element->type_state() == HTMLInputElement::TypeAttributeState::FileUpload) {
|
||||||
|
|
|
@ -965,9 +965,9 @@ static bool is_in_same_radio_button_group(HTML::HTMLInputElement const& a, HTML:
|
||||||
&& a.form() == b.form()
|
&& a.form() == b.form()
|
||||||
// - They both have a name attribute, their name attributes are not empty, and the
|
// - They both have a name attribute, their name attributes are not empty, and the
|
||||||
// value of a's name attribute equals the value of b's name attribute.
|
// value of a's name attribute equals the value of b's name attribute.
|
||||||
&& a.has_attribute(HTML::AttributeNames::name)
|
&& a.name().has_value()
|
||||||
&& b.has_attribute(HTML::AttributeNames::name)
|
&& b.name().has_value()
|
||||||
&& non_empty_equals(a.name(), b.name()));
|
&& non_empty_equals(a.name().value(), b.name().value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/input.html#radio-button-state-(type=radio)
|
// https://html.spec.whatwg.org/multipage/input.html#radio-button-state-(type=radio)
|
||||||
|
@ -979,8 +979,7 @@ void HTMLInputElement::set_checked_within_group()
|
||||||
set_checked(true, ChangeSource::User);
|
set_checked(true, ChangeSource::User);
|
||||||
|
|
||||||
// No point iterating the tree if we have an empty name.
|
// No point iterating the tree if we have an empty name.
|
||||||
auto name = this->name();
|
if (!name().has_value() || name()->is_empty())
|
||||||
if (name.is_empty())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
document().for_each_in_inclusive_subtree_of_type<HTML::HTMLInputElement>([&](auto& element) {
|
document().for_each_in_inclusive_subtree_of_type<HTML::HTMLInputElement>([&](auto& element) {
|
||||||
|
@ -1010,8 +1009,6 @@ void HTMLInputElement::legacy_pre_activation_behavior()
|
||||||
// has its checkedness set to true, if any, and then set this element's
|
// has its checkedness set to true, if any, and then set this element's
|
||||||
// checkedness to true.
|
// checkedness to true.
|
||||||
if (type_state() == TypeAttributeState::RadioButton) {
|
if (type_state() == TypeAttributeState::RadioButton) {
|
||||||
ByteString name = this->name();
|
|
||||||
|
|
||||||
document().for_each_in_inclusive_subtree_of_type<HTML::HTMLInputElement>([&](auto& element) {
|
document().for_each_in_inclusive_subtree_of_type<HTML::HTMLInputElement>([&](auto& element) {
|
||||||
if (element.checked() && is_in_same_radio_button_group(*this, element)) {
|
if (element.checked() && is_in_same_radio_button_group(*this, element)) {
|
||||||
m_legacy_pre_activation_behavior_checked_element_in_group = &element;
|
m_legacy_pre_activation_behavior_checked_element_in_group = &element;
|
||||||
|
|
|
@ -65,7 +65,6 @@ public:
|
||||||
WebIDL::ExceptionOr<void> set_type(String const&);
|
WebIDL::ExceptionOr<void> set_type(String const&);
|
||||||
|
|
||||||
ByteString default_value() const { return deprecated_attribute(HTML::AttributeNames::value); }
|
ByteString default_value() const { return deprecated_attribute(HTML::AttributeNames::value); }
|
||||||
ByteString name() const { return deprecated_attribute(HTML::AttributeNames::name); }
|
|
||||||
|
|
||||||
virtual String value() const override;
|
virtual String value() const override;
|
||||||
WebIDL::ExceptionOr<void> set_value(String const&);
|
WebIDL::ExceptionOr<void> set_value(String const&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue