diff --git a/lib/History.js b/lib/History.js index fa57c03..318b5c5 100644 --- a/lib/History.js +++ b/lib/History.js @@ -114,11 +114,20 @@ function renderOptions(e, path) { var query = [] for (var i = 0, len = elements.length, el; i < len; i++) { el = elements[i] - var name = el.name - if (!name) continue + + // Skip elements that shouldn't be posted. + // Taken from $.fieldValue() in https://github.com/malsup/form/blob/4bbb64/jquery.form.js#L1043-L1048 + // See http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2 + var n = el.name, t = el.type, tag = el.tagName.toLowerCase(); + if (!n || el.disabled || t == 'reset' || t == 'button' || + (t == 'checkbox' || t == 'radio') && !el.checked || + (t == 'submit' || t == 'image') || // && el.form && el.form.clk != el || // We don't know what element triggered the submission + tag == 'select' && el.selectedIndex == -1) + continue; + var value = el.value - query.push(encodeURIComponent(name) + '=' + encodeURIComponent(value)) - if (name === '_method') { + query.push(encodeURIComponent(n) + '=' + encodeURIComponent(value)) + if (n === '_method') { var override = value.toLowerCase() if (override === 'delete') override = 'del' }