Bug 5177

Summary: Javascript cloneNode(deep) does not clone form elements correctly
Product: WebKit Reporter: David Richardson <channel200>
Component: DOMAssignee: Anders Carlsson <andersca>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez
Priority: P2    
Version: 420+   
Hardware: Mac   
OS: OS X 10.4   
Attachments:
Description Flags
test case, text/html
none
test case, application/xhtml+xml
none
fixed test case, application/xhtml+xml
none
Fix darin: review+

Description David Richardson 2005-09-28 21:56:43 PDT
Javascript cloneNode(deep) should clone all attributes (as I understand it). A clone of an <INPUT> 
element does not contain the VALUE attribute. Mozilla and IE do. This has never worked in any version 
of Safari, including latest Webkit build obtained using 'Nightshift'.

Use test case included, fill the input field with a value, and clone it.

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML XMLNS="http://www.w3.org/1999/xhtml">
<HEAD>
	<TITLE>cloneNode(deep) Test Case</TITLE>
	<SCRIPT TYPE="text/javascript" LANGUAGE="javascript">
	function deepCloneTest()
	   {
	       //Get the input field and clone it.
	       //Append the cloned element to the document.
	       //When a 'deep' clone is created, should the current value of the source field not be cloned?
	       //Mozilla and (ugh) IE do it.
	       var sourceElement = document.getElementById("TestElement");
	       var newElement = sourceElement.cloneNode(true);
	       newElement.id = "ClonedElement";
	       sourceElement.parentNode.appendChild(newElement);
	   }
    </SCRIPT>
</HEAD>
<BODY>
    <INPUT ID="TestElement" TYPE="text" SIZE="20" MAXLENGTH="20" />
    <INPUT TYPE="button" VALUE="Clone Input Field" ONCLICK="deepCloneTest()"/>
</BODY>
</HTML>
Comment 1 Alexey Proskuryakov 2005-12-30 06:21:09 PST
Created attachment 5381 [details]
test case, text/html
Comment 2 Alexey Proskuryakov 2005-12-30 06:22:18 PST
Created attachment 5382 [details]
test case, application/xhtml+xml
Comment 3 Alexey Proskuryakov 2005-12-30 06:30:02 PST
Created attachment 5383 [details]
fixed test case, application/xhtml+xml
Comment 4 Anders Carlsson 2006-01-01 14:10:54 PST
Created attachment 5412 [details]
Fix
Comment 5 Darin Adler 2006-01-02 14:53:02 PST
Comment on attachment 5412 [details]
Fix

Looks fine to me. r=me
Comment 6 Lucas Forschler 2019-02-06 09:03:11 PST
Mass moving XML DOM bugs to the "DOM" Component.