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.
package/dist/es/core.d.ts CHANGED
@@ -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/es/core.js CHANGED
@@ -933,14 +933,23 @@ class MetaTable {
933
933
  }
934
934
  }
935
935
  /**
936
- * Get [[MetaElement]] for the given tag or null if the element doesn't exist.
936
+ * Get [[MetaElement]] for the given tag. If no specific metadata is present
937
+ * the global metadata is returned or null if no global is present.
937
938
  *
938
939
  * @public
939
940
  * @returns A shallow copy of metadata.
940
941
  */
941
942
  getMetaFor(tagName) {
943
+ /* try to locate by tagname */
942
944
  tagName = tagName.toLowerCase();
943
- return this.elements[tagName] ? { ...this.elements[tagName] } : null;
945
+ if (this.elements[tagName]) {
946
+ return { ...this.elements[tagName] };
947
+ }
948
+ /* try to locate global element */
949
+ if (this.elements["*"]) {
950
+ return { ...this.elements["*"] };
951
+ }
952
+ return null;
944
953
  }
945
954
  /**
946
955
  * Find all tags which has enabled given property.
@@ -2936,7 +2945,7 @@ var TRANSFORMER_API;
2936
2945
  /** @public */
2937
2946
  const name = "html-validate";
2938
2947
  /** @public */
2939
- const version = "6.2.0";
2948
+ const version = "6.3.0";
2940
2949
  /** @public */
2941
2950
  const homepage = "https://html-validate.org";
2942
2951
  /** @public */
@@ -3406,6 +3415,28 @@ class AllowedLinks extends Rule {
3406
3415
  }
3407
3416
  }
3408
3417
 
3418
+ class AriaHiddenBody extends Rule {
3419
+ documentation() {
3420
+ return {
3421
+ description: "`aria-hidden` must not be used on the `<body>` element as it makes the page inaccessible to assistive technology such as screenreaders",
3422
+ url: ruleDocumentationUrl("@/rules/aria-hidden-body.ts"),
3423
+ };
3424
+ }
3425
+ setup() {
3426
+ this.on("tag:ready", this.isRelevant, (event) => {
3427
+ const { target } = event;
3428
+ const attr = target.getAttribute("aria-hidden");
3429
+ if (!attr || !attr.valueMatches("true", true)) {
3430
+ return;
3431
+ }
3432
+ this.report(target, "aria-hidden must not be used on <body>", attr.keyLocation);
3433
+ });
3434
+ }
3435
+ isRelevant(event) {
3436
+ return event.target.is("body");
3437
+ }
3438
+ }
3439
+
3409
3440
  const whitelisted = [
3410
3441
  "main",
3411
3442
  "nav",
@@ -5033,8 +5064,9 @@ class ElementRequiredAttributes extends Rule {
5033
5064
  class ElementRequiredContent extends Rule {
5034
5065
  documentation(context) {
5035
5066
  if (context) {
5067
+ const { element, missing } = context;
5036
5068
  return {
5037
- description: `The <${context.node} element requires a <${context.missing}> to be present as content.`,
5069
+ description: `The \`${element}\` element requires a \`${missing}\` to be present as content.`,
5038
5070
  url: ruleDocumentationUrl("@/rules/element-required-content.ts"),
5039
5071
  };
5040
5072
  }
@@ -5060,10 +5092,11 @@ class ElementRequiredContent extends Rule {
5060
5092
  }
5061
5093
  for (const missing of Validator.validateRequiredContent(node, rules)) {
5062
5094
  const context = {
5063
- node: node.tagName,
5064
- missing,
5095
+ element: node.annotatedName,
5096
+ missing: `<${missing}>`,
5065
5097
  };
5066
- this.report(node, `${node.annotatedName} element must have <${missing}> as content`, null, context);
5098
+ const message = `${node.annotatedName} element must have <${missing}> as content`;
5099
+ this.report(node, message, null, context);
5067
5100
  }
5068
5101
  });
5069
5102
  });
@@ -5146,7 +5179,14 @@ class EmptyHeading extends Rule {
5146
5179
  class EmptyTitle extends Rule {
5147
5180
  documentation() {
5148
5181
  return {
5149
- 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.`,
5182
+ description: [
5183
+ "The `<title>` element cannot be empty, it must have textual content.",
5184
+ "",
5185
+ "It is used to describe the document and is shown in the browser tab and titlebar.",
5186
+ "WCAG and SEO requires a descriptive title and preferably unique within the site.",
5187
+ "",
5188
+ "Whitespace is ignored.",
5189
+ ].join("\n"),
5150
5190
  url: ruleDocumentationUrl("@/rules/empty-title.ts"),
5151
5191
  };
5152
5192
  }
@@ -5162,7 +5202,10 @@ class EmptyTitle extends Rule {
5162
5202
  break;
5163
5203
  case TextClassification.EMPTY_TEXT:
5164
5204
  /* no content or whitespace only */
5165
- this.report(node, `<${node.tagName}> cannot be empty, must have text content`);
5205
+ {
5206
+ const message = `<${node.tagName}> cannot be empty, must have text content`;
5207
+ this.report(node, message, node.location);
5208
+ }
5166
5209
  break;
5167
5210
  }
5168
5211
  });
@@ -9440,6 +9483,7 @@ const bundledRules$1 = {
9440
9483
 
9441
9484
  const bundledRules = {
9442
9485
  "allowed-links": AllowedLinks,
9486
+ "aria-hidden-body": AriaHiddenBody,
9443
9487
  "aria-label-misuse": AriaLabelMisuse,
9444
9488
  "attr-case": AttrCase,
9445
9489
  "attr-delimiter": AttrDelimiter,
@@ -9510,6 +9554,7 @@ var defaultConfig = {};
9510
9554
 
9511
9555
  const config$3 = {
9512
9556
  rules: {
9557
+ "aria-hidden-body": "error",
9513
9558
  "aria-label-misuse": "error",
9514
9559
  "deprecated-rule": "warn",
9515
9560
  "empty-heading": "error",
@@ -9544,6 +9589,7 @@ const config$2 = {
9544
9589
 
9545
9590
  const config$1 = {
9546
9591
  rules: {
9592
+ "aria-hidden-body": "error",
9547
9593
  "aria-label-misuse": "error",
9548
9594
  "attr-case": "error",
9549
9595
  "attr-delimiter": "error",