html-validate 8.11.1 → 8.13.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
@@ -737,6 +737,9 @@ const definitions = {
737
737
  },
738
738
  {
739
739
  $ref: "#/definitions/expression"
740
+ },
741
+ {
742
+ "function": true
740
743
  }
741
744
  ]
742
745
  },
@@ -1375,7 +1378,12 @@ class MetaTable {
1375
1378
  function expandProperties(node, entry) {
1376
1379
  for (const key of dynamicKeys) {
1377
1380
  const property = entry[key];
1378
- if (property && typeof property !== "boolean") {
1381
+ if (!property) {
1382
+ continue;
1383
+ }
1384
+ if (typeof property === "function") {
1385
+ setMetaProperty(entry, key, property(node._adapter));
1386
+ } else if (typeof property !== "boolean") {
1379
1387
  setMetaProperty(entry, key, evaluateProperty(node, property));
1380
1388
  }
1381
1389
  }
@@ -6277,7 +6285,7 @@ const defaults$h = {
6277
6285
  minInitialRank: "h1",
6278
6286
  sectioningRoots: ["dialog", '[role="dialog"]', '[role="alertdialog"]']
6279
6287
  };
6280
- function isRelevant$5(event) {
6288
+ function isRelevant$6(event) {
6281
6289
  const node = event.target;
6282
6290
  return Boolean(node.meta && node.meta.heading);
6283
6291
  }
@@ -6344,7 +6352,7 @@ class HeadingLevel extends Rule {
6344
6352
  };
6345
6353
  }
6346
6354
  setup() {
6347
- this.on("tag:start", isRelevant$5, (event) => {
6355
+ this.on("tag:start", isRelevant$6, (event) => {
6348
6356
  this.onTagStart(event);
6349
6357
  });
6350
6358
  this.on("tag:ready", (event) => {
@@ -6984,7 +6992,7 @@ class MapDupName extends Rule {
6984
6992
  }
6985
6993
  }
6986
6994
 
6987
- function isRelevant$4(event) {
6995
+ function isRelevant$5(event) {
6988
6996
  return event.target.is("map");
6989
6997
  }
6990
6998
  function hasStaticValue(attr) {
@@ -6998,7 +7006,7 @@ class MapIdName extends Rule {
6998
7006
  };
6999
7007
  }
7000
7008
  setup() {
7001
- this.on("tag:ready", isRelevant$4, (event) => {
7009
+ this.on("tag:ready", isRelevant$5, (event) => {
7002
7010
  const { target } = event;
7003
7011
  const id = target.getAttribute("id");
7004
7012
  const name = target.getAttribute("name");
@@ -7073,6 +7081,62 @@ class MultipleLabeledControls extends Rule {
7073
7081
  }
7074
7082
  }
7075
7083
 
7084
+ const abstractRoles = [
7085
+ "command",
7086
+ "composite",
7087
+ "input",
7088
+ "landmark",
7089
+ "range",
7090
+ "roletype",
7091
+ "section",
7092
+ "sectionhead",
7093
+ "select",
7094
+ "structure",
7095
+ "widget",
7096
+ "window"
7097
+ ];
7098
+ function isRelevant$4(event) {
7099
+ return event.key === "role";
7100
+ }
7101
+ class NoAbstractRole extends Rule {
7102
+ documentation(context) {
7103
+ return {
7104
+ description: [
7105
+ `Role \`"${context.role}"\` is abstract and must not be used.`,
7106
+ "",
7107
+ "WAI-ARIA defines a list of [abstract roles](https://www.w3.org/TR/wai-aria-1.2/#abstract_roles) which cannot be used by authors:",
7108
+ "",
7109
+ ...abstractRoles.map((it) => `- \`"${it}"\``),
7110
+ "",
7111
+ `Use one of the defined subclass roles for \`"${context.role}"\` instead.`
7112
+ ].join("\n"),
7113
+ url: "https://html-validate.org/rules/no-abstract-role.html"
7114
+ };
7115
+ }
7116
+ setup() {
7117
+ this.on("attr", isRelevant$4, (event) => {
7118
+ const roles = event.value;
7119
+ if (!roles || roles instanceof DynamicValue) {
7120
+ return;
7121
+ }
7122
+ const tokens = new DOMTokenList(roles, event.valueLocation);
7123
+ for (const { item: role, location } of tokens.iterator()) {
7124
+ if (!abstractRoles.includes(role)) {
7125
+ continue;
7126
+ }
7127
+ this.report({
7128
+ node: event.target,
7129
+ message: `Role "{{ role }}" is abstract and must not be used`,
7130
+ location,
7131
+ context: {
7132
+ role
7133
+ }
7134
+ });
7135
+ }
7136
+ });
7137
+ }
7138
+ }
7139
+
7076
7140
  const defaults$e = {
7077
7141
  include: null,
7078
7142
  exclude: null
@@ -9482,6 +9546,7 @@ const bundledRules = {
9482
9546
  "meta-refresh": MetaRefresh,
9483
9547
  "missing-doctype": MissingDoctype,
9484
9548
  "multiple-labeled-controls": MultipleLabeledControls,
9549
+ "no-abstract-role": NoAbstractRole,
9485
9550
  "no-autoplay": NoAutoplay,
9486
9551
  "no-conditional-comment": NoConditionalComment,
9487
9552
  "no-deprecated-attr": NoDeprecatedAttr,
@@ -9535,6 +9600,7 @@ const config$4 = {
9535
9600
  "hidden-focusable": "error",
9536
9601
  "meta-refresh": "error",
9537
9602
  "multiple-labeled-controls": "error",
9603
+ "no-abstract-role": "error",
9538
9604
  "no-autoplay": ["error", { include: ["audio", "video"] }],
9539
9605
  "no-dup-id": "error",
9540
9606
  "no-implicit-button-type": "error",
@@ -9614,6 +9680,7 @@ const config$1 = {
9614
9680
  "map-id-name": "error",
9615
9681
  "meta-refresh": "error",
9616
9682
  "multiple-labeled-controls": "error",
9683
+ "no-abstract-role": "error",
9617
9684
  "no-autoplay": ["error", { include: ["audio", "video"] }],
9618
9685
  "no-conditional-comment": "error",
9619
9686
  "no-deprecated-attr": "error",
@@ -9681,6 +9748,7 @@ const config = {
9681
9748
  "map-dup-name": "error",
9682
9749
  "map-id-name": "error",
9683
9750
  "multiple-labeled-controls": "error",
9751
+ "no-abstract-role": "error",
9684
9752
  "no-deprecated-attr": "error",
9685
9753
  "no-dup-attr": "error",
9686
9754
  "no-dup-id": "error",
@@ -11914,7 +11982,7 @@ class HtmlValidate {
11914
11982
  }
11915
11983
 
11916
11984
  const name = "html-validate";
11917
- const version = "8.11.1";
11985
+ const version = "8.13.0";
11918
11986
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
11919
11987
 
11920
11988
  function definePlugin(plugin) {