Bug 5177 - Javascript cloneNode(deep) does not clone form elements correctly
Summary: Javascript cloneNode(deep) does not clone form elements correctly
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Anders Carlsson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-28 21:56 PDT by David Richardson
Modified: 2019-02-06 09:03 PST (History)
1 user (show)

See Also:


Attachments
test case, text/html (990 bytes, text/html)
2005-12-30 06:21 PST, Alexey Proskuryakov
no flags Details
test case, application/xhtml+xml (990 bytes, application/xhtml+xml)
2005-12-30 06:22 PST, Alexey Proskuryakov
no flags Details
fixed test case, application/xhtml+xml (1007 bytes, application/xhtml+xml)
2005-12-30 06:30 PST, Alexey Proskuryakov
no flags Details
Fix (9.35 KB, patch)
2006-01-01 14:10 PST, Anders Carlsson
darin: review+
Details | Formatted Diff | Diff

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