mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Use optional chaining, where possible, in the web/
-folder
By using optional chaining, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining, it's possible to reduce unnecessary code-repetition in many cases.
This commit is contained in:
parent
dc19965d78
commit
063a072742
11 changed files with 27 additions and 32 deletions
|
@ -787,7 +787,7 @@ function dispatchDOMEvent(eventName, args = null) {
|
|||
throw new Error("Not implemented: dispatchDOMEvent");
|
||||
}
|
||||
const details = Object.create(null);
|
||||
if (args && args.length > 0) {
|
||||
if (args?.length > 0) {
|
||||
const obj = args[0];
|
||||
for (const key in obj) {
|
||||
const value = obj[key];
|
||||
|
@ -1022,7 +1022,7 @@ function getActiveOrFocusedElement() {
|
|||
let curActiveOrFocused =
|
||||
curRoot.activeElement || curRoot.querySelector(":focus");
|
||||
|
||||
while (curActiveOrFocused && curActiveOrFocused.shadowRoot) {
|
||||
while (curActiveOrFocused?.shadowRoot) {
|
||||
curRoot = curActiveOrFocused.shadowRoot;
|
||||
curActiveOrFocused =
|
||||
curRoot.activeElement || curRoot.querySelector(":focus");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue