1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #15035 from Snuffleupagus/prefer-modern-dom-apis-2

Use modern DOM methods a bit more (PR 15031 follow-up)
This commit is contained in:
Jonas Jenwald 2022-06-17 19:37:43 +02:00 committed by GitHub
commit be2dfe45f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 9 deletions

View file

@ -1507,7 +1507,7 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
noneOptionElement.value = " ";
noneOptionElement.setAttribute("hidden", true);
noneOptionElement.setAttribute("selected", true);
selectElement.insertBefore(noneOptionElement, selectElement.firstChild);
selectElement.prepend(noneOptionElement);
removeEmptyEntry = () => {
noneOptionElement.remove();
@ -1581,13 +1581,16 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
},
insert(event) {
const { index, displayValue, exportValue } = event.detail.insert;
const selectChild = selectElement.children[index];
const optionElement = document.createElement("option");
optionElement.textContent = displayValue;
optionElement.value = exportValue;
selectElement.insertBefore(
optionElement,
selectElement.children[index]
);
if (selectChild) {
selectChild.before(optionElement);
} else {
selectElement.append(optionElement);
}
storage.setValue(id, {
value: getValue(event, /* isExport */ true),
items: getItems(event),