From ffc607ad1caf4683a63e405c609a9c48b2ce418e Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Sat, 19 Aug 2023 22:46:42 +0100 Subject: :sparkle: Concat multiple class attributes on an element. --- lib/src/runtime.ffi.mjs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'lib/src') 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; } -- cgit v1.2.3