mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:27:43 +00:00
LibWeb: Implement reset algorithm for HTMLInputElement
This commit is contained in:
parent
6032d122c2
commit
de44e0faf5
2 changed files with 24 additions and 0 deletions
|
@ -736,6 +736,28 @@ DeprecatedString HTMLInputElement::value_sanitization_algorithm(DeprecatedString
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/input.html#the-input-element:concept-form-reset-control
|
||||||
|
void HTMLInputElement::reset_algorithm()
|
||||||
|
{
|
||||||
|
// The reset algorithm for input elements is to set the dirty value flag and dirty checkedness flag back to false,
|
||||||
|
m_dirty_value = false;
|
||||||
|
m_dirty_checkedness = false;
|
||||||
|
|
||||||
|
// set the value of the element to the value of the value content attribute, if there is one, or the empty string otherwise,
|
||||||
|
m_value = has_attribute(AttributeNames::value) ? get_attribute(AttributeNames::value) : DeprecatedString::empty();
|
||||||
|
|
||||||
|
// set the checkedness of the element to true if the element has a checked content attribute and false if it does not,
|
||||||
|
m_checked = has_attribute(AttributeNames::checked);
|
||||||
|
|
||||||
|
// empty the list of selected files,
|
||||||
|
m_selected_files = FileAPI::FileList::create(realm(), {});
|
||||||
|
|
||||||
|
// and then invoke the value sanitization algorithm, if the type attribute's current state defines one.
|
||||||
|
m_value = value_sanitization_algorithm(m_value);
|
||||||
|
if (m_text_node)
|
||||||
|
m_text_node->set_data(m_value);
|
||||||
|
}
|
||||||
|
|
||||||
void HTMLInputElement::form_associated_element_was_inserted()
|
void HTMLInputElement::form_associated_element_was_inserted()
|
||||||
{
|
{
|
||||||
create_shadow_tree_if_needed();
|
create_shadow_tree_if_needed();
|
||||||
|
|
|
@ -112,6 +112,8 @@ public:
|
||||||
// https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
|
// https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
|
||||||
virtual bool is_auto_capitalize_inheriting() const override { return true; }
|
virtual bool is_auto_capitalize_inheriting() const override { return true; }
|
||||||
|
|
||||||
|
virtual void reset_algorithm() override;
|
||||||
|
|
||||||
virtual void form_associated_element_was_inserted() override;
|
virtual void form_associated_element_was_inserted() override;
|
||||||
|
|
||||||
// ^HTMLElement
|
// ^HTMLElement
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue