diff --git a/reviewers/alt_required.go b/reviewers/alt_required.go
index fd03ce9..02803eb 100644
--- a/reviewers/alt_required.go
+++ b/reviewers/alt_required.go
@@ -27,13 +27,12 @@ func (at AltRequired) Review(path string, page io.Reader) ([]Fault, error) {
break
}
- if tt == html.StartTagToken || tt == html.SelfClosingTagToken {
- token := z.Token()
-
- if !at.tagRequiresAlt(token) || at.hasAlt(token) {
- continue
- }
+ token := z.Token()
+ if !at.tagRequiresAlt(token) || at.hasAlt(token) {
+ continue
+ }
+ if tt == html.StartTagToken || tt == html.SelfClosingTagToken {
result = append(result, Fault{
Reviewer: at.ReviewerName(),
Line: token.Line,
@@ -47,12 +46,10 @@ func (at AltRequired) Review(path string, page io.Reader) ([]Fault, error) {
}
func (at AltRequired) tagRequiresAlt(token html.Token) bool {
- if token.DataAtom.String() == "img" {
+ switch token.DataAtom.String() {
+ case "img":
return true
- }
-
- // input[type=image]
- if token.DataAtom.String() == "input" {
+ case "input":
for _, attr := range token.Attr {
if attr.Key != "type" || strings.ToLower(attr.Val) != "image" {
continue
@@ -62,10 +59,7 @@ func (at AltRequired) tagRequiresAlt(token html.Token) bool {
}
return false
- }
-
- // area[href]
- if token.DataAtom.String() == "area" {
+ case "area":
for _, attr := range token.Attr {
if attr.Key == "href" {
return true
@@ -73,9 +67,9 @@ func (at AltRequired) tagRequiresAlt(token html.Token) bool {
}
return true
+ default:
+ return false
}
-
- return false
}
func (at AltRequired) hasAlt(token html.Token) bool {
diff --git a/reviewers/att_no_white_spaces.go b/reviewers/att_no_white_spaces.go
index bfe60e3..29cdec3 100644
--- a/reviewers/att_no_white_spaces.go
+++ b/reviewers/att_no_white_spaces.go
@@ -28,7 +28,7 @@ func (at AttrNoWhiteSpaces) Review(path string, page io.Reader) ([]Fault, error)
continue
}
- exp := regexp.MustCompile(`[^\s]+(\s+\=\s*|\s*\=\s+)`)
+ exp := regexp.MustCompile(`\S+(\s+=\s*|\s*=\s+)`)
if exp.MatchString(line) {
result = append(result, Fault{
Reviewer: at.ReviewerName(),
diff --git a/reviewers/attr_id_unique.go b/reviewers/attr_id_unique.go
index f8f7d79..2a9ce9d 100644
--- a/reviewers/attr_id_unique.go
+++ b/reviewers/attr_id_unique.go
@@ -9,7 +9,7 @@ import (
type AttrIDUnique struct{}
func (at AttrIDUnique) ReviewerName() string {
- return "attribute/alt-required"
+ return "attribute/id-unique"
}
func (at AttrIDUnique) Accepts(filePath string) bool {
@@ -31,8 +31,13 @@ func (at AttrIDUnique) Review(path string, page io.Reader) ([]Fault, error) {
token := z.Token()
ID := at.tagID(token)
+ if ID == "" {
+ continue
+ }
+
if ID != "" && !IDs[ID] {
IDs[ID] = true
+
continue
}
diff --git a/reviewers/attr_id_unique_test.go b/reviewers/attr_id_unique_test.go
index abc1538..6a63d28 100644
--- a/reviewers/attr_id_unique_test.go
+++ b/reviewers/attr_id_unique_test.go
@@ -30,6 +30,17 @@ func Test_AttrIDUnique_Review(t *testing.T) {
`,
},
+ {
+ name: "no fault empty",
+ content: `
+
+
+
+
+
+ `,
+ },
+
{
name: "Faults",
content: `