-
Notifications
You must be signed in to change notification settings - Fork 0
/
attributes.go
75 lines (60 loc) · 2.26 KB
/
attributes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package html
import "strings"
// Aria adds a "aria-*" attribute to the Element
func (element *Element) Aria(name string, value string) *Element {
return element.Attr("aria-"+name, value)
}
// Class adds a "class" attribute to the Element.
// Multiple class names can be passed, and are separated by spaces
func (element *Element) Class(values ...string) *Element {
return element.Attr("class", strings.Join(values, " "))
}
// For adds a "for" attribute to the Element
func (element *Element) For(value string) *Element {
return element.Attr("for", value)
}
// Data adds a "data-" attribute to the Element
func (element *Element) Data(name string, value string) *Element {
return element.Attr("data-"+name, value)
}
// ID adds an "id" attribute to the Element
func (element *Element) ID(value string) *Element {
return element.Attr("id", value)
}
// Label adds a "label" attribute to the Element
func (element *Element) Label(value string) *Element {
return element.Attr("label", value)
}
// List adds a "list" attribute to the Element
func (element *Element) List(value string) *Element {
return element.Attr("list", value)
}
// Name adds a "name" attribute to the Element
func (element *Element) Name(value string) *Element {
return element.Attr("name", value)
}
// Name adds a "role" attribute to the Element (for WAI-ARIA)
func (element *Element) Role(value string) *Element {
return element.Attr("role", value)
}
// Script adds a "data-script" attribute to the Element (for https://hyperscript.org)
func (element *Element) Script(value string) *Element {
return element.Attr("data-script", value)
}
// Stype adds a "style" attribute to the Element
// Multiple style definitions can be passed, and are separated by semicolons.
func (element *Element) Style(values ...string) *Element {
return element.Attr("style", strings.Join(values, "; "))
}
// TabIndex adds a "tabIndex" attribute to the Element
func (element *Element) TabIndex(value string) *Element {
return element.Attr("tabIndex", value)
}
// Type adds a "type" attribute to the Element
func (element *Element) Type(value string) *Element {
return element.Attr("type", value)
}
// Value adds a "value" attribute to the Element
func (element *Element) Value(value string) *Element {
return element.Attr("value", value)
}