diff options
-rw-r--r-- | lib/src/runtime.ffi.mjs | 9 |
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] ); |