diff --git a/Userland/Libraries/LibWeb/DOM/Attribute.cpp b/Userland/Libraries/LibWeb/DOM/Attribute.cpp index 996a80a404..9933e7f60e 100644 --- a/Userland/Libraries/LibWeb/DOM/Attribute.cpp +++ b/Userland/Libraries/LibWeb/DOM/Attribute.cpp @@ -9,15 +9,16 @@ namespace Web::DOM { -NonnullRefPtr Attribute::create(Document& document, FlyString local_name, String value) +NonnullRefPtr Attribute::create(Document& document, FlyString local_name, String value, Element const* owner_element) { - return adopt_ref(*new Attribute(document, move(local_name), move(value))); + return adopt_ref(*new Attribute(document, move(local_name), move(value), owner_element)); } -Attribute::Attribute(Document& document, FlyString local_name, String value) +Attribute::Attribute(Document& document, FlyString local_name, String value, Element const* owner_element) : Node(document, NodeType::ATTRIBUTE_NODE) , m_qualified_name(move(local_name), {}, {}) , m_value(move(value)) + , m_owner_element(owner_element) { } diff --git a/Userland/Libraries/LibWeb/DOM/Attribute.h b/Userland/Libraries/LibWeb/DOM/Attribute.h index 0a9dfd97b9..850bc4bfa6 100644 --- a/Userland/Libraries/LibWeb/DOM/Attribute.h +++ b/Userland/Libraries/LibWeb/DOM/Attribute.h @@ -17,7 +17,7 @@ class Attribute final : public Node { public: using WrapperType = Bindings::AttributeWrapper; - static NonnullRefPtr create(Document&, FlyString local_name, String value); + static NonnullRefPtr create(Document&, FlyString local_name, String value, Element const* = nullptr); virtual ~Attribute() override = default; @@ -38,7 +38,7 @@ public: constexpr bool specified() const { return true; } private: - Attribute(Document&, FlyString local_name, String value); + Attribute(Document&, FlyString local_name, String value, Element const*); QualifiedName m_qualified_name; String m_value; diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index e6ea910150..5bfdb5084f 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -82,7 +82,7 @@ ExceptionOr Element::set_attribute(const FlyString& name, const String& va if (auto* attribute = find_attribute(name)) attribute->set_value(value); else - m_attributes.append(Attribute::create(document(), name, value)); + m_attributes.append(Attribute::create(document(), name, value, this)); parse_attribute(name, value); return {};