Bug Tracker

Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#795 closed bug (fixed)

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

Change History (2)

comment:1 Changed 14 years ago by andrea

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>

comment:2 Changed 14 years ago by john

Resolution: fixed
Status: newclosed

I've fixed this in SVN.

Note: See TracTickets for help on using tickets.