Don't use firstChild/lastChild when getting elements (follow-up of #20447)
This commit is contained in:
parent
b41959bde8
commit
029cae2ad4
@ -992,7 +992,7 @@ function renderRichText({ html, dir, className }, container) {
|
|||||||
intent: "richText",
|
intent: "richText",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
fragment.firstChild.classList.add("richText", className);
|
fragment.firstElementChild.classList.add("richText", className);
|
||||||
container.append(fragment);
|
container.append(fragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -208,8 +208,8 @@ class DrawLayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (path) {
|
if (path) {
|
||||||
const defs = element.firstChild;
|
const defs = element.firstElementChild;
|
||||||
const pathElement = defs.firstChild;
|
const pathElement = defs.firstElementChild;
|
||||||
this.#updateProperties(pathElement, path);
|
this.#updateProperties(pathElement, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -183,7 +183,7 @@ class ColorPicker {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.target === this.#button) {
|
if (event.target === this.#button) {
|
||||||
this.#dropdown.firstChild?.focus();
|
this.#dropdown.firstElementChild?.focus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.target.nextSibling?.focus();
|
event.target.nextSibling?.focus();
|
||||||
@ -191,7 +191,7 @@ class ColorPicker {
|
|||||||
|
|
||||||
_moveToPrevious(event) {
|
_moveToPrevious(event) {
|
||||||
if (
|
if (
|
||||||
event.target === this.#dropdown?.firstChild ||
|
event.target === this.#dropdown?.firstElementChild ||
|
||||||
event.target === this.#button
|
event.target === this.#button
|
||||||
) {
|
) {
|
||||||
if (this.#isDropdownVisible) {
|
if (this.#isDropdownVisible) {
|
||||||
@ -210,7 +210,7 @@ class ColorPicker {
|
|||||||
this.#openDropdown(event);
|
this.#openDropdown(event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.#dropdown.firstChild?.focus();
|
this.#dropdown.firstElementChild?.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
_moveToEnd(event) {
|
_moveToEnd(event) {
|
||||||
@ -218,7 +218,7 @@ class ColorPicker {
|
|||||||
this.#openDropdown(event);
|
this.#openDropdown(event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.#dropdown.lastChild?.focus();
|
this.#dropdown.lastElementChild?.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
#keyDown(event) {
|
#keyDown(event) {
|
||||||
|
|||||||
@ -2051,11 +2051,13 @@ class AnnotationEditor {
|
|||||||
// on the top-left one.
|
// on the top-left one.
|
||||||
if (nextFirstPosition < firstPosition) {
|
if (nextFirstPosition < firstPosition) {
|
||||||
for (let i = 0; i < firstPosition - nextFirstPosition; i++) {
|
for (let i = 0; i < firstPosition - nextFirstPosition; i++) {
|
||||||
this.#resizersDiv.append(this.#resizersDiv.firstChild);
|
this.#resizersDiv.append(this.#resizersDiv.firstElementChild);
|
||||||
}
|
}
|
||||||
} else if (nextFirstPosition > firstPosition) {
|
} else if (nextFirstPosition > firstPosition) {
|
||||||
for (let i = 0; i < nextFirstPosition - firstPosition; i++) {
|
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.#setResizerTabIndex(0);
|
||||||
this.#isResizerEnabledForKeyboard = true;
|
this.#isResizerEnabledForKeyboard = true;
|
||||||
this.#resizersDiv.firstChild.focus({ focusVisible: true });
|
this.#resizersDiv.firstElementChild.focus({ focusVisible: true });
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopImmediatePropagation();
|
event.stopImmediatePropagation();
|
||||||
}
|
}
|
||||||
@ -2397,12 +2399,12 @@ class AnnotationEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resetAnnotationElement(annotation) {
|
resetAnnotationElement(annotation) {
|
||||||
const { firstChild } = annotation.container;
|
const { firstElementChild } = annotation.container;
|
||||||
if (
|
if (
|
||||||
firstChild?.nodeName === "DIV" &&
|
firstElementChild?.nodeName === "DIV" &&
|
||||||
firstChild.classList.contains("annotationContent")
|
firstElementChild.classList.contains("annotationContent")
|
||||||
) {
|
) {
|
||||||
firstChild.remove();
|
firstElementChild.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -392,8 +392,8 @@ class CommentSidebar {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#setDate(element.firstChild, modificationDate || creationDate);
|
this.#setDate(element.firstElementChild, modificationDate || creationDate);
|
||||||
this.#setText(element.lastChild, richText, contentsObj);
|
this.#setText(element.lastElementChild, richText, contentsObj);
|
||||||
|
|
||||||
this.#annotations.splice(index, 1);
|
this.#annotations.splice(index, 1);
|
||||||
index = binarySearchFirstItem(
|
index = binarySearchFirstItem(
|
||||||
|
|||||||
@ -444,7 +444,7 @@ class NewAltTextManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#close() {
|
#close() {
|
||||||
const canvas = this.#imagePreview.firstChild;
|
const canvas = this.#imagePreview.firstElementChild;
|
||||||
canvas.remove();
|
canvas.remove();
|
||||||
canvas.width = canvas.height = 0;
|
canvas.width = canvas.height = 0;
|
||||||
this.#imageData = null;
|
this.#imageData = null;
|
||||||
@ -619,7 +619,7 @@ class ImageAltTextSettings {
|
|||||||
async #download(isFromUI = false) {
|
async #download(isFromUI = false) {
|
||||||
if (isFromUI) {
|
if (isFromUI) {
|
||||||
this.#downloadModelButton.disabled = true;
|
this.#downloadModelButton.disabled = true;
|
||||||
const span = this.#downloadModelButton.firstChild;
|
const span = this.#downloadModelButton.firstElementChild;
|
||||||
span.setAttribute(
|
span.setAttribute(
|
||||||
"data-l10n-id",
|
"data-l10n-id",
|
||||||
"pdfjs-editor-alt-text-settings-downloading-model-button"
|
"pdfjs-editor-alt-text-settings-downloading-model-button"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user