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+

David Richardson
Reported 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>
Attachments
test case, text/html (990 bytes, text/html)
2005-12-30 06:21 PST, Alexey Proskuryakov
no flags
test case, application/xhtml+xml (990 bytes, application/xhtml+xml)
2005-12-30 06:22 PST, Alexey Proskuryakov
no flags
fixed test case, application/xhtml+xml (1007 bytes, application/xhtml+xml)
2005-12-30 06:30 PST, Alexey Proskuryakov
no flags
Fix (9.35 KB, patch)
2006-01-01 14:10 PST, Anders Carlsson
darin: review+
Alexey Proskuryakov
Comment 1 2005-12-30 06:21:09 PST
Created attachment 5381 [details] test case, text/html
Alexey Proskuryakov
Comment 2 2005-12-30 06:22:18 PST
Created attachment 5382 [details] test case, application/xhtml+xml
Alexey Proskuryakov
Comment 3 2005-12-30 06:30:02 PST
Created attachment 5383 [details] fixed test case, application/xhtml+xml
Anders Carlsson
Comment 4 2006-01-01 14:10:54 PST
Darin Adler
Comment 5 2006-01-02 14:53:02 PST
Comment on attachment 5412 [details] Fix Looks fine to me. r=me
Lucas Forschler
Comment 6 2019-02-06 09:03:11 PST
Mass moving XML DOM bugs to the "DOM" Component.
Note You need to log in before you can comment on or make changes to this bug.