mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 07:36:50 +00:00
LibWeb: Allow cloneNode() to clone elements with weird attributes
We can't rely on Element.setAttribute() in cloneNode() since that will throw on weird attribute names. Instead, just follow the spec and copy attributes into cloned elements verbatim. This fixes a crash when loading the "issues" tab on GitHub repos. They are actually sending us unintentionally broken markup, but we should still support cloning it. :^)
This commit is contained in:
@@ -826,7 +826,7 @@ JS::NonnullGCPtr<Node> Node::clone_node(Document* document, bool clone_children)
|
||||
element.for_each_attribute([&](auto& name, auto& value) {
|
||||
// 1. Let copyAttribute be a clone of attribute.
|
||||
// 2. Append copyAttribute to copy.
|
||||
MUST(element_copy->set_attribute(name, value));
|
||||
element_copy->append_attribute(name, value);
|
||||
});
|
||||
copy = move(element_copy);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user