Skip to main content

Bug Tracker

Side navigation

#795 closed bug (fixed)

Opened January 12, 2007 11:26PM UTC

Closed January 14, 2007 09:51PM UTC

Last modified June 19, 2007 08:48AM UTC

WEIRD new lines in PRE in IE7

Reported by: Andrea Ercolino Owned by:
Priority: major Milestone: 1.1
Component: core Version: 1.1
Keywords: text pre Cc:
Blocked by: Blocking:
Description

Trying Rev.1043 with Chili, it works as expected in FF, but not in IE.

WEIRD new lines appear in $('pre > code').text() They are weird because a newline each two disappears, with a pattern like this:

a
bb
ccc

becomes

abb
ccc
Attachments (0)
Change History (2)

Changed January 13, 2007 07:00AM UTC by andrea comment:1

The problem is related to the fact that Rev.1043.text() uses innerText in IE and it seems to return text with all the newLines stripped off.

DEMO (Rev.1043.text renamed text2):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> new document </title>
<script type="text/javascript" src="jquery-1.0.4.pack.js"></script>

<script language="javascript">
function jQuery.fn.text2(e) {
	var type = this.length && this[0].innerText == undefined ?
		"textContent" : "innerText";
		
	return e == undefined ?
		jQuery.map(this, function(a){ return a[ type ]; }).join('') :
		this.each(function(){ this[ type ] = e; });
}
</script>
</head>

<body>
<pre><code>
a
bb
ccc
dddd
eeeee
</code></pre>

<script language="javascript">
var $test = $( "pre > code" );
alert( '$test.text()

' + $test.text() );
alert( '$test.text2()

' + $test.text2() );
</script>
</body>
</html>

Changed January 14, 2007 09:51PM UTC by john comment:2

resolution: → fixed
status: newclosed

I've fixed this in SVN.