about summary refs log tree commit diff stats
path: root/attr/attributes_test.go
diff options
context:
space:
mode:
authorMarkus Wüstenberg2020-09-24 13:19:52 +0200
committerGitHub2020-09-24 13:19:52 +0200
commit4c109f9f1d4db4733d267ece171a533521029bdb (patch)
tree555c4ef5ad7281e8e36431d31968ade85c61aa72 /attr/attributes_test.go
parentf27cb0c05f23785189979e57c831eb798e1da1f1 (diff)
downloadgomponents-4c109f9f1d4db4733d267ece171a533521029bdb.tar.lz
gomponents-4c109f9f1d4db4733d267ece171a533521029bdb.tar.zst
gomponents-4c109f9f1d4db4733d267ece171a533521029bdb.zip
Introduce Placer interface (#18)
When implemented, the `Place` method of the `Placer` interface tells `Render` in `El` where to put a Node. This is relevant for helpers that want to be rendered like attributes, inside the parent element.

Fixes the bug where `attr.Classes` was rendered outside the element.
Diffstat (limited to 'attr/attributes_test.go')
-rw-r--r--attr/attributes_test.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/attr/attributes_test.go b/attr/attributes_test.go
index 9c7ece7..4da28e3 100644
--- a/attr/attributes_test.go
+++ b/attr/attributes_test.go
@@ -3,6 +3,7 @@ package attr_test
 import (
 	"testing"
 
+	g "github.com/maragudk/gomponents"
 	"github.com/maragudk/gomponents/assert"
 	"github.com/maragudk/gomponents/attr"
 )
@@ -29,6 +30,11 @@ func TestClasses(t *testing.T) {
 		})
 	})
 
+	t.Run("renders as attribute in an element", func(t *testing.T) {
+		e := g.El("div", attr.Classes{"hat": true})
+		assert.Equal(t, `<div class="hat"/>`, e)
+	})
+
 	t.Run("also works with fmt", func(t *testing.T) {
 		a := attr.Classes{"hat": true}
 		if a.String() != ` class="hat"` {