Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing boolean attrs #51

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions attrs/attrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const (
// Image/Embed Attributes
Height = "height"
Width = "width"
IsMap = "ismap"

// Form/Input Attributes
Accept = "accept"
Expand All @@ -47,10 +48,12 @@ const (
Min = "min"
Multiple = "multiple"
Name = "name"
NoValidate = "novalidate"
Placeholder = "placeholder"
Readonly = "readonly"
Required = "required"
Rows = "rows"
Selected = "selected"
Type = "type"
Value = "value"

Expand All @@ -62,8 +65,8 @@ const (
Spellcheck = "spellcheck"

// Table Attributes
RowSpan = "rowspan"
ColSpan = "colspan"
Scope = "scope"
Headers = "headers"
RowSpan = "rowspan"
ColSpan = "colspan"
Scope = "scope"
Headers = "headers"
)
21 changes: 12 additions & 9 deletions elem.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,21 @@ var voidElements = map[string]struct{}{
"wbr": {},
}

// List of boolean attributes. Boolean attributes can't have literal values. The presence of an boolean
// List of boolean attributes. Boolean attributes can't have literal values. The presence of an boolean
// attribute represents the "true" value. To represent the "false" value, the attribute has to be omitted.
// See https://html.spec.whatwg.org/multipage/indices.html#attributes-3 for reference
var booleanAttrs = map[string]struct{}{
attrs.Async: {},
attrs.Autofocus: {},
attrs.Checked: {},
attrs.Defer: {},
attrs.Disabled: {},
attrs.Multiple: {},
attrs.Readonly: {},
attrs.Required: {},
attrs.Async: {},
attrs.Autofocus: {},
attrs.Checked: {},
attrs.Defer: {},
attrs.Disabled: {},
attrs.IsMap: {},
attrs.Multiple: {},
attrs.NoValidate: {},
attrs.Readonly: {},
attrs.Required: {},
attrs.Selected: {},
}

type Attrs map[string]string
Expand Down