Last Comment Bug 706770 - let setAttributeNS() only set the attribute value (not its prefix)
: let setAttributeNS() only set the attribute value (not its prefix)
Status: UNCONFIRMED
:
Product: Core
Classification: Components
Component: DOM: Core & HTML (show other bugs)
: unspecified
: x86 Mac OS X
: -- normal (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-12-01 01:14 PST by Anne (:annevk)
Modified: 2014-09-02 11:52 PDT (History)
6 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments

Description Anne (:annevk) 2011-12-01 01:14:28 PST
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 Olli Pettay [:smaug] (way behind * queues, especially ni? queue) 2011-12-01 01:25:03 PST
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 )
Comment 2 Arkadiusz Michalski (Spirit) 2014-09-01 07:13:14 PDT
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 Arkadiusz Michalski (Spirit) 2014-09-01 08:10:39 PDT
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 Boris Zbarsky [:bz] (still a bit busy) 2014-09-02 09:51:17 PDT
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.

Note You need to log in before you can comment on or make changes to this bug.