Merge pull request #549 from mnaza/fix/set-attribute-qualified-name-547

fix(dom): match setAttribute by qualified name, not local name only
This commit is contained in:
SGavrl authored and GitHub committed 2026-08-07 16:51:32 +00:00
commit 44fd3dc65b
2 files changed
+21 -1

No files matched your search

+5 -1
View File
@@ -136,7 +136,11 @@ impl Node {
pub fn set_attribute(&mut self, name: &str, value: String) {
if let NodeData::Element { attrs, .. } = &mut self.data {
if let Some(attr) = attrs.iter_mut().find(|a| a.name.local.as_ref() == name) {
// Match by qualified name, consistent with get_attribute and the
// remove_attribute op. A parsed namespaced attribute is stored with
// a separate prefix (e.g. xlink:href -> prefix="xlink", local="href");
// matching on local name alone would miss it and push a duplicate.
if let Some(attr) = attrs.iter_mut().find(|a| a.qualified_name_eq(name)) {
attr.value = value;
} else {
attrs.push(Attribute {