Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 6863; Use array.join() for string concatenation in getText() #59

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions sizzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -995,18 +995,21 @@ if ( document.documentElement.compareDocumentPosition ) {

// Utility function for retreiving the text value of an array of DOM nodes
Sizzle.getText = function( elems ) {
var ret = "", elem;
var nodeType = elems.nodeType,
ret = "";

for ( var i = 0; elems[i]; i++ ) {
elem = elems[i];

// Get the text from text nodes and CDATA nodes
if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
ret += elem.nodeValue;

// Traverse everything else, except comment nodes
} else if ( elem.nodeType !== 8 ) {
ret += Sizzle.getText( elem.childNodes );
// Get text from the array elements if this is not a node
if ( nodeType == null ) {
for ( var i = 0; elems[i]; i++ ) {
ret += Sizzle.getText( elems[i] );
}
// Get the text from text nodes and CDATA nodes
} else if ( nodeType === 3 || nodeType === 4 ) {
ret += elems.nodeValue;
// Traverse everything else, except comment nodes
} else if ( nodeType !== 8 ) {
for ( var node = elems.firstChild; node; node = node.nextSibling) {
ret += Sizzle.getText( node );
}
}

Expand Down