Fix parsing values of option elements in forms (#162)

* Fix a bug where the value of <option> would not get sent if falsy

According to the spec, the value attribute should be sent if it
exists, even if it's falsy.

* Don't send an <option> tag if it's disabled, even if it's selected
This commit was merged in pull request #162.
This commit is contained in:
BehindTheMath
2018-05-30 15:39:08 -04:00
committed by GitHub
parent 8dbe7553b9
commit 8abb21e1e9

View File

@@ -67,8 +67,8 @@ function parseFormElements(el) {
for (var i = 0; i < element.options.length; i++) { for (var i = 0; i < element.options.length; i++) {
opt = element.options[i] opt = element.options[i]
if (opt.selected) { if (opt.selected && !opt.disabled) {
values.push(opt.value || opt.text) values.push(opt.hasAttribute("value") ? opt.value : opt.text)
} }
} }
} }