Repository: maragudk/gomponents
Pull request #84 (2021-06-18 07:35:10)

Add video element and related attributes
Adds the `video` element and `loop`, `muted`, `playsinline`, `poster` attributes.

codecov[bot]: # [Codecov](https://codecov.io/gh/maragudk/gomponents/pull/84?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=maragudk) Report
> Merging [#84](https://codecov.io/gh/maragudk/gomponents/pull/84?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=maragudk) (9a00f5e) into [master](https://codecov.io/gh/maragudk/gomponents/commit/0efc71d6f326efc88d25688f50f83b948b40fc38?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=maragudk) (0efc71d) will **not change** coverage.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/maragudk/gomponents/pull/84/graphs/tree.svg?width=650&height=150&src=pr&token=JYN032TYAC&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=maragudk)](https://codecov.io/gh/maragudk/gomponents/pull/84?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=maragudk)

```diff
@@            Coverage Diff            @@
##            master       #84   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            8         8           
  Lines          255       260    +5     
=========================================
+ Hits           255       260    +5     
```


| [Impacted Files](https://codecov.io/gh/maragudk/gomponents/pull/84?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=maragudk) | Coverage Δ | |
|---|---|---|
| [html/attributes.go](https://codecov.io/gh/maragudk/gomponents/pull/84/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=maragudk#diff-aHRtbC9hdHRyaWJ1dGVzLmdv) | `100.00% <100.00%> (ø)` | |
| [html/elements.go](https://codecov.io/gh/maragudk/gomponents/pull/84/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=maragudk#diff-aHRtbC9lbGVtZW50cy5nbw==) | `100.00% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/maragudk/gomponents/pull/84?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=maragudk).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=maragudk)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/maragudk/gomponents/pull/84?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=maragudk). Last update [0efc71d...9a00f5e](https://codecov.io/gh/maragudk/gomponents/pull/84?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=maragudk). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=maragudk).


Patch:
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/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))
+}


Test patch:
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_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 {