Skip to content

Commit

Permalink
Rename _nextElement to solve Issue#629 (mozilla#637)
Browse files Browse the repository at this point in the history
* Renamed _nextElement to _nextNode

* Update docs to reflect changes made
  • Loading branch information
ankushduacodes authored Nov 4, 2020
1 parent 22cff05 commit 60af91f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Readability.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,11 +548,11 @@ Readability.prototype = {
},

/**
* Finds the next element, starting from the given node, and ignoring
* Finds the next node, starting from the given node, and ignoring
* whitespace in between. If the given node is an element, the same node is
* returned.
*/
_nextElement: function (node) {
_nextNode: function (node) {
var next = node;
while (next
&& (next.nodeType != this.ELEMENT_NODE)
Expand All @@ -577,10 +577,10 @@ Readability.prototype = {
// <p> block.
var replaced = false;

// If we find a <br> chain, remove the <br>s until we hit another element
// If we find a <br> chain, remove the <br>s until we hit another node
// or non-whitespace. This leaves behind the first <br> in the chain
// (which will be replaced with a <p> later).
while ((next = this._nextElement(next)) && (next.tagName == "BR")) {
while ((next = this._nextNode(next)) && (next.tagName == "BR")) {
replaced = true;
var brSibling = next.nextSibling;
next.parentNode.removeChild(next);
Expand All @@ -598,7 +598,7 @@ Readability.prototype = {
while (next) {
// If we've hit another <br><br>, we're done adding children to this <p>.
if (next.tagName == "BR") {
var nextElem = this._nextElement(next.nextSibling);
var nextElem = this._nextNode(next.nextSibling);
if (nextElem && nextElem.tagName == "BR")
break;
}
Expand Down Expand Up @@ -736,7 +736,7 @@ Readability.prototype = {
});

this._forEachNode(this._getAllNodesWithTag(articleContent, ["br"]), function(br) {
var next = this._nextElement(br.nextSibling);
var next = this._nextNode(br.nextSibling);
if (next && next.tagName == "P")
br.parentNode.removeChild(br);
});
Expand Down

0 comments on commit 60af91f

Please sign in to comment.