From d3e076f963716222787903a9613e0678d909a7ab Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Wed, 21 Aug 2024 12:27:30 +0100 Subject: [PATCH] LibWeb: Implement cloning steps for `HTMLTextAreaElement` --- .../HTMLTextAreaElement-cloning-steps.txt | 1 + .../HTMLTextAreaElement-cloning-steps.html | 20 +++++++++++++++++++ .../LibWeb/HTML/HTMLTextAreaElement.cpp | 11 ++++++++++ .../LibWeb/HTML/HTMLTextAreaElement.h | 2 ++ 4 files changed, 34 insertions(+) create mode 100644 Tests/LibWeb/Text/expected/HTML/HTMLTextAreaElement-cloning-steps.txt create mode 100644 Tests/LibWeb/Text/input/HTML/HTMLTextAreaElement-cloning-steps.html diff --git a/Tests/LibWeb/Text/expected/HTML/HTMLTextAreaElement-cloning-steps.txt b/Tests/LibWeb/Text/expected/HTML/HTMLTextAreaElement-cloning-steps.txt new file mode 100644 index 00000000000..56535ab4463 --- /dev/null +++ b/Tests/LibWeb/Text/expected/HTML/HTMLTextAreaElement-cloning-steps.txt @@ -0,0 +1 @@ + Cloned textarea value: PASS diff --git a/Tests/LibWeb/Text/input/HTML/HTMLTextAreaElement-cloning-steps.html b/Tests/LibWeb/Text/input/HTML/HTMLTextAreaElement-cloning-steps.html new file mode 100644 index 00000000000..17777437f52 --- /dev/null +++ b/Tests/LibWeb/Text/input/HTML/HTMLTextAreaElement-cloning-steps.html @@ -0,0 +1,20 @@ + + +
+ +
+ diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp index d0d2242ab87..e9e15a8f5e8 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp @@ -116,6 +116,17 @@ void HTMLTextAreaElement::reset_algorithm() } } +// https://html.spec.whatwg.org/multipage/forms.html#the-textarea-element:concept-node-clone-ext +WebIDL::ExceptionOr HTMLTextAreaElement::cloned(DOM::Node& copy, bool) +{ + // The cloning steps for textarea elements must propagate the raw value and dirty value flag from the node being cloned to the copy. + auto& textarea_copy = verify_cast(copy); + textarea_copy.m_raw_value = m_raw_value; + textarea_copy.m_dirty_value = m_dirty_value; + + return {}; +} + void HTMLTextAreaElement::form_associated_element_was_inserted() { create_shadow_tree_if_needed(); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h index 0ef2fba9cd6..6260cc18ae3 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h @@ -63,6 +63,8 @@ public: virtual void reset_algorithm() override; + virtual WebIDL::ExceptionOr cloned(Node&, bool) override; + virtual void form_associated_element_was_inserted() override; virtual void form_associated_element_was_removed(DOM::Node*) override; virtual void form_associated_element_attribute_changed(FlyString const&, Optional const&) override;