Skip to content
Permalink
Browse files

missing file changes

  • Loading branch information...
Simek committed Jul 20, 2015
1 parent 3816021 commit adfbf05970dd453753590e4ce418383fb01e1a57
Showing with 14 additions and 2 deletions.
  1. +14 −2 xpather.js
@@ -265,8 +265,13 @@ function getSafeOffset(node) {
return offsetTop < 150 ? 0 : offsetTop - 150;
}

function collectTextNodes(element, texts) {
for (var child = element.firstChild; child !== null; child = child.nextSibling) {
function simpleEscapeHTML(text) {
return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}

function collectTextNodes(node, texts) {
var child = node.firstChild;
for (child; child !== null; child = child.nextSibling) {
if (child.nodeType === 3) {
texts.push(child);
} else if (child.nodeType === 1) {
@@ -277,6 +282,13 @@ function collectTextNodes(element, texts) {

function getNodeText(node) {
var texts = [];
if (node.firstChild) {
collectTextNodes(node, texts);
for (var i = texts.length; i-- > 0;) {
texts[i] = simpleEscapeHTML(texts[i].data);
}
} else {
texts.push(node.textContent);
}
return $.trim(texts.join(' ').replace(/\s+/g, ' '));
}

0 comments on commit adfbf05

Please sign in to comment.
You can’t perform that action at this time.