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:
2 files changed
+21
-1
No files matched your search
@@ -1682,6 +1682,22 @@ mod tests {
|
||||
assert_eq!(v, serde_json::json!("#icon|#icon|id,xlink:href"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_attribute_updates_a_parsed_namespaced_attribute_in_place() {
|
||||
// setAttribute matched the stored attribute by local name only, so a
|
||||
// parsed `xlink:href` (prefix=xlink, local=href) was never found by the
|
||||
// qualified name "xlink:href": the update was pushed as a *second*
|
||||
// attribute, getAttribute kept returning the stale original, and the
|
||||
// element serialized `xlink:href` twice.
|
||||
let mut rt = setup_runtime(
|
||||
r##"<html><body><svg><use id="u" xlink:href="#a"></use></svg></body></html>"##,
|
||||
);
|
||||
let v = rt
|
||||
.evaluate("(function(){var u=document.getElementById('u');u.setAttribute('xlink:href','#b');var dup=(u.outerHTML.match(/xlink:href/g)||[]).length;return u.getAttribute('xlink:href')+'|'+u.getAttributeNS('http://www.w3.org/1999/xlink','href')+'|'+u.getAttributeNames().join(',')+'|'+dup;})()")
|
||||
.unwrap();
|
||||
assert_eq!(v, serde_json::json!("#b|#b|id,xlink:href|1"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_attribute_ns_validates_namespace_constraints() {
|
||||
let mut rt = setup_runtime("<html><body></body></html>");
|
||||
|
||||
Reference in new issue
Block a user