about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMarkus Wüstenberg2021-06-18 09:39:47 +0200
committerGitHub2021-06-18 09:39:47 +0200
commitec86ca5c71fecf21590b872737fbadd9aa3e158b (patch)
treeb6de2ad1bd978d0c7f8d25ee089b2f190f2fd1e1
parent0efc71d6f326efc88d25688f50f83b948b40fc38 (diff)
downloadgomponents-ec86ca5c71fecf21590b872737fbadd9aa3e158b.tar.lz
gomponents-ec86ca5c71fecf21590b872737fbadd9aa3e158b.tar.zst
gomponents-ec86ca5c71fecf21590b872737fbadd9aa3e158b.zip
Add video element and related attributes (#84)
Adds the `video` element and `loop`, `muted`, `playsinline`, `poster` attributes.
-rw-r--r--html/attributes.go24
-rw-r--r--html/attributes_test.go26
-rw-r--r--html/elements.go4
-rw-r--r--html/elements_test.go1
4 files changed, 40 insertions, 15 deletions
diff --git a/html/attributes.go b/html/attributes.go
index ab575d8..b670b05 100644
--- a/html/attributes.go
+++ b/html/attributes.go
@@ -28,10 +28,22 @@ func Disabled() g.Node {
 	return g.Attr("disabled")
 }
 
+func Loop() g.Node {
+	return g.Attr("loop")
+}
+
 func Multiple() g.Node {
 	return g.Attr("multiple")
 }
 
+func Muted() g.Node {
+	return g.Attr("muted")
+}
+
+func PlaysInline() g.Node {
+	return g.Attr("playsinline")
+}
+
 func ReadOnly() g.Node {
 	return g.Attr("readonly")
 }
@@ -142,14 +154,18 @@ func Pattern(v string) g.Node {
 	return g.Attr("pattern", v)
 }
 
-func Preload(v string) g.Node {
-	return g.Attr("preload", v)
-}
-
 func Placeholder(v string) g.Node {
 	return g.Attr("placeholder", v)
 }
 
+func Poster(v string) g.Node {
+	return g.Attr("poster", v)
+}
+
+func Preload(v string) g.Node {
+	return g.Attr("preload", v)
+}
+
 func Rel(v string) g.Node {
 	return g.Attr("rel", v)
 }
diff --git a/html/attributes_test.go b/html/attributes_test.go
index 1d0b312..1388494 100644
--- a/html/attributes_test.go
+++ b/html/attributes_test.go
@@ -11,16 +11,19 @@ import (
 
 func TestBooleanAttributes(t *testing.T) {
 	cases := map[string]func() g.Node{
-		"async":     Async,
-		"autofocus": AutoFocus,
-		"autoplay":  AutoPlay,
-		"controls":  Controls,
-		"defer":     Defer,
-		"disabled":  Disabled,
-		"multiple":  Multiple,
-		"readonly":  ReadOnly,
-		"required":  Required,
-		"selected":  Selected,
+		"async":       Async,
+		"autofocus":   AutoFocus,
+		"autoplay":    AutoPlay,
+		"controls":    Controls,
+		"defer":       Defer,
+		"disabled":    Disabled,
+		"loop":        Loop,
+		"multiple":    Multiple,
+		"muted":       Muted,
+		"playsinline": PlaysInline,
+		"readonly":    ReadOnly,
+		"required":    Required,
+		"selected":    Selected,
 	}
 
 	for name, fn := range cases {
@@ -55,8 +58,9 @@ func TestSimpleAttributes(t *testing.T) {
 		"minlength":    MinLength,
 		"name":         Name,
 		"pattern":      Pattern,
-		"preload":      Preload,
 		"placeholder":  Placeholder,
+		"poster":       Poster,
+		"preload":      Preload,
 		"rel":          Rel,
 		"role":         Role,
 		"rows":         Rows,
diff --git a/html/elements.go b/html/elements.go
index 918f6bd..79db67f 100644
--- a/html/elements.go
+++ b/html/elements.go
@@ -426,3 +426,7 @@ func U(children ...g.Node) g.Node {
 func Var(children ...g.Node) g.Node {
 	return g.El("var", g.Group(children))
 }
+
+func Video(children ...g.Node) g.Node {
+	return g.El("video", g.Group(children))
+}
diff --git a/html/elements_test.go b/html/elements_test.go
index a85312c..e0cab4a 100644
--- a/html/elements_test.go
+++ b/html/elements_test.go
@@ -118,6 +118,7 @@ func TestSimpleElements(t *testing.T) {
 		"u":          U,
 		"ul":         Ul,
 		"var":        Var,
+		"video":      Video,
 	}
 
 	for name, fn := range cases {