mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-06-11 01:25:53 -04:00
Merge pull request #2253 from navidemad/fix-requestsubmit-default-submitter
Fix SubmitEvent.submitter for requestSubmit() with no argument
This commit is contained in:
@@ -3701,7 +3701,15 @@ pub fn submitForm(self: *Frame, submitter_: ?*Element, form_: ?*Element.Html.For
|
||||
};
|
||||
|
||||
if (submit_opts.fire_event) {
|
||||
const submitter_html: ?*HtmlElement = if (submitter_) |s| s.is(HtmlElement) else null;
|
||||
// Per HTML spec "submit a form element" algorithm: SubmitEvent.submitter
|
||||
// must be null when the submitter is the form itself, which is what
|
||||
// Form.requestSubmit() passes when called with no submitter argument.
|
||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-form-submit
|
||||
const submitter_html: ?*HtmlElement = blk: {
|
||||
const s = submitter_ orelse break :blk null;
|
||||
if (s == form_element) break :blk null;
|
||||
break :blk s.is(HtmlElement);
|
||||
};
|
||||
const submit_event = (try SubmitEvent.initTrusted(comptime .wrap("submit"), .{ .bubbles = true, .cancelable = true, .submitter = submitter_html }, self)).asEvent();
|
||||
|
||||
// so submit_event is still valid when we check _prevent_default
|
||||
|
||||
@@ -485,12 +485,13 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Test: requestSubmit() without submitter sets submitter to the form element -->
|
||||
<!-- Test: requestSubmit() without submitter sets SubmitEvent.submitter to null
|
||||
per the HTML spec "submit a form element" algorithm step 4. -->
|
||||
<form id="test_form_submitter2" action="/should-not-navigate7" method="get">
|
||||
<input type="text" name="q" value="test">
|
||||
</form>
|
||||
|
||||
<script id="requestSubmit_default_submitter_is_form">
|
||||
<script id="requestSubmit_default_submitter_is_null">
|
||||
{
|
||||
const form = $('#test_form_submitter2');
|
||||
let capturedSubmitter = undefined;
|
||||
@@ -501,7 +502,7 @@
|
||||
});
|
||||
|
||||
form.requestSubmit();
|
||||
testing.expectEqual(form, capturedSubmitter);
|
||||
testing.expectEqual(null, capturedSubmitter);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user