diff --git a/sizzle.js b/sizzle.js index b175e102..c497b492 100644 --- a/sizzle.js +++ b/sizzle.js @@ -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) { diff --git a/test/index.html b/test/index.html index 829311d5..bf424d6e 100644 --- a/test/index.html +++ b/test/index.html @@ -220,6 +220,7 @@

+
Test   This
fadeIn
fadeIn
diff --git a/test/unit/selector.js b/test/unit/selector.js index a1f464f1..cf23fb2f 100644 --- a/test/unit/selector.js +++ b/test/unit/selector.js @@ -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";