Closed Bug 295771 Opened 20 years ago Closed 20 years ago

textContent and whitespace

Categories

(Core :: DOM: Serializers, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 285830

People

(Reporter: devbits, Unassigned)

Details

User-Agent:       Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4

textContent on any DOM element (that has no child <br/> nodes) always returns 
a single string stripped of linefeeds and "ignorable" whitespace.
While this makes sense and is indeed the expected result for most HTML tags, a 
PRE by definition doesn't have any ignoreable whitespace, so stripping it is 
not conform with the DOM Level 3 specification that only ignorable whitespace 
is eligable to be stripped.

Reproducible: Always

Steps to Reproduce:
<span>This is some text
spread across multiple lines.</span>

<pre>This is some more text
spread across multiple lines.</pre>
Actual Results:  
span::textContent = "This is some text spread across multiple lines."

pre::textContent = "This is some more text spread across multiple lines."

Expected Results:  
span::textContent = "This is some text spread across multiple lines."

pre::textContent = "This is some more text\n spread across multiple lines."

*** This bug has been marked as a duplicate of 285830 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.