mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 10:18:13 +00:00
LibWeb: Implement Node.cloneNode for Attr nodes
This commit is contained in:
parent
9a9c8460aa
commit
a004d3043f
3 changed files with 12 additions and 6 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue