The default bug view has changed. See this FAQ.

let setAttributeNS() only set the attribute value (not its prefix)

UNCONFIRMED
Unassigned

Status

()

Core
DOM: Core & HTML
UNCONFIRMED
5 years ago
3 years ago

People

(Reporter: annevk, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

5 years ago
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.
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
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)
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)
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.
You need to log in before you can comment on or make changes to this bug.