innerHTML returns extraneous newline characters for long content

RESOLVED WORKSFORME

Status

()

RESOLVED WORKSFORME
14 years ago
13 years ago

People

(Reporter: aduncan, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

14 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4

the innerHTML attribute returns a string that contains newlines not present in
the  HTML source. The extra newline characters only seem to appear on longer
strings.

Reproducible: Always

Steps to Reproduce:
paste this into an HTML document and click on the paragraphs (there should be no
newlines between each set of paragraph tags, so if this form adds them, take
them out)
<p onclick="alert(this.innerHTML + '\ncontains newline: ' +
(this.innerHTML.indexOf('\n') != -1));">1 2 3 4 5 6 7 8 910 1 2 3 4 5 6 7 8 920 </p>
<p onclick="alert(this.innerHTML + '\ncontains newline: ' +
(this.innerHTML.indexOf('\n') != -1));">1 2 3 4 5 6 7 8 910 1 2 3 4 5 6 7 8 920
1 2 3 4 5 6 7 8 930 1 2 3 4 5 6 7 8 940 </p>
<p onclick="alert(this.innerHTML + '\ncontains newline: ' +
(this.innerHTML.indexOf('\n') != -1));">1 2 3 4 5 6 7 8 910 1 2 3 4 5 6 7 8 920
1 2 3 4 5 6 7 8 930 1 2 3 4 5 6 7 8 940 1 2 3 4 5 6 7 8 950 1 2 3 4 5 6 7 8 960
1 2 3 4 5 6 7 8 970</p>


Actual Results:  
the third paragraph, when clicked will wrap as follows:

1 2 3 4 5 6 7 8 910 1 2 3 4 5 6 7 8 920 1 2 3 4 5 6 7 8 930 1 2 3 4 5 6
7 8 940 1 2 3 4 5 6 7 8 950 1 2 3 4 5 6 7 8 960 1 2 3 4 5 6 7 8 970

and the .search function will return an index for a newline character

Expected Results:  
The innerHTML string should not have contained any newline characters at all.
Any wrapping in the display should only have been a "soft" wrap.
Created attachment 186584 [details]
tescase

now with all characters on 1 line
if the line wraps there is no newline detected

Comment 3

13 years ago
fixed in ff trunk, can't find bug to dupe to, so wfm
Status: UNCONFIRMED → RESOLVED
Last Resolved: 13 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.