diff --git a/packages/next-yak/runtime/__tests__/attrs.test.tsx b/packages/next-yak/runtime/__tests__/attrs.test.tsx index 75e60a60..4e24dfc4 100644 --- a/packages/next-yak/runtime/__tests__/attrs.test.tsx +++ b/packages/next-yak/runtime/__tests__/attrs.test.tsx @@ -14,7 +14,6 @@ it("works fine with an empty object", () => { const Comp = styled.div.attrs({})``; expect(TestRenderer.create().toJSON()).toMatchInlineSnapshot(`
`); @@ -23,11 +22,10 @@ it("works fine with an empty object", () => { it("works fine with a function that returns an empty object", () => { const Comp = styled.div.attrs(() => ({}))``; expect(TestRenderer.create().toJSON()).toMatchInlineSnapshot(` -
-`); +
+ `); }); it("pass a simple attr via object", () => { @@ -36,7 +34,6 @@ it("pass a simple attr via object", () => { })``; expect(TestRenderer.create().toJSON()).toMatchInlineSnapshot(` @@ -81,9 +77,7 @@ it("should filter out properties starting with $", () => { expect(container).toMatchInlineSnapshot(`
- +
`); }); @@ -111,7 +105,6 @@ it("should forward properties to the next yak component", () => {
`); @@ -139,7 +132,6 @@ it("should concatenate styles", () => { expect(container).toMatchInlineSnapshot(`
@@ -153,9 +145,7 @@ it("should not add class if prop is not set", () => { expect(container).toMatchInlineSnapshot(`
- +
`); }); @@ -187,15 +177,9 @@ it("should allow falsy values", () => { expect(container).toMatchInlineSnapshot(`
- - - + + +
`); }); diff --git a/packages/next-yak/runtime/styled.tsx b/packages/next-yak/runtime/styled.tsx index 1fa79943..1a24059c 100644 --- a/packages/next-yak/runtime/styled.tsx +++ b/packages/next-yak/runtime/styled.tsx @@ -225,6 +225,7 @@ function removePrefixedProperties>(obj: T) { } const mergeClassNames = (a?: string, b?: string) => { + if (!a && !b) return undefined; if (!a) return b; if (!b) return a; return a + " " + b;