Use the getText utility function provided by Sizzle.
authorJohn Resig <jeresig@gmail.com>
Mon, 7 Dec 2009 01:47:41 +0000 (17:47 -0800)
committerJohn Resig <jeresig@gmail.com>
Mon, 7 Dec 2009 01:47:41 +0000 (17:47 -0800)
src/manipulation.js
src/sizzle-jquery.js

index 9103111..a8cb484 100644 (file)
@@ -36,20 +36,7 @@ jQuery.fn.extend({
                        return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
                }
 
-               var ret = "";
-
-               jQuery.each( this, function() {
-                       // Get the text from text nodes and CDATA nodes
-                       if ( this.nodeType === 3 || this.nodeType === 4 ) {
-                               ret += this.nodeValue;
-
-                       // Traverse everything else, except comment nodes
-                       } else if ( this.nodeType !== 8 ) {
-                               ret += jQuery.fn.text.call( this.childNodes );
-                       }
-               });
-
-               return ret;
+               return jQuery.getText( this );
        },
 
        wrapAll: function( html ) {
index 6f2c86f..3d15128 100644 (file)
@@ -2,5 +2,6 @@ jQuery.find = Sizzle;
 jQuery.expr = Sizzle.selectors;
 jQuery.expr[":"] = jQuery.expr.filters;
 jQuery.unique = Sizzle.uniqueSort;
+jQuery.getText = getText;
 
 return;