Closed Bug 271081 Opened 20 years ago Closed 20 years ago

some form elements cloned by cloneNode() revert to their original values

Categories

(Firefox :: General, defect)

PowerPC
macOS
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 230307

People

(Reporter: bugzilla, Assigned: bugzilla)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0

When a textarea or select field is cloned through cloneNode(), the value reverts
back to the original one set in the HTML. This affects only textareas, not text
inputs.

The loss happens at the cloning stage - if the value is set just after the
clone, but before the clone is inserted back into the document, it works fine.

This bug /might/ be a related to Bug 107342, but seems to be fundamentally
different - the values are being reverted, not lost.

Reproducible: Always
Steps to Reproduce:
1. clone a textarea or select field
Small error in the above report - it affects both textareas and select fields,
but not other input types.
The cause of this behavior seems to be that for most input types the value is stored as an attribute, but 
for textareas and select fields the values are stored in child elements.

When a textarea is first parsed, the value attribute is taken from the child text-node's text. If the value 
is changed by typing new text or through javascript, the textarea's value attribute is updated but not 
the child text-node. When a new copy is made through cloneNode(), the value is taken from the 
template's child text-node, not the value attribute.

Is this behavior in fact the result of Firefox correctly implementing HTML/DOM?

I can think of two fixes:
1. Cloned textareas could take their value from the template's value not the child text node.
2. Updating a textarea could update the child text node too.

*** This bug has been marked as a duplicate of 230307 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: