aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHayleigh Thompson <me@hayleigh.dev>2023-08-20 07:46:44 +0100
committerHayleigh Thompson <me@hayleigh.dev>2023-08-20 07:46:44 +0100
commita72f92af11d8226522f7a1b6a6273caf1978d1c8 (patch)
tree438f7067418c893f6011d1f956e3ab070243ebe5
parentfddee047ca9dc855f6591b33ab9bd520068d93fa (diff)
downloadlustre-a72f92af11d8226522f7a1b6a6273caf1978d1c8.tar.gz
lustre-a72f92af11d8226522f7a1b6a6273caf1978d1c8.zip
:recycle: Tweak class concat code to avoid leading whitespace.
-rw-r--r--lib/src/runtime.ffi.mjs9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/src/runtime.ffi.mjs b/lib/src/runtime.ffi.mjs
index 1d25d6f..3fc0d91 100644
--- a/lib/src/runtime.ffi.mjs
+++ b/lib/src/runtime.ffi.mjs
@@ -43,7 +43,9 @@ function createElement(prev, curr, ns, parent = null) {
morphAttr(
el,
attr.head[0],
- attr.head[0] === "class" ? `${el.className}{attr.head[1]}` : attr.head[1]
+ attr.head[0] === "class" && el.className
+ ? `${el.className} ${attr.head[1]}`
+ : attr.head[1]
);
attr = attr.tail;
@@ -77,6 +79,7 @@ function createElement(prev, curr, ns, parent = null) {
if (prev) prev.replaceWith(el);
}
+
return el;
}
@@ -88,8 +91,8 @@ function morphElement(prev, curr, ns, parent) {
while (currAttr.head) {
currAttrs.set(
currAttr.head[0],
- currAttr.head[0] === "class"
- ? `${prev.className} {currAttr.head[1]}`
+ currAttr.head[0] === "class" && prev.className
+ ? `${prev.className} ${currAttr.head[1]}`
: currAttr.head[1]
);