Current section

26 Versions

Jump to

Compare versions

4 files changed
+24 additions
-8 deletions
  @@ -1,12 +1,20 @@
1 1 "use strict";
2 2
3 + import SubmitEvent from "./submit_event.mjs";
3 4 import Type from "../type.mjs";
4 5
5 6 export default class ChangeEvent {
6 7 static buildOperationParam(event) {
7 8 const target = event.target;
8 - const type = target.type;
9 9 const tagName = target.tagName;
10 +
11 + // Check if this is a form-level change event by examining currentTarget
12 + if (event.currentTarget.tagName === "FORM") {
13 + const formEvent = {target: event.currentTarget};
14 + return SubmitEvent.buildOperationParam(formEvent);
15 + }
16 +
17 + const type = target.type;
10 18 let value;
11 19
12 20 if (tagName === "INPUT" && (type === "checkbox" || type === "radio")) {
  @@ -4,12 +4,20 @@ import Type from "../type.mjs";
4 4
5 5 export default class SubmitEvent {
6 6 static buildOperationParam(event) {
7 - const formData = new FormData(event.target);
7 + const form = event.target;
8 + const formData = new FormData(form);
8 9
9 - const mapData = [...formData.entries()].map(([name, value]) => [
10 - Type.bitstring(name),
11 - Type.bitstring(value),
12 - ]);
10 + const mapData = [...formData.entries()].map(([name, value]) => {
11 + const element = form.elements[name];
12 +
13 + if (element.tagName === "INPUT" && element.type === "checkbox") {
14 + // Note: FormData only includes checked checkboxes
15 + // Since this element appears in FormData, it means it's checked
16 + return [Type.bitstring(name), Type.boolean(true)];
17 + }
18 +
19 + return [Type.bitstring(name), Type.bitstring(value)];
20 + });
13 21
14 22 return Type.map(mapData);
15 23 }
  @@ -7,7 +7,7 @@
7 7 {<<"Sponsor">>,<<"https://github.com/sponsors/bartblast">>},
8 8 {<<"Website">>,<<"https://hologram.page">>}]}.
9 9 {<<"name">>,<<"hologram">>}.
10 - {<<"version">>,<<"0.6.1">>}.
10 + {<<"version">>,<<"0.6.2">>}.
11 11 {<<"description">>,
12 12 <<"Full stack isomorphic Elixir web framework that can be used on top of Phoenix.">>}.
13 13 {<<"elixir">>,<<"~> 1.0">>}.
  @@ -2,7 +2,7 @@
2 2 defmodule Hologram.MixProject do
3 3 use Mix.Project
4 4
5 - @version "0.6.1"
5 + @version "0.6.2"
6 6
7 7 # Copied from Hologram.Commons.SystemUtils
8 8 @windows_exec_suffixes [".bat", ".cmd", ".exe"]