Escape on stuck code

Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
James Ketr 2018-09-04 20:12:07 -07:00
parent 436524f036
commit 59bbde7e7d

View File

@ -350,18 +350,19 @@
} }
var pos = this.checkPosition(index), last = -1; var pos = this.checkPosition(index), last = -1;
while (pos != 0 && last != pos) { while (pos != 0 && last != index) {
last = index; /* safety escape in case the DOM changed and nothing matches */
if (pos == +1) { /* Checked item was too low on the page, so look closer to start */ if (pos == +1) { /* Checked item was too low on the page, so look closer to start */
index = index >> 1; index = index >> 1;
} else { /* Checked item was too high on the page, so look farther */ } else { /* Checked item was too high on the page, so look farther */
index += (length - index) >> 1; index += (length - index) >> 1;
} }
last = index; /* safety escape in case the DOM changed and nothing matches */
pos = this.checkPosition(index); pos = this.checkPosition(index);
} }
if (pos == last) { if (pos != 0) {
console.log("DOM changed or viewport changed and search would never exit; re-scheduling check") console.log("DOM changed or viewport changed and search would never exit; re-scheduling check")
//this.triggerVisibilityChecks(); //this.triggerVisibilityChecks();
return; return;