Open
Bug 706770
Opened 13 years ago
Updated 2 years ago
let setAttributeNS() only set the attribute value (not its prefix)
Categories
(Core :: DOM: Core & HTML, defect, P5)
Tracking
()
UNCONFIRMED
People
(Reporter: annevk, Unassigned)
Details
Letting setAttributeNS() change the prefix as well is problematic for mutation observers.
See: http://lists.w3.org/Archives/Public/www-dom/2011OctDec/0222.html
I have updated DOM4 to only make it set the value.
Comment 1•13 years ago
|
||
IMO we should not do this but change the spec.
Gecko and apparently IE behave currently the same way.
It is strange if setAttributeNS() doesn't do anything with the prefix.
A bit better than what the current DOM4 draft says would be to throw if one tries to change
prefix. But not sure if that is anyway web compatible (not that specs require such
compatibility anymore :p )
Status: NEW → UNCONFIRMED
Ever confirmed: false
Comment 2•11 years ago
|
||
This bug still exist (not only in Mac OS X platform), actual DOM spec. letting only change the value:
http://dom.spec.whatwg.org/#dom-element-setattributens
Small test:
<script>
var html = document.documentElement;
html.setAttributeNS("www.test1.com", "a:ID", "Test1");
html.setAttributeNS("www.test1.com", "b:ID", "Test2");
var attr = html.attributes[0];
document.write(attr.namespaceURI + " , " + attr.prefix + " , " + attr.name + " , " + attr.value + "<br>");
</script>
And behaviour in browser:
- Firefox and IE change prefix (and automaticaly changing Attr.name too)
- Chrome doesn't change prefix (and Attr.name)
Comment 3•11 years ago
|
||
Ohh, similar to https://bugzilla.mozilla.org/show_bug.cgi?id=1061234, when we make reference to attr object before invoking second setAttributeNS() Firefox works correct:
<script>
var html = document.documentElement;
html.setAttributeNS("www.test1.com", "a:ID", "Test1");
var attr = html.attributes[0];
html.setAttributeNS("www.test1.com", "b:ID", "Test2");
document.write(attr.namespaceURI + " , " + attr.prefix + " , " + attr.name + " , " + attr.value + "<br>");
</script>
And behaviour in browser:
- IE change prefix (and automaticaly changing Attr.name too)
- Firefox and Chrome doesn't change prefix (and Attr.name)
![]() |
||
Comment 4•11 years ago
|
||
This is somewhat different from bug 1061234. What you're seeing in comment 3 is that the setAttributeNS call doesn't affect the cached Attr object's nodeinfo... which is arguably a bug.
Comment 5•7 years ago
|
||
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046
Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.
If you have questions, please contact :mdaly.
Priority: -- → P5
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•