mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 12:49:19 +00:00
LibWeb: Clone all attribute properties when cloning a single node
Previously, the namespace of the attributes on the cloned element was not being set.
This commit is contained in:
parent
a467005855
commit
1e9e2b6564
Notes:
github-actions[bot]
2025-01-11 22:11:11 +00:00
Author: https://github.com/tcl3
Commit: 1e9e2b6564
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3228
Reviewed-by: https://github.com/gmta ✅
3 changed files with 88 additions and 3 deletions
|
@ -1099,11 +1099,24 @@ WebIDL::ExceptionOr<GC::Ref<Node>> Node::clone_single_node(Document& document) c
|
|||
auto element_copy = TRY(DOM::create_element(document, element.local_name(), element.namespace_uri(), element.prefix(), element.is_value()));
|
||||
|
||||
// 2. For each attribute of node’s attribute list:
|
||||
element.for_each_attribute([&](auto& name, auto& value) {
|
||||
// FIXME: 1. Let copyAttribute be the result of cloning a single node given attribute and document.
|
||||
Optional<WebIDL::Exception> maybe_exception;
|
||||
element.for_each_attribute([&](Attr const& attr) {
|
||||
// 1. Let copyAttribute be the result of cloning a single node given attribute and document.
|
||||
auto copy_attribute_or_error = attr.clone_single_node(document);
|
||||
if (copy_attribute_or_error.is_error()) {
|
||||
maybe_exception = copy_attribute_or_error.release_error();
|
||||
return;
|
||||
}
|
||||
|
||||
auto copy_attribute = copy_attribute_or_error.release_value();
|
||||
|
||||
// 2. Append copyAttribute to copy.
|
||||
element_copy->append_attribute(name, value);
|
||||
element_copy->append_attribute(verify_cast<Attr>(*copy_attribute));
|
||||
});
|
||||
|
||||
if (maybe_exception.has_value())
|
||||
return *maybe_exception;
|
||||
|
||||
copy = move(element_copy);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue