Bug Tracker

Opened 9 years ago

Last modified 7 years ago

#6863 closed enhancement

faster getText — at Initial Version

Reported by: steida Owned by:
Priority: blocker Milestone: 1.7
Component: selector Version: 1.4.2
Keywords: speed, getText, 1.7-discuss Cc:
Blocked by: Blocking:

Description

var getText = function (elem) {

var text = []; for (var node = elem.firstChild; node; node = node.nextSibling) {

Get the text from text nodes and CDATA nodes

if (node.nodeType == 3
node.nodeType == 4)

text.push(node.nodeValue);

Traverse everything else, except comment nodes else if (elem.nodeType !== 8)

text.push(getText(node));

} return text.join();

};

Change History (0)

Note: See TracTickets for help on using tickets.