mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2026-04-12 11:07:23 +00:00
fix: refine pdfjs at compatibility polyfill
Agent-Logs-Url: https://github.com/kekingcn/kkFileView/sessions/287f0212-d368-4b59-ae70-0374fb3fe76f Co-authored-by: klboke <18591662+klboke@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
530304b832
commit
3fbf0156e2
@@ -21,11 +21,11 @@ function installAtPolyfill(target) {
|
|||||||
Object.defineProperty(target.prototype, "at", {
|
Object.defineProperty(target.prototype, "at", {
|
||||||
value(index) {
|
value(index) {
|
||||||
const length = this.length >>> 0;
|
const length = this.length >>> 0;
|
||||||
let relativeIndex = Number(index) || 0;
|
let relativeIndex = Number(index);
|
||||||
if (!Number.isFinite(relativeIndex)) {
|
if (Number.isNaN(relativeIndex)) {
|
||||||
relativeIndex = 0;
|
relativeIndex = 0;
|
||||||
}
|
}
|
||||||
relativeIndex = relativeIndex < 0 ? Math.ceil(relativeIndex) : Math.floor(relativeIndex);
|
relativeIndex = Math.trunc(relativeIndex);
|
||||||
const resolvedIndex = relativeIndex >= 0 ? relativeIndex : length + relativeIndex;
|
const resolvedIndex = relativeIndex >= 0 ? relativeIndex : length + relativeIndex;
|
||||||
if (resolvedIndex < 0 || resolvedIndex >= length) {
|
if (resolvedIndex < 0 || resolvedIndex >= length) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user