Skip to content

Commit

Permalink
Try translating "next"/"previous" links to history commands
Browse files Browse the repository at this point in the history
  • Loading branch information
fakedrake committed May 17, 2017
1 parent 5f329c4 commit 26918b6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions common/content/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,19 @@ const Buffer = Module("buffer", {
let elem = res.snapshotItem(i);
if (regex.test(elem.textContent) || regex.test(elem.title) ||
Array.some(elem.childNodes, function (child) regex.test(child.alt))) {
if (elem.href
&& typeof history.session[history.session.index - 1] !== "undefined"
&& history.session[history.session.index - 1].URI.spec === elem.href) {
history.stepTo(-1);
return true;
}
if (elem.href
&& typeof history.session[history.session.index + 1] !== "undefined"
&& history.session[history.session.index + 1].URI.spec === elem.href) {
history.stepTo(1);
return true;
}

buffer.followLink(elem, liberator.CURRENT_TAB);
return true;
}
Expand Down

0 comments on commit 26918b6

Please sign in to comment.