diff --git a/Tests/LibWeb/Text/expected/reset-input-element.txt b/Tests/LibWeb/Text/expected/reset-input-element.txt new file mode 100644 index 00000000000..baf8cfc78f1 --- /dev/null +++ b/Tests/LibWeb/Text/expected/reset-input-element.txt @@ -0,0 +1,13 @@ +abc + +true +false +true +false +abc +abc +1 +2 +false +true +true diff --git a/Tests/LibWeb/Text/input/reset-input-element.html b/Tests/LibWeb/Text/input/reset-input-element.html new file mode 100644 index 00000000000..56f912bc9b4 --- /dev/null +++ b/Tests/LibWeb/Text/input/reset-input-element.html @@ -0,0 +1,58 @@ + + +
+ + + + + + + + 5 + + + + + +
+ diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 352314f5505..ac7aef7aac5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -5,6 +5,7 @@ * Copyright (c) 2023-2024, Shannon Booth * Copyright (c) 2023, Bastiaan van der Plaat * Copyright (c) 2024, Jelle Raaijmakers + * Copyright (c) 2024, Fernando Kiotheka * * SPDX-License-Identifier: BSD-2-Clause */ @@ -406,6 +407,20 @@ WebIDL::ExceptionOr HTMLInputElement::run_input_activation_behavior(DOM::E // 4. Submit the element's form owner from the element with userInvolvement set to event's user navigation involvement. TRY(form->submit_form(*this, { .user_involvement = user_navigation_involvement(event) })); } + // https://html.spec.whatwg.org/multipage/input.html#reset-button-state-(type=reset) + else if (type_state() == TypeAttributeState::ResetButton) { + // 1. If the element does not have a form owner, then return. + auto* form = this->form(); + if (!form) + return {}; + + // 2. If the element's node document is not fully active, then return. + if (!document().is_fully_active()) + return {}; + + // 3. Reset the form owner from the element. + form->reset_form(); + } return {}; }