html-validate 8.19.0 → 8.20.0

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 CHANGED
@@ -10045,7 +10045,10 @@ function hasAssociatedSubmit(document, form) {
10045
10045
  class H36 extends Rule {
10046
10046
  documentation() {
10047
10047
  return {
10048
- 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=""`).',
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
- this.report(node, "image used as submit button must have alt text");
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, input");
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, `${getTag(node)} cannot have empty "alt" attribute`, attr == null ? void 0 : attr.keyLocation);
10140
+ this.report(node, `${tag} cannot have empty "alt" attribute`, attr.keyLocation);
10144
10141
  } else {
10145
- this.report(node, `${getTag(node)} is missing required "alt" attribute`, node.location);
10142
+ this.report(node, `${tag} is missing required "alt" attribute`, node.location);
10146
10143
  }
10147
10144
  }
10148
10145
  }
@@ -12326,6 +12323,18 @@ class StaticConfigLoader extends ConfigLoader {
12326
12323
  super(defaultResolvers, config);
12327
12324
  }
12328
12325
  }
12326
+ /**
12327
+ * Set a new configuration for this loader.
12328
+ *
12329
+ * @public
12330
+ * @since 8.20.0
12331
+ * @param config - New configuration to use.
12332
+ */
12333
+ /* istanbul ignore next -- not testing setters/getters */
12334
+ setConfig(config) {
12335
+ const defaults = Config.empty();
12336
+ this.globalConfig = defaults.merge(this.resolvers, this.loadFromObject(config));
12337
+ }
12329
12338
  getConfigFor(_handle, configOverride) {
12330
12339
  const override = this.loadFromObject(configOverride ?? {});
12331
12340
  if (override.isRootFound()) {
@@ -12715,6 +12724,28 @@ class HtmlValidate {
12715
12724
  getConfigForSync(filename, configOverride) {
12716
12725
  return this.configLoader.getConfigFor(filename, configOverride);
12717
12726
  }
12727
+ /**
12728
+ * Get current configuration loader.
12729
+ *
12730
+ * @public
12731
+ * @since %version%
12732
+ * @returns Current configuration loader.
12733
+ */
12734
+ /* istanbul ignore next -- not testing setters/getters */
12735
+ getConfigLoader() {
12736
+ return this.configLoader;
12737
+ }
12738
+ /**
12739
+ * Set configuration loader.
12740
+ *
12741
+ * @public
12742
+ * @since %version%
12743
+ * @param loader - New configuration loader to use.
12744
+ */
12745
+ /* istanbul ignore next -- not testing setters/getters */
12746
+ setConfigLoader(loader) {
12747
+ this.configLoader = loader;
12748
+ }
12718
12749
  /**
12719
12750
  * Flush configuration cache. Clears full cache unless a filename is given.
12720
12751
  *
@@ -12729,7 +12760,7 @@ class HtmlValidate {
12729
12760
  }
12730
12761
 
12731
12762
  const name = "html-validate";
12732
- const version = "8.19.0";
12763
+ const version = "8.20.0";
12733
12764
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
12734
12765
 
12735
12766
  function definePlugin(plugin) {