mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-06-11 01:25:53 -04:00
Form Submitter should only override when it's a submit input
This commit is contained in:
@@ -3806,9 +3806,14 @@ pub fn submitForm(self: *Frame, submitter_: ?*Element, form_: ?*Element.Html.For
|
||||
|
||||
const form_element = form.asElement();
|
||||
|
||||
const submit_button: ?*Element = blk: {
|
||||
const s = submitter_ orelse break :blk null;
|
||||
break :blk if (Element.Html.Form.isSubmitButton(s)) s else null;
|
||||
};
|
||||
|
||||
const target_name_: ?[]const u8 = blk: {
|
||||
if (submitter_) |submitter| {
|
||||
if (submitter.getAttributeSafe(comptime .wrap("formtarget"))) |ft| {
|
||||
if (submit_button) |s| {
|
||||
if (s.getAttributeSafe(comptime .wrap("formtarget"))) |ft| {
|
||||
break :blk ft;
|
||||
}
|
||||
}
|
||||
@@ -3862,13 +3867,13 @@ pub fn submitForm(self: *Frame, submitter_: ?*Element, form_: ?*Element.Html.For
|
||||
// form's corresponding attributes (matching how formtarget is honored above).
|
||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-form-submit
|
||||
const enctype_attr = blk: {
|
||||
if (submitter_) |s| {
|
||||
if (submit_button) |s| {
|
||||
if (s.getAttributeSafe(comptime .wrap("formenctype"))) |fe| break :blk fe;
|
||||
}
|
||||
break :blk form_element.getAttributeSafe(comptime .wrap("enctype"));
|
||||
};
|
||||
const method = blk: {
|
||||
if (submitter_) |s| {
|
||||
if (submit_button) |s| {
|
||||
if (s.getAttributeSafe(comptime .wrap("formmethod"))) |fm| break :blk fm;
|
||||
}
|
||||
break :blk form_element.getAttributeSafe(comptime .wrap("method")) orelse "";
|
||||
@@ -3908,7 +3913,7 @@ pub fn submitForm(self: *Frame, submitter_: ?*Element, form_: ?*Element.Html.For
|
||||
try form_data.write(.{ .encoding = encoding, .charset = charset, .allocator = arena }, &buf.writer);
|
||||
|
||||
var action = blk: {
|
||||
if (submitter_) |s| {
|
||||
if (submit_button) |s| {
|
||||
if (s.getAttributeSafe(comptime .wrap("formaction"))) |fa| break :blk fa;
|
||||
}
|
||||
break :blk form_element.getAttributeSafe(comptime .wrap("action")) orelse self.url;
|
||||
|
||||
@@ -148,7 +148,7 @@ pub fn requestSubmit(self: *Form, submitter: ?*Element, frame: *Frame) !void {
|
||||
/// Returns true if the element is a submit button per the HTML spec:
|
||||
/// - <input type="submit"> or <input type="image">
|
||||
/// - <button type="submit"> (including default, since button's default type is "submit")
|
||||
fn isSubmitButton(element: *Element) bool {
|
||||
pub fn isSubmitButton(element: *Element) bool {
|
||||
if (element.is(Input)) |input| {
|
||||
return input._input_type == .submit or input._input_type == .image;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user