diff options
author | Hayleigh Thompson <me@hayleigh.dev> | 2023-08-19 22:46:42 +0100 |
---|---|---|
committer | Hayleigh Thompson <me@hayleigh.dev> | 2023-08-19 22:46:42 +0100 |
commit | ffc607ad1caf4683a63e405c609a9c48b2ce418e (patch) | |
tree | 509e9502d86a1426a70ead3df3c3f5783af02c2d | |
parent | 8d05b2dea4afc46a03dc12e26d7b37d45140eaf9 (diff) | |
download | lustre-ffc607ad1caf4683a63e405c609a9c48b2ce418e.tar.gz lustre-ffc607ad1caf4683a63e405c609a9c48b2ce418e.zip |
:sparkle: Concat multiple class attributes on an element.
-rw-r--r-- | lib/src/runtime.ffi.mjs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/src/runtime.ffi.mjs b/lib/src/runtime.ffi.mjs index 7325583..36b6f4a 100644 --- a/lib/src/runtime.ffi.mjs +++ b/lib/src/runtime.ffi.mjs @@ -45,7 +45,12 @@ function createElement(prev, curr, ns, parent = null) { let attr = curr[1]; while (attr.head) { - morphAttr(el, attr.head[0], attr.head[1]); + morphAttr( + el, + attr.head[0], + attr.head[0] === "class" ? `${el.className}{attr.head[1]}` : attr.head[1] + ); + attr = attr.tail; } @@ -86,7 +91,13 @@ function morphElement(prev, curr, ns, parent) { let currAttr = curr[1]; while (currAttr.head) { - currAttrs.set(currAttr.head[0], currAttr.head[1]); + currAttrs.set( + currAttr.head[0], + currAttr.head[0] === "class" + ? `${prev.className} {currAttr.head[1]}` + : currAttr.head[1] + ); + currAttr = currAttr.tail; } |