RESOLVED CONFIGURATION CHANGED 117394
DOMSerializer creates invalid XML when setAttributeNS() has been used
https://bugs.webkit.org/show_bug.cgi?id=117394
Summary DOMSerializer creates invalid XML when setAttributeNS() has been used
Thomas W.
Reported 2013-06-10 00:55:24 PDT
== Overview == When serializing a document where attributes have been added using .setAttributeNs(), the serialization is invalid XML. == Steps to Reproduce == Execute the following code: var doc = (new DOMParser()).parseFromString("<test xmlns='http://www.example.com'/>","text/xml"); doc.documentElement.setAttributeNS("http://www.w3.org/XML/1998/namespace","id","abc"); doc.documentElement.setAttributeNS("http://www.example.com/dummy/namespace","foo","bar"); console.log((new XMLSerializer()).serializeToString(doc)); (can be found at http://jsfiddle.net/c4jBw/) == Actual Results == <test xmlns="http://www.example.com" id="abc" xmlns="http://www.w3.org/XML/1998/namespace" foo="bar" xmlns="http://www.example.com/dummy/namespace"/> == Expected Results == <test xmlns="http://www.example.com" xml:id="abc" a0:foo="bar" xmlns:a0="http://www.example.com/dummy/namespace"/> == Software Version == First encountered with Safari 5.1.7 (7534.57.2) on Windows 7 == Additional Comments == The main problem are three xmlns attributes. The second problem is that the added attributes are in the null namespace. The correct example output is taken from Firefox 21.
Attachments
Rob Buis
Comment 1 2013-07-16 13:17:12 PDT
This seems rather like other serializing bugs, like bug 19121? I am quite sure that fixing that one fixes this one too.
Lucas Forschler
Comment 2 2019-02-06 09:02:31 PST
Mass moving XML DOM bugs to the "DOM" Component.
Ahmad Saleem
Comment 3 2022-08-12 11:41:34 PDT
*** Safari Technical Preview 151 **** > In JSFiddle: "&lt;test xmlns=\&quot;http://www.example.com\&quot; xml:id=\&quot;abc\&quot; NS1:foo=\&quot;bar\&quot; xmlns:NS1=\&quot;http://www.example.com/dummy/namespace\&quot;/&gt;" > In Browser Console: <test xmlns="http://www.example.com" xml:id="abc" NS1:foo="bar" xmlns:NS1="http://www.example.com/dummy/namespace"/> ** Chrome Canary 106 *** > In JSFiddle: "&lt;test xmlns=\&quot;http://www.example.com\&quot; xml:id=\&quot;abc\&quot; xmlns:ns1=\&quot;http://www.example.com/dummy/namespace\&quot; ns1:foo=\&quot;bar\&quot;/&gt;" > In Browser Console: <test xmlns="http://www.example.com" xml:id="abc" xmlns:ns1="http://www.example.com/dummy/namespace" ns1:foo="bar"/> *** Firefox Nightly 105 *** > In JSFiddle: "&lt;test xmlns=\&quot;http://www.example.com\&quot; xml:id=\&quot;abc\&quot; a0:foo=\&quot;bar\&quot; xmlns:a0=\&quot;http://www.example.com/dummy/namespace\&quot;/&gt;" > In Browser Console: <test xmlns="http://www.example.com" xml:id="abc" NS1:foo="bar" xmlns:NS1="http://www.example.com/dummy/namespace"/> ___________ I am not sure now web-spec so I am going to just post updated results. Thanks!
Ryosuke Niwa
Comment 4 2022-08-13 22:28:55 PDT
This appears to be working now.
Note You need to log in before you can comment on or make changes to this bug.