html-validate 8.19.0 → 8.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/core.js +19 -22
- package/dist/cjs/core.js.map +1 -1
- package/dist/es/core.js +19 -22
- package/dist/es/core.js.map +1 -1
- package/package.json +9 -9
package/dist/cjs/core.js
CHANGED
|
@@ -10045,7 +10045,10 @@ function hasAssociatedSubmit(document, form) {
|
|
|
10045
10045
|
class H36 extends Rule {
|
|
10046
10046
|
documentation() {
|
|
10047
10047
|
return {
|
|
10048
|
-
description:
|
|
10048
|
+
description: [
|
|
10049
|
+
"WCAG 2.1 requires all images used as submit buttons to have a non-empty textual description using the `alt` attribute.",
|
|
10050
|
+
'The alt text cannot be empty (`alt=""`).'
|
|
10051
|
+
].join("\n"),
|
|
10049
10052
|
url: "https://html-validate.org/rules/wcag/h36.html"
|
|
10050
10053
|
};
|
|
10051
10054
|
}
|
|
@@ -10057,8 +10060,17 @@ class H36 extends Rule {
|
|
|
10057
10060
|
if (node.getAttributeValue("type") !== "image") {
|
|
10058
10061
|
return;
|
|
10059
10062
|
}
|
|
10063
|
+
if (!inAccessibilityTree(node)) {
|
|
10064
|
+
return;
|
|
10065
|
+
}
|
|
10060
10066
|
if (!hasAltText(node)) {
|
|
10061
|
-
|
|
10067
|
+
const message = "image used as submit button must have non-empty alt text";
|
|
10068
|
+
const alt = node.getAttribute("alt");
|
|
10069
|
+
this.report({
|
|
10070
|
+
node,
|
|
10071
|
+
message,
|
|
10072
|
+
location: alt ? alt.keyLocation : node.location
|
|
10073
|
+
});
|
|
10062
10074
|
}
|
|
10063
10075
|
});
|
|
10064
10076
|
}
|
|
@@ -10068,19 +10080,6 @@ const defaults$1 = {
|
|
|
10068
10080
|
allowEmpty: true,
|
|
10069
10081
|
alias: []
|
|
10070
10082
|
};
|
|
10071
|
-
function needsAlt(node) {
|
|
10072
|
-
if (node.is("img")) {
|
|
10073
|
-
return true;
|
|
10074
|
-
}
|
|
10075
|
-
if (node.is("input") && node.getAttributeValue("type") === "image") {
|
|
10076
|
-
return true;
|
|
10077
|
-
}
|
|
10078
|
-
return false;
|
|
10079
|
-
}
|
|
10080
|
-
function getTag(node) {
|
|
10081
|
-
return node.is("input") ? `<input type="${/* istanbul ignore next */
|
|
10082
|
-
node.getAttributeValue("type") ?? ""}">` : `<${node.tagName}>`;
|
|
10083
|
-
}
|
|
10084
10083
|
class H37 extends Rule {
|
|
10085
10084
|
constructor(options) {
|
|
10086
10085
|
super({ ...defaults$1, ...options });
|
|
@@ -10117,16 +10116,13 @@ class H37 extends Rule {
|
|
|
10117
10116
|
setup() {
|
|
10118
10117
|
this.on("dom:ready", (event) => {
|
|
10119
10118
|
const { document } = event;
|
|
10120
|
-
const nodes = document.querySelectorAll("img
|
|
10119
|
+
const nodes = document.querySelectorAll("img");
|
|
10121
10120
|
for (const node of nodes) {
|
|
10122
10121
|
this.validateNode(node);
|
|
10123
10122
|
}
|
|
10124
10123
|
});
|
|
10125
10124
|
}
|
|
10126
10125
|
validateNode(node) {
|
|
10127
|
-
if (!needsAlt(node)) {
|
|
10128
|
-
return;
|
|
10129
|
-
}
|
|
10130
10126
|
if (!inAccessibilityTree(node)) {
|
|
10131
10127
|
return;
|
|
10132
10128
|
}
|
|
@@ -10138,11 +10134,12 @@ class H37 extends Rule {
|
|
|
10138
10134
|
return;
|
|
10139
10135
|
}
|
|
10140
10136
|
}
|
|
10137
|
+
const tag = node.annotatedName;
|
|
10141
10138
|
if (node.hasAttribute("alt")) {
|
|
10142
10139
|
const attr = node.getAttribute("alt");
|
|
10143
|
-
this.report(node, `${
|
|
10140
|
+
this.report(node, `${tag} cannot have empty "alt" attribute`, attr.keyLocation);
|
|
10144
10141
|
} else {
|
|
10145
|
-
this.report(node, `${
|
|
10142
|
+
this.report(node, `${tag} is missing required "alt" attribute`, node.location);
|
|
10146
10143
|
}
|
|
10147
10144
|
}
|
|
10148
10145
|
}
|
|
@@ -12729,7 +12726,7 @@ class HtmlValidate {
|
|
|
12729
12726
|
}
|
|
12730
12727
|
|
|
12731
12728
|
const name = "html-validate";
|
|
12732
|
-
const version = "8.19.
|
|
12729
|
+
const version = "8.19.1";
|
|
12733
12730
|
const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
|
|
12734
12731
|
|
|
12735
12732
|
function definePlugin(plugin) {
|