html-validate 6.2.0 → 6.3.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.
@@ -1575,7 +1575,8 @@ declare class MetaTable {
1575
1575
  */
1576
1576
  loadFromFile(filename: string): void;
1577
1577
  /**
1578
- * Get [[MetaElement]] for the given tag or null if the element doesn't exist.
1578
+ * Get [[MetaElement]] for the given tag. If no specific metadata is present
1579
+ * the global metadata is returned or null if no global is present.
1579
1580
  *
1580
1581
  * @public
1581
1582
  * @returns A shallow copy of metadata.
package/dist/cjs/core.js CHANGED
@@ -944,14 +944,23 @@ class MetaTable {
944
944
  }
945
945
  }
946
946
  /**
947
- * Get [[MetaElement]] for the given tag or null if the element doesn't exist.
947
+ * Get [[MetaElement]] for the given tag. If no specific metadata is present
948
+ * the global metadata is returned or null if no global is present.
948
949
  *
949
950
  * @public
950
951
  * @returns A shallow copy of metadata.
951
952
  */
952
953
  getMetaFor(tagName) {
954
+ /* try to locate by tagname */
953
955
  tagName = tagName.toLowerCase();
954
- return this.elements[tagName] ? { ...this.elements[tagName] } : null;
956
+ if (this.elements[tagName]) {
957
+ return { ...this.elements[tagName] };
958
+ }
959
+ /* try to locate global element */
960
+ if (this.elements["*"]) {
961
+ return { ...this.elements["*"] };
962
+ }
963
+ return null;
955
964
  }
956
965
  /**
957
966
  * Find all tags which has enabled given property.
@@ -2947,7 +2956,7 @@ var TRANSFORMER_API;
2947
2956
  /** @public */
2948
2957
  const name = "html-validate";
2949
2958
  /** @public */
2950
- const version = "6.2.0";
2959
+ const version = "6.3.0";
2951
2960
  /** @public */
2952
2961
  const homepage = "https://html-validate.org";
2953
2962
  /** @public */
@@ -3417,6 +3426,28 @@ class AllowedLinks extends Rule {
3417
3426
  }
3418
3427
  }
3419
3428
 
3429
+ class AriaHiddenBody extends Rule {
3430
+ documentation() {
3431
+ return {
3432
+ description: "`aria-hidden` must not be used on the `<body>` element as it makes the page inaccessible to assistive technology such as screenreaders",
3433
+ url: ruleDocumentationUrl("@/rules/aria-hidden-body.ts"),
3434
+ };
3435
+ }
3436
+ setup() {
3437
+ this.on("tag:ready", this.isRelevant, (event) => {
3438
+ const { target } = event;
3439
+ const attr = target.getAttribute("aria-hidden");
3440
+ if (!attr || !attr.valueMatches("true", true)) {
3441
+ return;
3442
+ }
3443
+ this.report(target, "aria-hidden must not be used on <body>", attr.keyLocation);
3444
+ });
3445
+ }
3446
+ isRelevant(event) {
3447
+ return event.target.is("body");
3448
+ }
3449
+ }
3450
+
3420
3451
  const whitelisted = [
3421
3452
  "main",
3422
3453
  "nav",
@@ -5044,8 +5075,9 @@ class ElementRequiredAttributes extends Rule {
5044
5075
  class ElementRequiredContent extends Rule {
5045
5076
  documentation(context) {
5046
5077
  if (context) {
5078
+ const { element, missing } = context;
5047
5079
  return {
5048
- description: `The <${context.node} element requires a <${context.missing}> to be present as content.`,
5080
+ description: `The \`${element}\` element requires a \`${missing}\` to be present as content.`,
5049
5081
  url: ruleDocumentationUrl("@/rules/element-required-content.ts"),
5050
5082
  };
5051
5083
  }
@@ -5071,10 +5103,11 @@ class ElementRequiredContent extends Rule {
5071
5103
  }
5072
5104
  for (const missing of Validator.validateRequiredContent(node, rules)) {
5073
5105
  const context = {
5074
- node: node.tagName,
5075
- missing,
5106
+ element: node.annotatedName,
5107
+ missing: `<${missing}>`,
5076
5108
  };
5077
- this.report(node, `${node.annotatedName} element must have <${missing}> as content`, null, context);
5109
+ const message = `${node.annotatedName} element must have <${missing}> as content`;
5110
+ this.report(node, message, null, context);
5078
5111
  }
5079
5112
  });
5080
5113
  });
@@ -5157,7 +5190,14 @@ class EmptyHeading extends Rule {
5157
5190
  class EmptyTitle extends Rule {
5158
5191
  documentation() {
5159
5192
  return {
5160
- description: `The <title> element is used to describe the document and is shown in the browser tab and titlebar. WCAG and SEO requires a descriptive title and preferably unique within the site. Whitespace only is considered empty.`,
5193
+ description: [
5194
+ "The `<title>` element cannot be empty, it must have textual content.",
5195
+ "",
5196
+ "It is used to describe the document and is shown in the browser tab and titlebar.",
5197
+ "WCAG and SEO requires a descriptive title and preferably unique within the site.",
5198
+ "",
5199
+ "Whitespace is ignored.",
5200
+ ].join("\n"),
5161
5201
  url: ruleDocumentationUrl("@/rules/empty-title.ts"),
5162
5202
  };
5163
5203
  }
@@ -5173,7 +5213,10 @@ class EmptyTitle extends Rule {
5173
5213
  break;
5174
5214
  case TextClassification.EMPTY_TEXT:
5175
5215
  /* no content or whitespace only */
5176
- this.report(node, `<${node.tagName}> cannot be empty, must have text content`);
5216
+ {
5217
+ const message = `<${node.tagName}> cannot be empty, must have text content`;
5218
+ this.report(node, message, node.location);
5219
+ }
5177
5220
  break;
5178
5221
  }
5179
5222
  });
@@ -9451,6 +9494,7 @@ const bundledRules$1 = {
9451
9494
 
9452
9495
  const bundledRules = {
9453
9496
  "allowed-links": AllowedLinks,
9497
+ "aria-hidden-body": AriaHiddenBody,
9454
9498
  "aria-label-misuse": AriaLabelMisuse,
9455
9499
  "attr-case": AttrCase,
9456
9500
  "attr-delimiter": AttrDelimiter,
@@ -9521,6 +9565,7 @@ var defaultConfig = {};
9521
9565
 
9522
9566
  const config$3 = {
9523
9567
  rules: {
9568
+ "aria-hidden-body": "error",
9524
9569
  "aria-label-misuse": "error",
9525
9570
  "deprecated-rule": "warn",
9526
9571
  "empty-heading": "error",
@@ -9555,6 +9600,7 @@ const config$2 = {
9555
9600
 
9556
9601
  const config$1 = {
9557
9602
  rules: {
9603
+ "aria-hidden-body": "error",
9558
9604
  "aria-label-misuse": "error",
9559
9605
  "attr-case": "error",
9560
9606
  "attr-delimiter": "error",