Summary: | REGRESSION: File input value invisible after removing and re-appending | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Jeremy Nicoll <jnicoll> | ||||||
Component: | Forms | Assignee: | Darin Adler <darin> | ||||||
Status: | RESOLVED FIXED | ||||||||
Severity: | Major | CC: | ap | ||||||
Priority: | P1 | Keywords: | HasReduction, Regression | ||||||
Version: | 420+ | ||||||||
Hardware: | Mac | ||||||||
OS: | OS X 10.4 | ||||||||
Attachments: |
|
Description
Jeremy Nicoll
2007-01-14 15:49:33 PST
Jeremy, please attach a stand-alone test case of this issue to this bug. Thanks! Just to clarify, the desired behavior is that the value of the fine input element NOT be cleared when cloned or moved to another parent. Scenario 1 (works in Safari, not in latest Webkit): <script type="text/javascript"> function press_this () { var f = document.getElementById('upload_1'); f.parentNode.removeChild(f); document.getElementById('form2').appendChild(f); } </script> <form action="test.php" method="POST" enctype="multipart/form-data"> <input type="file" name="upload" id="upload_1"/> </form> <input type="button" onclick="press_this();"/> <form action="test.php" method="POST" id="form2" enctype="multipart/form-data"> </form> --------------------------------------- If you select a file, and then press the button, the selected file is gone in the element. Scenario 2 (works in neither): <script type="text/javascript"> function press_this () { var f = document.getElementById('upload_1'); var f2 = f.cloneNode(true); document.getElementById('form2').appendChild(f2); } </script> <form action="test.php" method="POST" enctype="multipart/form-data"> <input type="file" name="upload" id="upload_1"/> </form> <input type="button" onclick="press_this();"/> <form action="test.php" method="POST" id="form2" enctype="multipart/form-data"> </form> -------------------------------- The selected value is not copied with cloneNode() in either Safari or the Webkit nightly. Confirming the first case as a regression (->P1). The second case is somewhat more questionable, since IE 7 also doesn't clone the file input value. It's likely that we will need to discuss it separately, may I ask you to file a new bug for it? (In reply to comment #3) > The second case is somewhat more questionable, since IE 7 also doesn't clone > the file input value. It's likely that we will need to discuss it separately, > may I ask you to file a new bug for it? See Bug 12279. (In reply to comment #4) > (In reply to comment #3) > > The second case is somewhat more questionable, since IE 7 also doesn't clone > > the file input value. It's likely that we will need to discuss it separately, > > may I ask you to file a new bug for it? > See Bug 12279. Bah! See Bug 12285 instead. Created attachment 12474 [details]
scenario 1 as mentioned below
Looking with the DOM inspector shows that the file input value is there after removing and appending. It's just not being displayed. I think if you upload the form you'll see the same thing. So retitling the bug for the actual symptom. Created attachment 12475 [details]
patch with change log
*** Bug 12285 has been marked as a duplicate of this bug. *** Comment on attachment 12475 [details]
patch with change log
Amusing:
- * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006, 2007 Apple Inc.
[...]
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
Comment on attachment 12475 [details]
patch with change log
+ private instead, and made a coupld function members const.
Typo: "coupld"
r=me. Thanks for cleaning this up!
Added keyword to make this easier to find. Thank you for all your hard work! Is a regression test possible for this patch? (In reply to comment #14) > Is a regression test possible for this patch? Not without adding something to WebCore and/or DumpRenderTree. For security reasons, you can't set an <input type=file> from JavaScript. Committed revision 19035. |