Open Bug 153436 Opened 23 years ago Updated 3 years ago

request for a function like cloneNode, but includes expandos and value

Categories

(Core :: DOM: Core & HTML, enhancement, P5)

x86
All
enhancement

Tracking

()

People

(Reporter: mozbugs, Unassigned)

Details

I guess this is the same as Bug 50533, except I don't want cloneNode to do something that has been decided that it shouldn't do, but instead, I want a new dom function or even an cloneNode( true, true ) call, that would copy over, for example, the current value in a text box, and other expandos properties newly attached...
This wouldn't be core...
Component: DOM Core → DOM Mozilla Extensions
QA Contact: desale → lchiang
confirming rfe
Status: UNCONFIRMED → NEW
Ever confirmed: true
QA Contact: lchiang → ian
Mass-reassigning bugs to dom_bugs@netscape.com
Assignee: jst → dom_bugs
I have a problem with the cloneNode and I belive that this is the "bug", though I thought it was a bug and not a rfe. I will make an example to reproduce the "bug"... please tell me if the two bugs isn't the same. <div id="paragraphs"> <div> <input name="paragraph[]" value="1" /> <textarea name="text[]">text1</textarea> </div> </div> !! All text nodes have to be removed to make the example work !! Making it look like this: <div id="paragraphs"><div><input name="paragraph[]" value="1" /><textarea name="text[]">text1</textarea></div></div> Now I alter the value of the input field where the value is "1" to the value "new value" in my browser. Then i run the javascript: var paragraphs = document.getElementById('paragraphs'); var paragraph1 = paragraphs.childNodes[0]; alert(paragraph1.childNodes[0].value); var paragraph2 = paragraph1.cloneNode(true); alert(paragraph2.childNodes[0].value); The first alert prints "new value" The second alert prints "1" I don't get it I would assume that it would either print "1" both times or print "new value" both times?!?!
There are a few script variables that don't exactly map to DOM attributes. In this case DOM.value => obj.defaultValue another example is DOM.class => obj.className The distinction between the HTML markup in DOM-world and the living object in Script-world is well explained in http://groups.google.com/groups?selm=39ABF5E7.BF5864A6%40netscape.com so, inserting (after initial paragraph1 assignment) paragraph1.childNodes[0].defaultValue = 2; affects both the DOM and the living object 'value' (paragraph2.childNodes[0].value will be 2 and paragraph1.childNodes[0].value will update to 2 because nothing else set it) and, inserting paragraph1.childNodes[0].value = 10; paragraph1.childNodes[0].defaultValue = 2; has the first line only affecting the living object while the second line only affects DOM 'value' because the obj.value is set (paragraph2.childNodes[0].value will be 2, but paragraph1.childNodes[0].value is still 10)
Assignee: general → nobody
QA Contact: ian → general
Component: DOM: Mozilla Extensions → DOM
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046 Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5. If you have questions, please contact :mdaly.
Priority: -- → P5
Component: DOM → DOM: Core & HTML
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.