Fix link normalization for live HTMLCollections

Newer versions of JSDOM implement getElementsByTagName correctly.
This means it returns a live node list. When calling
`Element.replaceChild` for links inside the loop over that
collection, elements disappear from the list, meaning we miss
every other item. Without this fix, the `clean-links` testcase
breaks.
pull/509/head
Gijs Kruitbosch 6 years ago committed by Gijs
parent e8bb7f722f
commit 977be42d1f

@ -321,7 +321,7 @@ Readability.prototype = {
return uri;
}
var links = articleContent.getElementsByTagName("a");
var links = this._getAllNodesWithTag(articleContent, ["a"]);
this._forEachNode(links, function(link) {
var href = link.getAttribute("href");
if (href) {
@ -336,7 +336,7 @@ Readability.prototype = {
}
});
var imgs = articleContent.getElementsByTagName("img");
var imgs = this._getAllNodesWithTag(articleContent, ["img"]);
this._forEachNode(imgs, function(img) {
var src = img.getAttribute("src");
if (src) {

Loading…
Cancel
Save