Bug 10239 - XMLSerializer drops attribute values when attribute are previously accessed with getAttributeNode
Summary: XMLSerializer drops attribute values when attribute are previously accessed w...
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 417.x
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
URL: http://www.veerwest.com/test/safari_t...
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-03 13:08 PDT by Cedric Savarese
Modified: 2019-02-06 09:02 PST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cedric Savarese 2006-08-03 13:08:37 PDT
See the test case provided.

Here is the javascript code that reproduces the problem.
<script type="text/javascript">

	var domDoc = (new DOMParser()).parseFromString("<test><element attr1=\"test\" attr2=\"\" attr3=\"something\" /></test>", "text/xml");

	var xmlSerializer = new XMLSerializer();

	var serializedXML = xmlSerializer.serializeToString(domDoc);

	document.write("<textarea cols='60' rows='5'>" + serializedXML + "</textarea>");

	var element = domDoc.getElementsByTagName('element')[0];

	attr = element.getAttributeNode('attr1');

	var serializedXML = xmlSerializer.serializeToString(domDoc);

	document.write("<textarea cols='60' rows='5'>" + serializedXML + "</textarea>");

    document.write("<br/>Node value: "+ element.getAttributeNode('attr1').nodeValue);

</script> 

The second textarea shows that the value for the attr1 attribute is lost in the serialization. The DOM is still correct because the value can still be accessed.
If the call to getAttributeNode is removed, the second serialization works fine.
Comment 1 Alexey Proskuryakov 2006-08-04 06:07:23 PDT
I can reproduce this issue with stock 10.4.7 Safari, but not with a recent nightly (r15780). You can get a nightly build to verify the behavior from <http://nightly.webkit.org>.

Not sure what exactly fixed this, so closing as WORKSFORME.
Comment 2 Lucas Forschler 2019-02-06 09:02:40 PST
Mass moving XML DOM bugs to the "DOM" Component.