Commit 696864ea authored by Regis's avatar Regis

remove need for complex regex in pagination - add else if

parent be3e32f5
...@@ -26,16 +26,23 @@ ...@@ -26,16 +26,23 @@
const text = e.target.innerText; const text = e.target.innerText;
const { totalPages, nextPage, previousPage } = this.pageInfo; const { totalPages, nextPage, previousPage } = this.pageInfo;
if (text === SPREAD) return;
/** /**
the regex here is to read if the string coming in will become a valid number the regex here is to read if the string coming in will become a valid number
had issues with parsing using `+` because `typeof NaN === 'number'` had issues with parsing using `+` because `typeof NaN === 'number'`
*/ */
if (/^-?[\d.]+(?:e-?\d+)?$/.test(text)) pagenum = +text; if (text === SPREAD) {
if (text === LAST) pagenum = totalPages; return;
if (text === NEXT) pagenum = nextPage; } else if (text === LAST) {
if (text === PREV) pagenum = previousPage; pagenum = totalPages;
if (text === FIRST) pagenum = 1; } else if (text === NEXT) {
pagenum = nextPage;
} else if (text === PREV) {
pagenum = previousPage;
} else if (text === FIRST) {
pagenum = 1;
} else {
pagenum = +text;
}
this.change(pagenum, apiScope); this.change(pagenum, apiScope);
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment