aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHayleigh Thompson <me@hayleigh.dev>2024-03-25 23:33:46 +0000
committerHayleigh Thompson <me@hayleigh.dev>2024-03-25 23:33:46 +0000
commit01e81600d42d5510199ded74fd4f2c5bfb1aa4ab (patch)
tree6b9ffada42e698ed9333b7b57416bd508443c868
parenta590c6dbd267b2b1b9157fe5d5ac517059bd338f (diff)
downloadlustre-01e81600d42d5510199ded74fd4f2c5bfb1aa4ab.tar.gz
lustre-01e81600d42d5510199ded74fd4f2c5bfb1aa4ab.zip
:recycle: Additional data attached to server component events is moved to the 'data' property.
-rw-r--r--src/vdom.ffi.mjs33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/vdom.ffi.mjs b/src/vdom.ffi.mjs
index e090612..b9dc706 100644
--- a/src/vdom.ffi.mjs
+++ b/src/vdom.ffi.mjs
@@ -46,7 +46,7 @@ export function morph(prev, curr, dispatch, parent) {
"function should only be called internally by lustre's runtime: if you think",
"this is an error, please open an issue at",
"https://github.com/hayleigh-dot-dev/gleam-lustre/issues/new",
- ].join(" ")
+ ].join(" "),
);
}
@@ -190,7 +190,7 @@ function morphElement(prev, curr, dispatch, parent) {
) {
currAttrs.set(
currAttr[0],
- `${currAttrs.get("dangerous-unescaped-html")} ${currAttr[1]}`
+ `${currAttrs.get("dangerous-unescaped-html")} ${currAttr[1]}`,
);
} else if (currAttr[0] !== "") {
currAttrs.set(currAttr[0], currAttr[1]);
@@ -387,20 +387,23 @@ function serverEventHandler(event) {
return {
tag,
- data: include.reduce((data, property) => {
- const path = property.split(".");
-
- for (let i = 0, o = data, e = event; i < path.length; i++) {
- if (i === path.length - 1) {
- o[path[i]] = e[path[i]];
- } else {
- o[path[i]] ??= {};
- e = e[path[i]];
- o = o[path[i]];
+ data: include.reduce(
+ (data, property) => {
+ const path = property.split(".");
+
+ for (let i = 0, o = data, e = event; i < path.length; i++) {
+ if (i === path.length - 1) {
+ o[path[i]] = e[path[i]];
+ } else {
+ o[path[i]] ??= {};
+ e = e[path[i]];
+ o = o[path[i]];
+ }
}
- }
- return data;
- }, data),
+ return data;
+ },
+ { data },
+ ),
};
}