Skip to content

Commit c856d2d

Browse files
author
Ronan Giron
committed
Fix scope of variable in case of multi instance
1 parent e1f7684 commit c856d2d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/next-handler.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import $ from 'tealight';
22

3-
let lastResponse = document;
4-
let nextUrl;
5-
63
export function nextHandler(pageIndex) {
4+
if (!this.lastResponse) {
5+
this.lastResponse = document;
6+
}
7+
let nextUrl;
78
let ias = this;
89

9-
let nextEl = $(ias.options.next, lastResponse)[0];
10+
let nextEl = $(ias.options.next, this.lastResponse)[0];
1011

1112
if (!nextEl) {
1213
return;
@@ -16,9 +17,9 @@ export function nextHandler(pageIndex) {
1617

1718
return ias.load(nextUrl)
1819
.then((data) => {
19-
lastResponse = data.xhr.response;
20+
this.lastResponse = data.xhr.response;
2021

21-
let nextEl = $(ias.options.next, lastResponse)[0];
22+
let nextEl = $(ias.options.next, this.lastResponse)[0];
2223

2324
return ias.append(data.items)
2425
.then(() => {

0 commit comments

Comments
 (0)