Closed
Bug 297968
Opened 20 years ago
Closed 20 years ago
innerHTML returns extraneous newline characters for long content
Categories
(Firefox :: General, defect)
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: aduncan, Unassigned)
Details
Attachments
(2 files)
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.
Comment 1•20 years ago
|
||
Comment 2•20 years ago
|
||
now with all characters on 1 line
if the line wraps there is no newline detected
Comment 3•20 years ago
|
||
fixed in ff trunk, can't find bug to dupe to, so wfm
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•