From 3dbaae5cfc53e290cb9136dcec6d15a7894b65be Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Sun, 5 Jan 2025 15:46:57 +0000 Subject: [PATCH] LibWeb/HTML: Add cloning steps for HTMLScriptElement --- Libraries/LibWeb/HTML/HTMLScriptElement.cpp | 12 ++++++++++++ Libraries/LibWeb/HTML/HTMLScriptElement.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index da90594c34c..0d2efc90cba 100644 --- a/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -650,4 +650,16 @@ void HTMLScriptElement::set_async(bool async) } } +// https://html.spec.whatwg.org/multipage/scripting.html#script-processing-model:concept-node-clone-ext +WebIDL::ExceptionOr HTMLScriptElement::cloned(Node& copy, bool subtree) +{ + TRY(Base::cloned(copy, subtree)); + + // The cloning steps for script elements given node, copy, and subtree are to set copy's already started to node's already started. + auto& script_copy = verify_cast(copy); + script_copy.m_already_started = m_already_started; + + return {}; +} + } diff --git a/Libraries/LibWeb/HTML/HTMLScriptElement.h b/Libraries/LibWeb/HTML/HTMLScriptElement.h index 44e0f305c24..6e49fe7cab3 100644 --- a/Libraries/LibWeb/HTML/HTMLScriptElement.h +++ b/Libraries/LibWeb/HTML/HTMLScriptElement.h @@ -63,6 +63,8 @@ public: [[nodiscard]] bool async() const; void set_async(bool); + virtual WebIDL::ExceptionOr cloned(Node&, bool) override; + private: HTMLScriptElement(DOM::Document&, DOM::QualifiedName);