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/es/core.js CHANGED
@@ -10035,7 +10035,10 @@ function hasAssociatedSubmit(document, form) {
10035
10035
  class H36 extends Rule {
10036
10036
  documentation() {
10037
10037
  return {
10038
- description: 'WCAG 2.1 requires all images used as submit buttons to have a textual description using the alt attribute. The alt text cannot be empty (`alt=""`).',
10038
+ description: [
10039
+ "WCAG 2.1 requires all images used as submit buttons to have a non-empty textual description using the `alt` attribute.",
10040
+ 'The alt text cannot be empty (`alt=""`).'
10041
+ ].join("\n"),
10039
10042
  url: "https://html-validate.org/rules/wcag/h36.html"
10040
10043
  };
10041
10044
  }
@@ -10047,8 +10050,17 @@ class H36 extends Rule {
10047
10050
  if (node.getAttributeValue("type") !== "image") {
10048
10051
  return;
10049
10052
  }
10053
+ if (!inAccessibilityTree(node)) {
10054
+ return;
10055
+ }
10050
10056
  if (!hasAltText(node)) {
10051
- this.report(node, "image used as submit button must have alt text");
10057
+ const message = "image used as submit button must have non-empty alt text";
10058
+ const alt = node.getAttribute("alt");
10059
+ this.report({
10060
+ node,
10061
+ message,
10062
+ location: alt ? alt.keyLocation : node.location
10063
+ });
10052
10064
  }
10053
10065
  });
10054
10066
  }
@@ -10058,19 +10070,6 @@ const defaults$1 = {
10058
10070
  allowEmpty: true,
10059
10071
  alias: []
10060
10072
  };
10061
- function needsAlt(node) {
10062
- if (node.is("img")) {
10063
- return true;
10064
- }
10065
- if (node.is("input") && node.getAttributeValue("type") === "image") {
10066
- return true;
10067
- }
10068
- return false;
10069
- }
10070
- function getTag(node) {
10071
- return node.is("input") ? `<input type="${/* istanbul ignore next */
10072
- node.getAttributeValue("type") ?? ""}">` : `<${node.tagName}>`;
10073
- }
10074
10073
  class H37 extends Rule {
10075
10074
  constructor(options) {
10076
10075
  super({ ...defaults$1, ...options });
@@ -10107,16 +10106,13 @@ class H37 extends Rule {
10107
10106
  setup() {
10108
10107
  this.on("dom:ready", (event) => {
10109
10108
  const { document } = event;
10110
- const nodes = document.querySelectorAll("img, input");
10109
+ const nodes = document.querySelectorAll("img");
10111
10110
  for (const node of nodes) {
10112
10111
  this.validateNode(node);
10113
10112
  }
10114
10113
  });
10115
10114
  }
10116
10115
  validateNode(node) {
10117
- if (!needsAlt(node)) {
10118
- return;
10119
- }
10120
10116
  if (!inAccessibilityTree(node)) {
10121
10117
  return;
10122
10118
  }
@@ -10128,11 +10124,12 @@ class H37 extends Rule {
10128
10124
  return;
10129
10125
  }
10130
10126
  }
10127
+ const tag = node.annotatedName;
10131
10128
  if (node.hasAttribute("alt")) {
10132
10129
  const attr = node.getAttribute("alt");
10133
- this.report(node, `${getTag(node)} cannot have empty "alt" attribute`, attr == null ? void 0 : attr.keyLocation);
10130
+ this.report(node, `${tag} cannot have empty "alt" attribute`, attr.keyLocation);
10134
10131
  } else {
10135
- this.report(node, `${getTag(node)} is missing required "alt" attribute`, node.location);
10132
+ this.report(node, `${tag} is missing required "alt" attribute`, node.location);
10136
10133
  }
10137
10134
  }
10138
10135
  }
@@ -12719,7 +12716,7 @@ class HtmlValidate {
12719
12716
  }
12720
12717
 
12721
12718
  const name = "html-validate";
12722
- const version = "8.19.0";
12719
+ const version = "8.19.1";
12723
12720
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
12724
12721
 
12725
12722
  function definePlugin(plugin) {