mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
LibWeb: Allow FormData entry list to be mutated within a FormDataEvent
Previously, the list was copied when constructing the FormData object, then the original list was passed to the event, meaning any changes to the list that happened within the event would not be reflected outside of it.
This commit is contained in:
committed by
Andreas Kling
parent
4cb19c65b4
commit
ea0e434d1d
Notes:
github-actions[bot]
2024-11-21 19:26:21 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/ea0e434d1d6 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2480
19
Tests/LibWeb/Text/input/HTML/form-add-dynamic-formdata.html
Normal file
19
Tests/LibWeb/Text/input/HTML/form-add-dynamic-formdata.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<form id="test-form">
|
||||
<input type="text" name="field1" value="value1">
|
||||
</form>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
const form = document.getElementById('test-form');
|
||||
|
||||
form.addEventListener('formdata', (event) => {
|
||||
event.formData.append('field2', 'value2');
|
||||
});
|
||||
|
||||
const formData = new FormData(form);
|
||||
|
||||
println(`formData.get('field1') === 'value1': ${formData.get('field1') === 'value1'}`);
|
||||
println(`formData.get('field2') === 'value2': ${formData.get('field2') === 'value2'}`);
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user