Merge pull request #1315 from ealmloff/handle-select-elements

Handle oninput for select elements
This commit is contained in:
Jonathan Kelley 2023-09-16 11:56:18 -07:00 committed by GitHub
commit de649a46d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -446,15 +446,24 @@ function handler(event, name, bubbles, config) {
target.tagName === "FORM" &&
(event.type === "submit" || event.type === "input")
) {
if (
target.tagName === "FORM" &&
(event.type === "submit" || event.type === "input")
) {
const formData = new FormData(target);
const formData = new FormData(target);
for (let name of formData.keys()) {
let value = formData.getAll(name);
contents.values[name] = value;
for (let name of formData.keys()) {
let value = formData.getAll(name);
contents.values[name] = value;
}
}
if (
target.tagName === "SELECT" &&
event.type === "input"
) {
const selectData = target.options;
contents.values["options"] = [];
for (let i = 0; i < selectData.length; i++) {
let option = selectData[i];
if (option.selected) {
contents.values["options"].push(option.value.toString());
}
}
}