Closed Bug 152329 Opened 22 years ago Closed 19 years ago

Inserting a text node in a textarea displays the text twice

Categories

(Core :: Layout: Form Controls, defect, P2)

x86
Windows NT
defect

Tracking

()

RESOLVED FIXED
Future

People

(Reporter: ebourg, Assigned: mrbkap)

References

Details

(Keywords: testcase)

Attachments

(3 files)

Inserting a text node in a textarea displays the text twice. The text is
incorectly displayed on the first line and doesn't scroll on moving the slider.
-->
Assignee: rods → kin
I see this on Win XP branch build 2002061708
Status: UNCONFIRMED → NEW
Ever confirmed: true
José Jeria provided an interesting screenshot of this bug, see Attachment 109537 [details]
I can reproduce using (todays) 2003020604 build on WinXP.
Priority: -- → P2
Target Milestone: --- → Future
Keywords: testcase
I've created a bit more elaborate testcase.

What you can see is, is that if you do textarea.normalize() after you've
appended the textnode, the weird behavior disappears (not all the time, though)


Also, I have made methods to put a paragraph element or a textarea element into
the textarea. You can see how that affects the textarea and different
properties of it.
I think this is somehow related with bug 215228

IMHO:
- Textarea.innerHTML, textarea.childNodes[0].nodeValue, textarea.value and the
text you can see inside the textarea should always be the same.
- Objects generated with the DOM (textnodes, elements, whatever) should be
inserted as strings if they are inserted in the textarea.
- Textarea should never have more than one childNode (a textnode). Any attempts
(textarea.splitText or something like that) should be made undone.

A textarea may contain markup according to the w3c:
http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.7
But I don't know if that means, that markup inside a textarea should be
available via the DOM. I don't think it would be usefull for anything.
So the problem here is that we actually construct a frame for the textnode....
Perhaps we should not construct frames on dynamic changes if the parent frame
has the REPLACED_ELEMENT flag set?
Blocks: 86372
Blocks: 215228
Hmm.. i could have sworn we had an ancient bug for this but i can't find it. I
defenely remember it from when I fixed bug 17003 (amazing, i still remember that
bugnumber).

As I recall it the problem is that we create frames for all but the first
text-child of the textarea. I.e. it seemed like the nsCSSFrameConstructor just
skipped the first childnode of the textarea rather then all of them. That's why
normalize fixes the problem since all textnodes are combined into one.
Perhaps the real problem is that we construct frames for kids of a textarea at
all? Note bug 265367, eg.
Depends on: 265367
interestingly, it doesn't seem to happen for xhtml
(In reply to comment #7)
> IMHO:
> - Textarea.innerHTML, textarea.childNodes[0].nodeValue, textarea.value and the
> text you can see inside the textarea should always be the same.

No, the spec says otherwise. See bug 17003 comment 81.

> - Objects generated with the DOM (textnodes, elements, whatever) should be
> inserted as strings if they are inserted in the textarea.

Depends on what you mean by 'as strings'. If you insert a node like
<XXX>sometexthere</XXX>
into a textarea we should either insert the text 'sometexthere' or we should
ignore it compleatly, a good argument can be made for either. Right now I think
we ignore it compleatly.

> - Textarea should never have more than one childNode (a textnode). Any attempts
> (textarea.splitText or something like that) should be made undone.

Why? I defenetly don't agree. The DOM should allow for almost any change. How we
render it is something different though. At least that's how I recall the DOM spec.
Attached patch patch v1Splinter Review
This makes us not construct frames for explicit children of <textarea>.
Assignee: kinmoz → mrbkap
Status: NEW → ASSIGNED
Attachment #185698 - Flags: superreview?(bzbarsky)
Attachment #185698 - Flags: review?(bzbarsky)
Comment on attachment 185698 [details] [diff] [review]
patch v1

Fix the comment to mention <INPUT TYPE="text"> and TEXTAREA in both places, and
r+sr=bzbarsky
Attachment #185698 - Flags: superreview?(bzbarsky)
Attachment #185698 - Flags: superreview+
Attachment #185698 - Flags: review?(bzbarsky)
Attachment #185698 - Flags: review+
Comment on attachment 185698 [details] [diff] [review]
patch v1

More fixes to make <textarea>.innerHTML work correctly.
Attachment #185698 - Flags: approval1.8b3?
Attachment #185698 - Flags: approval1.8b3? → approval1.8b3+
Fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Blocks: 293162
Blocks: 292839
Blocks: 291019
Blocks: 296931
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: