summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Libraries/LibWeb/DOM/Attr.cpp11
-rw-r--r--Userland/Libraries/LibWeb/DOM/Attr.h3
-rw-r--r--Userland/Libraries/LibWeb/DOM/Node.cpp4
3 files changed, 12 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Attr.cpp b/Userland/Libraries/LibWeb/DOM/Attr.cpp
index b38c2c1508..7ff4ee8dd6 100644
--- a/Userland/Libraries/LibWeb/DOM/Attr.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Attr.cpp
@@ -15,12 +15,17 @@ namespace Web::DOM {
JS::NonnullGCPtr<Attr> Attr::create(Document& document, FlyString local_name, DeprecatedString value, Element const* owner_element)
{
- return *document.heap().allocate<Attr>(document.realm(), document, move(local_name), move(value), owner_element);
+ return *document.heap().allocate<Attr>(document.realm(), document, QualifiedName(move(local_name), {}, {}), move(value), owner_element);
}
-Attr::Attr(Document& document, FlyString local_name, DeprecatedString value, Element const* owner_element)
+JS::NonnullGCPtr<Attr> Attr::clone(Document& document)
+{
+ return *heap().allocate<Attr>(realm(), document, m_qualified_name, m_value, nullptr);
+}
+
+Attr::Attr(Document& document, QualifiedName qualified_name, DeprecatedString value, Element const* owner_element)
: Node(document, NodeType::ATTRIBUTE_NODE)
- , m_qualified_name(move(local_name), {}, {})
+ , m_qualified_name(move(qualified_name))
, m_value(move(value))
, m_owner_element(owner_element)
{
diff --git a/Userland/Libraries/LibWeb/DOM/Attr.h b/Userland/Libraries/LibWeb/DOM/Attr.h
index 2411e7c3eb..5c48c99d4b 100644
--- a/Userland/Libraries/LibWeb/DOM/Attr.h
+++ b/Userland/Libraries/LibWeb/DOM/Attr.h
@@ -19,6 +19,7 @@ class Attr final : public Node {
public:
static JS::NonnullGCPtr<Attr> create(Document&, FlyString local_name, DeprecatedString value, Element const* = nullptr);
+ JS::NonnullGCPtr<Attr> clone(Document&);
virtual ~Attr() override = default;
@@ -42,7 +43,7 @@ public:
void handle_attribute_changes(Element&, DeprecatedString const& old_value, DeprecatedString const& new_value);
private:
- Attr(Document&, FlyString local_name, DeprecatedString value, Element const*);
+ Attr(Document&, QualifiedName, DeprecatedString value, Element const*);
virtual void visit_edges(Cell::Visitor&) override;
diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp
index 7f672fbece..86e1eb4a44 100644
--- a/Userland/Libraries/LibWeb/DOM/Node.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Node.cpp
@@ -750,10 +750,10 @@ JS::NonnullGCPtr<Node> Node::clone_node(Document* document, bool clone_children)
document_type_copy->set_system_id(document_type->system_id());
copy = move(document_type_copy);
} else if (is<Attr>(this)) {
- // FIXME:
// Attr
// Set copy’s namespace, namespace prefix, local name, and value to those of node.
- dbgln("clone_node() not implemented for Attribute");
+ auto& attr = static_cast<Attr&>(*this);
+ copy = attr.clone(*document);
} else if (is<Text>(this)) {
// Text
auto text = verify_cast<Text>(this);