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.
@@ -1 +1 @@
1
- {"version":3,"file":"jest-diff.js","sources":["../../src/jest/utils/diff.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment -- this code needs to work\n * with multiple different versions of jest and it does verification of which\n * one is actually present but the other variants will cause errors, as is expected */\n/* eslint-disable @typescript-eslint/prefer-ts-expect-error -- one of the\n * variants will always not be an error */\n\nimport jestDiffDefault, * as jestDiff from \"jest-diff\";\n\n/**\n * @internal\n */\nexport interface DiffOptions {\n\taAnnotation?: string;\n\tbAnnotation?: string;\n\texpand?: boolean;\n}\n\n/**\n * @internal\n */\nexport type DiffFunction = (a: any, b: any, options?: DiffOptions) => string | null;\n\n/* ignore typing for compatibility so it will seem \"impossible\" but different\n * version will yield different source */\n/* istanbul ignore next: this is covered by integration tests */\nconst diffCandidates: Array<DiffFunction | undefined> = [\n\t// @ts-ignore\n\tjestDiffDefault?.diff,\n\t// @ts-ignore\n\tjestDiffDefault,\n\t// @ts-ignore\n\tjestDiff?.diff,\n\t// @ts-ignore\n\tjestDiff,\n];\n\nconst isFunction = (fn: unknown): boolean => typeof fn === \"function\";\n\n/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- assume\n * one of the candidate matches, there will be a reasonable error later on if\n * not */\nexport const diff: DiffFunction = diffCandidates.find(isFunction)!;\n"],"names":["jestDiffDefault","jestDiff"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,EAAA,CAAA;AAyBA,MAAM,cAAkD,GAAA;AAAA;AAAA,EAAA,CAEvD,EAAiB,GAAAA,2BAAA,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA;AAAA;AAAA,EAEjBA,2BAAA;AAAA;AAAA,EAEAC,mBAAU,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAA,mBAAA,CAAA,IAAA;AAAA;AAAA,EAEVA,mBAAA;AACD,CAAA,CAAA;AAEA,MAAM,UAAa,GAAA,CAAC,EAAyB,KAAA,OAAO,EAAO,KAAA,UAAA,CAAA;AAK9C,MAAA,IAAA,GAAqB,cAAe,CAAA,IAAA,CAAK,UAAU;;;;"}
1
+ {"version":3,"file":"jest-diff.js","sources":["../../src/jest/utils/diff.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment -- this code needs to work\n * with multiple different versions of jest and it does verification of which\n * one is actually present but the other variants will cause errors, as is expected */\n\nimport jestDiffDefault, * as jestDiff from \"jest-diff\";\n\n/**\n * @internal\n */\nexport interface DiffOptions {\n\taAnnotation?: string;\n\tbAnnotation?: string;\n\texpand?: boolean;\n}\n\n/**\n * @internal\n */\nexport type DiffFunction = (a: any, b: any, options?: DiffOptions) => string | null;\n\n/* ignore typing for compatibility so it will seem \"impossible\" but different\n * version will yield different source */\n/* istanbul ignore next: this is covered by integration tests */\nconst diffCandidates: Array<DiffFunction | undefined> = [\n\t// @ts-ignore\n\tjestDiffDefault?.diff,\n\t// @ts-ignore\n\tjestDiffDefault,\n\t// @ts-ignore\n\tjestDiff?.diff,\n\t// @ts-ignore\n\tjestDiff,\n];\n\nconst isFunction = (fn: unknown): boolean => typeof fn === \"function\";\n\n/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- assume\n * one of the candidate matches, there will be a reasonable error later on if\n * not */\nexport const diff: DiffFunction = diffCandidates.find(isFunction)!;\n"],"names":["jestDiffDefault","jestDiff"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,EAAA,CAAA;AAuBA,MAAM,cAAkD,GAAA;AAAA;AAAA,EAAA,CAEvD,EAAiB,GAAAA,2BAAA,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA;AAAA;AAAA,EAEjBA,2BAAA;AAAA;AAAA,EAEAC,mBAAU,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAA,mBAAA,CAAA,IAAA;AAAA;AAAA,EAEVA,mBAAA;AACD,CAAA,CAAA;AAEA,MAAM,UAAa,GAAA,CAAC,EAAyB,KAAA,OAAO,EAAO,KAAA,UAAA,CAAA;AAK9C,MAAA,IAAA,GAAqB,cAAe,CAAA,IAAA,CAAK,UAAU;;;;"}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.43.7"
8
+ "packageVersion": "7.46.2"
9
9
  }
10
10
  ]
11
11
  }
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
  }
@@ -12316,6 +12313,18 @@ class StaticConfigLoader extends ConfigLoader {
12316
12313
  super(defaultResolvers, config);
12317
12314
  }
12318
12315
  }
12316
+ /**
12317
+ * Set a new configuration for this loader.
12318
+ *
12319
+ * @public
12320
+ * @since 8.20.0
12321
+ * @param config - New configuration to use.
12322
+ */
12323
+ /* istanbul ignore next -- not testing setters/getters */
12324
+ setConfig(config) {
12325
+ const defaults = Config.empty();
12326
+ this.globalConfig = defaults.merge(this.resolvers, this.loadFromObject(config));
12327
+ }
12319
12328
  getConfigFor(_handle, configOverride) {
12320
12329
  const override = this.loadFromObject(configOverride ?? {});
12321
12330
  if (override.isRootFound()) {
@@ -12705,6 +12714,28 @@ class HtmlValidate {
12705
12714
  getConfigForSync(filename, configOverride) {
12706
12715
  return this.configLoader.getConfigFor(filename, configOverride);
12707
12716
  }
12717
+ /**
12718
+ * Get current configuration loader.
12719
+ *
12720
+ * @public
12721
+ * @since %version%
12722
+ * @returns Current configuration loader.
12723
+ */
12724
+ /* istanbul ignore next -- not testing setters/getters */
12725
+ getConfigLoader() {
12726
+ return this.configLoader;
12727
+ }
12728
+ /**
12729
+ * Set configuration loader.
12730
+ *
12731
+ * @public
12732
+ * @since %version%
12733
+ * @param loader - New configuration loader to use.
12734
+ */
12735
+ /* istanbul ignore next -- not testing setters/getters */
12736
+ setConfigLoader(loader) {
12737
+ this.configLoader = loader;
12738
+ }
12708
12739
  /**
12709
12740
  * Flush configuration cache. Clears full cache unless a filename is given.
12710
12741
  *
@@ -12719,7 +12750,7 @@ class HtmlValidate {
12719
12750
  }
12720
12751
 
12721
12752
  const name = "html-validate";
12722
- const version = "8.19.0";
12753
+ const version = "8.20.0";
12723
12754
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
12724
12755
 
12725
12756
  function definePlugin(plugin) {