Skip to content

Commit 33524d6

Browse files
jjba23Josep Jesus Bigorra Algaba
andauthored
Add loading and srcset HTML attributes (#86)
Useful for `img` and `picture` elements. Fixes #85. Co-authored-by: Josep Jesus Bigorra Algaba <[email protected]>
1 parent bd722de commit 33524d6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

html/attributes.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ func Lang(v string) g.Node {
126126
return g.Attr("lang", v)
127127
}
128128

129+
func Loading(v string) g.Node {
130+
return g.Attr("loading", v)
131+
}
132+
129133
func Max(v string) g.Node {
130134
return g.Attr("max", v)
131135
}
@@ -182,6 +186,10 @@ func Src(v string) g.Node {
182186
return g.Attr("src", v)
183187
}
184188

189+
func SrcSet(v string) g.Node {
190+
return g.Attr("srcset", v)
191+
}
192+
185193
func StyleAttr(v string) g.Node {
186194
return g.Attr("style", v)
187195
}

html/attributes_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func TestSimpleAttributes(t *testing.T) {
5151
"href": Href,
5252
"id": ID,
5353
"lang": Lang,
54+
"loading": Loading,
5455
"max": Max,
5556
"maxlength": MaxLength,
5657
"method": Method,
@@ -65,6 +66,7 @@ func TestSimpleAttributes(t *testing.T) {
6566
"role": Role,
6667
"rows": Rows,
6768
"src": Src,
69+
"srcset": SrcSet,
6870
"style": StyleAttr,
6971
"tabindex": TabIndex,
7072
"target": Target,

0 commit comments

Comments
 (0)