Open
Bug 1298669
Opened 9 years ago
Updated 3 years ago
innerText doesn't consider <p> tags to be linebreaks when used with synthetic documents
Categories
(Core :: DOM: Core & HTML, defect, P3)
Core
DOM: Core & HTML
Tracking
()
NEW
People
(Reporter: manishearth, Unassigned)
Details
Attachments
(2 files, 3 obsolete files)
If you have some elements separated by <p> tags, innerText on their container will show those tags as linebreaks. This is correct -- innerText is supposed to be what you get when the user selects and copies the node.
However, if this same thing happens in a synthetically constructed Document (i.e, via `xhr.responseType = "document"`), these linebreaks disappear.
For the attached testcase, Chrome behaves the same way firefox does. But for more complex cases like the `syntaxbox` element in https://developer.mozilla.org/en-US/docs/Web/CSS/clip-path, Chrome includes some line breaks, and Firefox strips all of them out (when fetched).
Not sure if this is a bug at all, though.
Updated•8 years ago
|
Priority: -- → P3
Updated•8 years ago
|
Assignee: nobody → jdai
Flags: needinfo?(jdai)
Comment 2•8 years ago
|
||
Manish, could you provide a simple testcase to reproduce the issue?
Flags: needinfo?(manishearth)
| Reporter | ||
Updated•8 years ago
|
Attachment #8785681 -
Attachment mime type: text/plain → text/html
Flags: needinfo?(manishearth)
| Reporter | ||
Comment 3•8 years ago
|
||
The attached testcase works already? It fetches itself over XHR and compares the innerText of the current and fetched document.
Comment 4•8 years ago
|
||
(In reply to Manish Goregaokar [:manishearth] from comment #3)
> The attached testcase works already? It fetches itself over XHR and compares
> the innerText of the current and fetched document.
Yes, I tweaked your testcase a little bit and it works on the first case, it shows "Fetched innerText: abc" both in chrome and firefox.
However, I had a hard time to reproduce the second one, which is
> But for more complex cases like the `syntaxbox` element in
> https://developer.mozilla.org/en-US/docs/Web/CSS/clip-path,
> Chrome includes some line breaks, and Firefox strips all of them out (when fetched).
Hence, could you provide a simple testcase to reproduce this issue? Thank you.
Attachment #8785681 -
Attachment is obsolete: true
Updated•8 years ago
|
Flags: needinfo?(manishearth)
| Reporter | ||
Comment 5•8 years ago
|
||
Running
`xhr = new XMLHttpRequest(); xhr.responseType="document"; xhr.open("GET", ""); xhr.send(null); xhr.onloadend = function() {console.log("Remote: " + xhr.response.querySelector('pre.syntaxbox').innerText)}; console.log("Local: " + document.querySelector('pre.syntaxbox').innerText)`
in the console for https://developer.mozilla.org/en-US/docs/Web/CSS/clip-path works and shows the discrepancy.
Not yet sure how to reduce that testcase, will look at later.
Flags: needinfo?(manishearth)
Comment 6•8 years ago
|
||
(In reply to Manish Goregaokar [:manishearth] from comment #5)
> Running
>
> `xhr = new XMLHttpRequest(); xhr.responseType="document"; xhr.open("GET",
> ""); xhr.send(null); xhr.onloadend = function() {console.log("Remote: " +
> xhr.response.querySelector('pre.syntaxbox').innerText)}; console.log("Local:
> " + document.querySelector('pre.syntaxbox').innerText)`
>
> in the console for
> https://developer.mozilla.org/en-US/docs/Web/CSS/clip-path works and shows
> the discrepancy.
>
>
> Not yet sure how to reduce that testcase, will look at later.
If you can give me whole piece of html test file that would be nice. After I looked at your comment, I can't figure out 'pre.syntaxbox'.
Comment 7•8 years ago
|
||
Hi :manishearth,
It's just a gentle ping, could you upload your test file? Thank you.
Flags: needinfo?(manishearth)
| Reporter | ||
Comment 8•8 years ago
|
||
Flags: needinfo?(manishearth)
| Reporter | ||
Updated•8 years ago
|
Attachment #8829745 -
Attachment mime type: text/plain → text/html
| Reporter | ||
Comment 9•8 years ago
|
||
Attachment #8829745 -
Attachment is obsolete: true
| Reporter | ||
Comment 10•8 years ago
|
||
It seems to happen with <br> tags inside <p> tags.
Both Chrome and Firefox output
> Local: line 1
> line 2
>
> line 3
but for Remote Chrome outputs
> Remote: line 1
> line 2line 3
and Firefox outputs
> Remote: line 1 line 2line 3
Both are wrong, though Firefox strips out both <br> and <p> whereas Chrome only strips out <p>
Attachment #8829746 -
Attachment is obsolete: true
Updated•7 years ago
|
Assignee: jdai → nobody
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•