diff --git a/src/display/display_utils.js b/src/display/display_utils.js index 0a9c5e4db..2d48082ad 100644 --- a/src/display/display_utils.js +++ b/src/display/display_utils.js @@ -992,7 +992,7 @@ function renderRichText({ html, dir, className }, container) { intent: "richText", }); } - fragment.firstChild.classList.add("richText", className); + fragment.firstElementChild.classList.add("richText", className); container.append(fragment); } diff --git a/src/display/draw_layer.js b/src/display/draw_layer.js index 3c763f443..61994012a 100644 --- a/src/display/draw_layer.js +++ b/src/display/draw_layer.js @@ -208,8 +208,8 @@ class DrawLayer { } } if (path) { - const defs = element.firstChild; - const pathElement = defs.firstChild; + const defs = element.firstElementChild; + const pathElement = defs.firstElementChild; this.#updateProperties(pathElement, path); } } diff --git a/src/display/editor/color_picker.js b/src/display/editor/color_picker.js index 53dab57d2..e7561516b 100644 --- a/src/display/editor/color_picker.js +++ b/src/display/editor/color_picker.js @@ -183,7 +183,7 @@ class ColorPicker { return; } if (event.target === this.#button) { - this.#dropdown.firstChild?.focus(); + this.#dropdown.firstElementChild?.focus(); return; } event.target.nextSibling?.focus(); @@ -191,7 +191,7 @@ class ColorPicker { _moveToPrevious(event) { if ( - event.target === this.#dropdown?.firstChild || + event.target === this.#dropdown?.firstElementChild || event.target === this.#button ) { if (this.#isDropdownVisible) { @@ -210,7 +210,7 @@ class ColorPicker { this.#openDropdown(event); return; } - this.#dropdown.firstChild?.focus(); + this.#dropdown.firstElementChild?.focus(); } _moveToEnd(event) { @@ -218,7 +218,7 @@ class ColorPicker { this.#openDropdown(event); return; } - this.#dropdown.lastChild?.focus(); + this.#dropdown.lastElementChild?.focus(); } #keyDown(event) { diff --git a/src/display/editor/editor.js b/src/display/editor/editor.js index 084fa34f1..043873e6d 100644 --- a/src/display/editor/editor.js +++ b/src/display/editor/editor.js @@ -2051,11 +2051,13 @@ class AnnotationEditor { // on the top-left one. if (nextFirstPosition < firstPosition) { for (let i = 0; i < firstPosition - nextFirstPosition; i++) { - this.#resizersDiv.append(this.#resizersDiv.firstChild); + this.#resizersDiv.append(this.#resizersDiv.firstElementChild); } } else if (nextFirstPosition > firstPosition) { for (let i = 0; i < nextFirstPosition - firstPosition; i++) { - this.#resizersDiv.firstChild.before(this.#resizersDiv.lastChild); + this.#resizersDiv.firstElementChild.before( + this.#resizersDiv.lastElementChild + ); } } @@ -2069,7 +2071,7 @@ class AnnotationEditor { this.#setResizerTabIndex(0); this.#isResizerEnabledForKeyboard = true; - this.#resizersDiv.firstChild.focus({ focusVisible: true }); + this.#resizersDiv.firstElementChild.focus({ focusVisible: true }); event.preventDefault(); event.stopImmediatePropagation(); } @@ -2397,12 +2399,12 @@ class AnnotationEditor { } resetAnnotationElement(annotation) { - const { firstChild } = annotation.container; + const { firstElementChild } = annotation.container; if ( - firstChild?.nodeName === "DIV" && - firstChild.classList.contains("annotationContent") + firstElementChild?.nodeName === "DIV" && + firstElementChild.classList.contains("annotationContent") ) { - firstChild.remove(); + firstElementChild.remove(); } } } diff --git a/web/comment_manager.js b/web/comment_manager.js index eaff727bd..98c6deae1 100644 --- a/web/comment_manager.js +++ b/web/comment_manager.js @@ -392,8 +392,8 @@ class CommentSidebar { return; } - this.#setDate(element.firstChild, modificationDate || creationDate); - this.#setText(element.lastChild, richText, contentsObj); + this.#setDate(element.firstElementChild, modificationDate || creationDate); + this.#setText(element.lastElementChild, richText, contentsObj); this.#annotations.splice(index, 1); index = binarySearchFirstItem( diff --git a/web/new_alt_text_manager.js b/web/new_alt_text_manager.js index d9554b779..546056f0b 100644 --- a/web/new_alt_text_manager.js +++ b/web/new_alt_text_manager.js @@ -444,7 +444,7 @@ class NewAltTextManager { } #close() { - const canvas = this.#imagePreview.firstChild; + const canvas = this.#imagePreview.firstElementChild; canvas.remove(); canvas.width = canvas.height = 0; this.#imageData = null; @@ -619,7 +619,7 @@ class ImageAltTextSettings { async #download(isFromUI = false) { if (isFromUI) { this.#downloadModelButton.disabled = true; - const span = this.#downloadModelButton.firstChild; + const span = this.#downloadModelButton.firstElementChild; span.setAttribute( "data-l10n-id", "pdfjs-editor-alt-text-settings-downloading-model-button"