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;
|
||||
}
|
||||
|
||||
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
|
||||
// don't want to add a potential duplicate entry in the browser history.
|
||||
return;
|
||||
@ -388,8 +388,7 @@ class PDFHistory {
|
||||
if (
|
||||
typeof PDFJSDev !== "undefined" &&
|
||||
PDFJSDev.test("CHROME") &&
|
||||
window.history.state &&
|
||||
window.history.state.chromecomState
|
||||
window.history.state?.chromecomState
|
||||
) {
|
||||
// history.state.chromecomState is managed by chromecom.js.
|
||||
newState.chromecomState = window.history.state.chromecomState;
|
||||
@ -397,7 +396,7 @@ class PDFHistory {
|
||||
this._updateInternalState(destination, newState.uid);
|
||||
|
||||
let newUrl;
|
||||
if (this._updateUrl && destination && destination.hash) {
|
||||
if (this._updateUrl && destination?.hash) {
|
||||
const baseUrl = document.location.href.split("#")[0];
|
||||
// Prevent errors in Firefox.
|
||||
if (!baseUrl.startsWith("file://")) {
|
||||
@ -494,7 +493,7 @@ class PDFHistory {
|
||||
return false;
|
||||
}
|
||||
const [perfEntry] = performance.getEntriesByType("navigation");
|
||||
if (!perfEntry || perfEntry.type !== "reload") {
|
||||
if (perfEntry?.type !== "reload") {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@ -523,7 +522,7 @@ class PDFHistory {
|
||||
clearTimeout(this._updateViewareaTimeout);
|
||||
this._updateViewareaTimeout = null;
|
||||
}
|
||||
if (removeTemporary && destination && destination.temporary) {
|
||||
if (removeTemporary && destination?.temporary) {
|
||||
// When the `destination` comes from the browser history,
|
||||
// we no longer treat it as a *temporary* position.
|
||||
delete destination.temporary;
|
||||
@ -633,8 +632,7 @@ class PDFHistory {
|
||||
if (
|
||||
(typeof PDFJSDev !== "undefined" &&
|
||||
PDFJSDev.test("CHROME") &&
|
||||
state &&
|
||||
state.chromecomState &&
|
||||
state?.chromecomState &&
|
||||
!this._isValidState(state)) ||
|
||||
!state
|
||||
) {
|
||||
|
Loading…
Reference in New Issue
Block a user