From ec86ca5c71fecf21590b872737fbadd9aa3e158b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20W=C3=BCstenberg?= Date: Fri, 18 Jun 2021 09:39:47 +0200 Subject: [PATCH] Add video element and related attributes (#84) Adds the `video` element and `loop`, `muted`, `playsinline`, `poster` attributes. --- html/attributes.go | 24 ++++++++++++++++++++---- html/attributes_test.go | 26 +++++++++++++++----------- html/elements.go | 4 ++++ html/elements_test.go | 1 + 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 {