Testcase for jQuery Ticket 3144
by jitter
HTML
<div id="test">
<div>one</div>
<div> two </div>
</div>
<textarea id="output" rows="10" cols="50"></textarea>
<p>#Results</p>
<pre>
Opera 10.63
.text(): '{32}{10}{32}{32}{32}{32}one{32}{10}{32}{32}{32}{32}{32}two{32}{32}{10}' 22
.innerText: '{32}{10}{32}{32}{32}{32}one{32}{10}{32}{32}{32}{32}{32}two{32}{32}{10}' 22
.textContent: '{32}{10}{32}{32}{32}{32}one{32}{10}{32}{32}{32}{32}{32}two{32}{32}{10}' 22
IE6
.text(): 'onetwo{32}' 7
.innerText: 'one{13}{10}two{32}' 9
FF 3.6.12
.text(): '{32}{10}{32}{32}{32}{32}one{32}{10}{32}{32}{32}{32}{32}two{32}{32}{10}' 22
.textContent: '{32}{10}{32}{32}{32}{32}one{32}{10}{32}{32}{32}{32}{32}two{32}{32}{10}' 22
Chrome 6.0.something
.text(): '{32}{10}{32}{32}{32}{32}one{32}{10}{32}{32}{32}{32}{32}two{32}{32}{10}' 22
.innerText: 'one{10}two{10}' 8
.textContent: '{32}{10}{32}{32}{32}{32}one{32}{10}{32}{32}{32}{32}{32}two{32}{32}{10}' 22
Feel free to add more
</pre>
JavaScript
function check(m, s) {
if (s == null) return;
var r = "'";
for (var i = 0; i < s.length; i++) {
var c = s.charCodeAt(i);
r += c > 0x20 ? s.charAt(i) : "{" + c + "}";
}
$("#output").append(m + ": " + r + "' " + s.length + '\n');
}
var t = $("#test");
check(".text()", t.text());
check(".innerText", t[0].innerText);
check(".textContent", t[0].textContent);