| 86 | } |
| 87 | |
| 88 | private static handleFormValues( |
| 89 | clone: HTMLElement, |
| 90 | copyValues: boolean |
| 91 | ): void { |
| 92 | if (!copyValues) return |
| 93 | |
| 94 | clone |
| 95 | .querySelectorAll("input, select, textarea") |
| 96 | .forEach((field: HTMLElement) => { |
| 97 | if (field instanceof HTMLInputElement) { |
| 98 | if (field.type === "radio" || field.type === "checkbox") { |
| 99 | if (field.checked) { |
| 100 | field.setAttribute("checked", "checked") |
| 101 | } |
| 102 | } else { |
| 103 | field.setAttribute("value", field.value) |
| 104 | } |
| 105 | } else if (field instanceof HTMLSelectElement) { |
| 106 | Array.from(field.options).forEach((option) => { |
| 107 | if (option.selected) { |
| 108 | option.setAttribute("selected", "selected") |
| 109 | } |
| 110 | }) |
| 111 | } else if (field instanceof HTMLTextAreaElement) { |
| 112 | field.textContent = field.value |
| 113 | } |
| 114 | }) |
| 115 | } |
| 116 | |
| 117 | private static addExtraContent( |
| 118 | clone: HTMLElement, |