Skip to content

Commit

Permalink
FormData should not contain an entry for the submitter (#27439)
Browse files Browse the repository at this point in the history
FormData should not contain an entry for the submit button that was used to submit the form.
  • Loading branch information
rwlbuis committed Feb 2, 2021
1 parent b55988f commit c134161
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions html/semantics/forms/the-form-element/form-requestsubmit.html
Expand Up @@ -173,4 +173,24 @@
}));
}, 'The value of the submitter should be appended, and form* ' +
'attributes of the submitter should be handled.');

test(() => {
document.body.insertAdjacentHTML('afterbegin', `<form>
<input name="n1" value="v1">
<button type="submit" name="n2" value="v2"></button>
</form>
<form id="form2"></form>`);
let form = document.querySelector('form');
let formDataInEvent = null;
let submitter = form.querySelector('button[type=submit]');
form.addEventListener('submit', e => {
e.preventDefault();
formDataInEvent = new FormData(e.target);
});

form.requestSubmit(submitter);
assert_equals(formDataInEvent.get('n1'), 'v1');
assert_false(formDataInEvent.has('n2'));
}, 'The constructed FormData object should not contain an entry for the submit button that was used to submit the form.');

</script>

0 comments on commit c134161

Please sign in to comment.