Closed
Bug 197294
Opened 20 years ago
Closed 20 years ago
[FIXr]The value of a cloned <input> is lost
Categories
(Core :: DOM: Core & HTML, defect, P1)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla1.6beta
People
(Reporter: rbs, Assigned: bzbarsky)
References
Details
Attachments
(3 files)
683 bytes,
text/html
|
Details | |
1.31 KB,
text/html
|
Details | |
1.67 KB,
patch
|
jst
:
review+
jst
:
superreview+
|
Details | Diff | Splinter Review |
When an <input> node is cloned, whatever value was typed in is lost. The cloned <input> goes back to the initial default value. Will attach a simple testcase to demonstrate the problem.
![]() |
Assignee | |
Comment 3•20 years ago
|
||
Cloning clones the node and its attributes. IE incorrectly changes the "value" attribute of the DOM node as you type. So cloning "works" in IE. Mozilla does not change the attribute, so cloning loses the state....
Whiteboard: DUPEME
I was maiking a demo where some parameters get created on the fly, and then transferred to a set. Due to this bug, I am/was forced to stash the typed values into private attributes rather than relying on the typed values directly.
![]() |
Assignee | |
Comment 5•20 years ago
|
||
*** Bug 224938 has been marked as a duplicate of this bug. ***
Comment 6•20 years ago
|
||
According to the DOM level 1 HTML spec, value contains "The current form control value". I would also note that if I manually loop through all form elements and copy the values across by doing newElem.value = oldElem.value, this does work as expected, which is to say it copies the current value (this is my current workaround). I have to admit I'm confused as to why cloneNode should behave differently from direct assignment.
![]() |
Assignee | |
Comment 7•20 years ago
|
||
Note the difference between "value" and "defaultValue" in that spec. The latter corresponds to an attribute and hence is copied automatically. The former does not, so needs special attention. This is an explanation of why cloneNode acts as it does in Mozilla, not a statement that it should act that way.
![]() |
Assignee | |
Comment 8•20 years ago
|
||
![]() |
Assignee | |
Comment 9•20 years ago
|
||
![]() |
Assignee | |
Comment 10•20 years ago
|
||
Comment on attachment 134943 [details] [diff] [review] Possible patch jst, what do you think the behavior should be here? Also, what, if anything, should be done when a <textarea> is cloned?
Attachment #134943 -
Flags: superreview?(jst)
Attachment #134943 -
Flags: review?(jst)
Comment 11•20 years ago
|
||
Comment on attachment 134943 [details] [diff] [review] Possible patch + case NS_FORM_INPUT_TEXT: + case NS_FORM_INPUT_PASSWORD: + case NS_FORM_INPUT_FILE: + if (GET_BOOLBIT(mBitField, BF_VALUE_CHANGED)) { + // We don't have our default value anymore. Set our value on + // the clone. + nsAutoString value; + GetValue(value); + // SetValueInternal handles setting the VALUE_CHANGED bit for us + it->SetValueInternal(value, nsnull); + } Looks reasonable to me, but what about hidden inputs? Don't they need this too? r+sr=jst
Attachment #134943 -
Flags: superreview?(jst)
Attachment #134943 -
Flags: superreview+
Attachment #134943 -
Flags: review?(jst)
Attachment #134943 -
Flags: review+
![]() |
Assignee | |
Comment 12•20 years ago
|
||
For hidden inputs we currently map the value property to the value attribute...
![]() |
Assignee | |
Comment 13•20 years ago
|
||
Taking.
Assignee: john → bz-vacation
Priority: -- → P1
Summary: The value of a cloned <input> is lost → [FIXr]The value of a cloned <input> is lost
Whiteboard: DUPEME
Target Milestone: --- → mozilla1.6beta
![]() |
Assignee | |
Comment 14•20 years ago
|
||
Checked in.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Reporter | ||
Comment 15•19 years ago
|
||
<textarea> wasn't fixed and has been reported in bug 237783.
Blocks: 237783
You need to log in
before you can comment on or make changes to this bug.
Description
•