Fix #280 and #271 by being more careful about how we iterate over node lists in case they're live

pull/282/head
Gijs Kruitbosch 8 years ago
parent c3c91a739b
commit 71a0b32e41

@ -155,7 +155,15 @@ Readability.prototype = {
* @return void
*/
_forEachNode: function(nodeList, fn) {
return Array.prototype.forEach.call(nodeList, fn, this);
var i = 0;
while (nodeList[i]) {
var el = nodeList[i];
fn.call(this, el, i, nodeList);
// Only increment i if the element is still in the list:
if (nodeList[i] == el) {
i++
}
}
},
/**

Loading…
Cancel
Save