From 4260b20d4f1752521188bbeef89efbf0a2ccd030 Mon Sep 17 00:00:00 2001 From: Cyril Fluck Date: Mon, 23 Jan 2012 16:53:41 -0800 Subject: [PATCH 1/2] getText respects unbreakable whitespace on IE This is a regression from jQuery 1.6.4. --- sizzle.js | 4 ++-- test/index.html | 1 + test/unit/selector.js | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/sizzle.js b/sizzle.js index b175e102..9124da03 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 ).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"; From 9bae960aca172e8d29d05df64d0977a14a5f2f1a Mon Sep 17 00:00:00 2001 From: Cyril Fluck Date: Tue, 24 Jan 2012 11:21:37 -0800 Subject: [PATCH 2/2] fix bug leading to infinite loop --- sizzle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sizzle.js b/sizzle.js index 9124da03..c497b492 100644 --- a/sizzle.js +++ b/sizzle.js @@ -344,7 +344,7 @@ var getText = Sizzle.getText = function( elem ) { return elem.textContent; } else if ( typeof elem.innerText === 'string' ) { // Replace IE's carriage returns - return getText( elem ).replace( rReturn, '' ); + return getText( elem.childNodes ).replace( rReturn, '' ); } else { // Traverse it's children for ( elem = elem.firstChild; elem; elem = elem.nextSibling) {