Skip to content

Commit 820be06

Browse files
author
Ben Barber
committed
Bug 6863; Use array.join() for string concatenation in getText()
1 parent 4bcc097 commit 820be06

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

sizzle.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -995,22 +995,24 @@ if ( document.documentElement.compareDocumentPosition ) {
995995

996996
// Utility function for retreiving the text value of an array of DOM nodes
997997
Sizzle.getText = function( elems ) {
998-
var ret = "", elem;
998+
var elem, nodeType,
999+
ret = [];
9991000

10001001
for ( var i = 0; elems[i]; i++ ) {
10011002
elem = elems[i];
1003+
nodeType = elem.nodeType;
10021004

10031005
// Get the text from text nodes and CDATA nodes
1004-
if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
1005-
ret += elem.nodeValue;
1006+
if ( nodeType === 3 || nodeType === 4 ) {
1007+
ret[ ret.length ] = elem.nodeValue;
10061008

10071009
// Traverse everything else, except comment nodes
1008-
} else if ( elem.nodeType !== 8 ) {
1009-
ret += Sizzle.getText( elem.childNodes );
1010+
} else if ( nodeType !== 8 ) {
1011+
ret[ ret.length ] = Sizzle.getText( elem.childNodes );
10101012
}
10111013
}
10121014

1013-
return ret;
1015+
return ret.join( '' );
10141016
};
10151017

10161018
// Check to see if the browser returns elements by name when

0 commit comments

Comments
 (0)