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:
commit
be2dfe45f9
5 changed files with 13 additions and 9 deletions
|
@ -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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue