Use optional chaining in web/pdf_history.js
Since we're now free to use e.g. optional chaining everywhere *except* for the worker, we can thus simplify this code a bit.
This commit is contained in:
parent
911948c5c0
commit
322b1072af
@ -290,7 +290,7 @@ class PDFHistory {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._destination && this._destination.page === pageNumber) {
|
if (this._destination?.page === pageNumber) {
|
||||||
// When the new page is identical to the one in `this._destination`, we
|
// When the new page is identical to the one in `this._destination`, we
|
||||||
// don't want to add a potential duplicate entry in the browser history.
|
// don't want to add a potential duplicate entry in the browser history.
|
||||||
return;
|
return;
|
||||||
@ -388,8 +388,7 @@ class PDFHistory {
|
|||||||
if (
|
if (
|
||||||
typeof PDFJSDev !== "undefined" &&
|
typeof PDFJSDev !== "undefined" &&
|
||||||
PDFJSDev.test("CHROME") &&
|
PDFJSDev.test("CHROME") &&
|
||||||
window.history.state &&
|
window.history.state?.chromecomState
|
||||||
window.history.state.chromecomState
|
|
||||||
) {
|
) {
|
||||||
// history.state.chromecomState is managed by chromecom.js.
|
// history.state.chromecomState is managed by chromecom.js.
|
||||||
newState.chromecomState = window.history.state.chromecomState;
|
newState.chromecomState = window.history.state.chromecomState;
|
||||||
@ -397,7 +396,7 @@ class PDFHistory {
|
|||||||
this._updateInternalState(destination, newState.uid);
|
this._updateInternalState(destination, newState.uid);
|
||||||
|
|
||||||
let newUrl;
|
let newUrl;
|
||||||
if (this._updateUrl && destination && destination.hash) {
|
if (this._updateUrl && destination?.hash) {
|
||||||
const baseUrl = document.location.href.split("#")[0];
|
const baseUrl = document.location.href.split("#")[0];
|
||||||
// Prevent errors in Firefox.
|
// Prevent errors in Firefox.
|
||||||
if (!baseUrl.startsWith("file://")) {
|
if (!baseUrl.startsWith("file://")) {
|
||||||
@ -494,7 +493,7 @@ class PDFHistory {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const [perfEntry] = performance.getEntriesByType("navigation");
|
const [perfEntry] = performance.getEntriesByType("navigation");
|
||||||
if (!perfEntry || perfEntry.type !== "reload") {
|
if (perfEntry?.type !== "reload") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -523,7 +522,7 @@ class PDFHistory {
|
|||||||
clearTimeout(this._updateViewareaTimeout);
|
clearTimeout(this._updateViewareaTimeout);
|
||||||
this._updateViewareaTimeout = null;
|
this._updateViewareaTimeout = null;
|
||||||
}
|
}
|
||||||
if (removeTemporary && destination && destination.temporary) {
|
if (removeTemporary && destination?.temporary) {
|
||||||
// When the `destination` comes from the browser history,
|
// When the `destination` comes from the browser history,
|
||||||
// we no longer treat it as a *temporary* position.
|
// we no longer treat it as a *temporary* position.
|
||||||
delete destination.temporary;
|
delete destination.temporary;
|
||||||
@ -633,8 +632,7 @@ class PDFHistory {
|
|||||||
if (
|
if (
|
||||||
(typeof PDFJSDev !== "undefined" &&
|
(typeof PDFJSDev !== "undefined" &&
|
||||||
PDFJSDev.test("CHROME") &&
|
PDFJSDev.test("CHROME") &&
|
||||||
state &&
|
state?.chromecomState &&
|
||||||
state.chromecomState &&
|
|
||||||
!this._isValidState(state)) ||
|
!this._isValidState(state)) ||
|
||||||
!state
|
!state
|
||||||
) {
|
) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user