getText respects unbreakable whitespace on IE #91

Closed
wants to merge 2 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+7 −3
Diff settings

Always

Just for now

View
@@ -339,12 +339,12 @@ var getText = Sizzle.getText = function( elem ) {
if ( nodeType ) {
if ( nodeType === 1 || nodeType === 9 ) {
- // Use textContent || innerText for elements
+ // Use textContent for elements
if ( typeof elem.textContent === 'string' ) {
return elem.textContent;
} else if ( typeof elem.innerText === 'string' ) {
// Replace IE's carriage returns
- return elem.innerText.replace( rReturn, '' );
+ return getText( elem.childNodes ).replace( rReturn, '' );
} else {
// Traverse it's children
for ( elem = elem.firstChild; elem; elem = elem.nextSibling) {
View
@@ -220,6 +220,7 @@ <h2 id="qunit-userAgent"></h2>
</div>
</div>
</dl>
+ <div id="whitespace" style="position:absolute;width:1px;height:1px;overflow:hidden;">Test &nbsp; This</div>
<div id="fx-test-group" style="position:absolute;width:1px;height:1px;overflow:hidden;">
<div id="fx-queue" name="test">
<div id="fadein" class='chain test' name='div'>fadeIn<div>fadeIn</div></div>
View
@@ -406,7 +406,7 @@ test("pseudo - child", function() {
});
test("pseudo - misc", function() {
- expect(19);
+ expect(20);
t( "Headers", ":header", ["qunit-header", "qunit-banner", "qunit-userAgent"] );
t( "Has Children - :has()", "p:has(a)", ["firstp","ap","en","sap"] );
@@ -436,6 +436,9 @@ test("pseudo - misc", function() {
document.body.removeChild( tmp );
+ var whitespace = document.getElementById("whitespace");
+ equal( Sizzle.getText( whitespace ), 'Test ' + String.fromCharCode(160) + ' This' );
+
var input = document.createElement("input");
input.type = "text";
input.id = "focus-input";