Node.textContent() incorrectly serializes <br> into CR

RESOLVED INVALID

Status

()

Core
Serializers
RESOLVED INVALID
10 years ago
10 years ago

People

(Reporter: glazou, Unassigned)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

10 years ago
if |node| is a HTML paragraph with the following content model:

  <p>foo<br>bar</p>

the result of |node.textContent()| is "foo\nbar".
Given the DOM Level 3 Core prose available in http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-textContent , we have two options here :

1. <br> is really a special element and the user really wants to see the presence of that <br> reflected in textContent()'s output ; the spec is then underspecified and feedback to W3C is needed...

2. the spec is correct and nothing in the spec says <br> should be given a special behaviour. According to the prose, the textContent()'s value of <br> element is the empty string. So the result of |node.textContent()| above should be "foobar". The "\n" is here because we get the textContent of a given node through a text/plain nsIDocumentEncoder and that beast of course returns a CR for a <br> element... See |nsNode3Tearoff::GetTextContent|.
(Reporter)

Comment 1

10 years ago
sorry for spam, please read |textContent| and not |textContent()|, it's an attribute, not a method.
What version of gecko are you seeing this in. I thought we fixed this a long time ago.

If you're still seeing this please attach a testcase.
(Reporter)

Comment 3

10 years ago
Created attachment 323876 [details]
test case, see the alert containing the textContent of the paragraph

(In reply to comment #2)
> What version of gecko are you seeing this in. I thought we fixed this a long
> time ago.
> 
> If you're still seeing this please attach a testcase.

Well, I am using a fresh nightly... Gecko/2008060407 Minefield/3.0pre
See the attached test case.
(Reporter)

Comment 4

10 years ago
sigh, nevermind, the CR in the source code after the <br> is a typo, was not supposed to be here. Sorry for that.
Status: NEW → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.