html-validate 11.3.0 → 11.5.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
@@ -898,6 +898,31 @@ const definitions = {
898
898
  },
899
899
  {
900
900
  regexp: true
901
+ },
902
+ {
903
+ type: "object",
904
+ title: "Named regular expression",
905
+ required: [
906
+ "name",
907
+ "pattern"
908
+ ],
909
+ additionalProperties: false,
910
+ properties: {
911
+ name: {
912
+ type: "string",
913
+ minLength: 1
914
+ },
915
+ pattern: {
916
+ anyOf: [
917
+ {
918
+ type: "string"
919
+ },
920
+ {
921
+ regexp: true
922
+ }
923
+ ]
924
+ }
925
+ }
901
926
  }
902
927
  ]
903
928
  }
@@ -906,6 +931,13 @@ const definitions = {
906
931
  type: "boolean",
907
932
  title: "Set to true if this attribute can optionally omit its value"
908
933
  },
934
+ reference: {
935
+ type: "string",
936
+ "enum": [
937
+ "id"
938
+ ],
939
+ title: "Set when the attribute references another element."
940
+ },
909
941
  required: {
910
942
  title: "Set to true or a function to evaluate if this attribute is required",
911
943
  oneOf: [
@@ -1493,10 +1525,7 @@ function expandProperties(node, entry) {
1493
1525
  setMetaProperty(entry, "focusable", entry.focusable(node._adapter));
1494
1526
  }
1495
1527
  }
1496
- function expandRegexValue(value) {
1497
- if (value instanceof RegExp) {
1498
- return value;
1499
- }
1528
+ function compileRegexString(value) {
1500
1529
  const match = /^\/(.*(?=\/))\/(i?)$/.exec(value);
1501
1530
  if (match) {
1502
1531
  const [, expr, flags] = match;
@@ -1505,9 +1534,28 @@ function expandRegexValue(value) {
1505
1534
  } else {
1506
1535
  return new RegExp(`^${expr}$`, flags);
1507
1536
  }
1508
- } else {
1509
- return value;
1510
1537
  }
1538
+ return null;
1539
+ }
1540
+ function expandRegexValue(value) {
1541
+ if (value instanceof RegExp) {
1542
+ return { name: value.toString(), pattern: value };
1543
+ }
1544
+ if (typeof value === "object") {
1545
+ if (value.pattern instanceof RegExp) {
1546
+ return { name: value.name, pattern: value.pattern };
1547
+ }
1548
+ const compiled = compileRegexString(value.pattern);
1549
+ if (!compiled) {
1550
+ throw new Error(`Failed to create regular expression from "${value.pattern}"`);
1551
+ }
1552
+ return { name: value.name, pattern: compiled };
1553
+ }
1554
+ const regex = compileRegexString(value);
1555
+ if (regex) {
1556
+ return { name: regex.toString(), pattern: regex };
1557
+ }
1558
+ return value;
1511
1559
  }
1512
1560
  function expandRegex(entry) {
1513
1561
  for (const [name, values] of Object.entries(entry.attributes)) {
@@ -3325,10 +3373,14 @@ class Validator {
3325
3373
  }
3326
3374
  const caseInsensitiveValue = value.toLowerCase();
3327
3375
  return rule.enum.some((entry) => {
3328
- if (entry instanceof RegExp) {
3376
+ if (typeof entry === "string") {
3377
+ return caseInsensitiveValue === entry;
3378
+ } else if (entry instanceof RegExp) {
3329
3379
  return entry.test(value);
3380
+ } else if (entry.pattern instanceof RegExp) {
3381
+ return entry.pattern.test(value);
3330
3382
  } else {
3331
- return caseInsensitiveValue === entry;
3383
+ throw new TypeError("RegExp was not precompiled when it should have been");
3332
3384
  }
3333
3385
  });
3334
3386
  }
@@ -5399,8 +5451,10 @@ class AttributeAllowedValues extends Rule {
5399
5451
  const allowedList = allowed.enum.map((value2) => {
5400
5452
  if (typeof value2 === "string") {
5401
5453
  return `- \`"${value2}"\``;
5402
- } else {
5454
+ } else if (value2 instanceof RegExp) {
5403
5455
  return `- \`${value2.toString()}\``;
5456
+ } else {
5457
+ return `- ${value2.name}`;
5404
5458
  }
5405
5459
  });
5406
5460
  docs.description = [
@@ -7551,10 +7605,58 @@ class IdPattern extends BasePatternRule {
7551
7605
 
7552
7606
  const restricted = /* @__PURE__ */ new Map([
7553
7607
  ["accept", ["file"]],
7608
+ ["alpha", ["color"]],
7554
7609
  ["alt", ["image"]],
7610
+ [
7611
+ "autocapitalize",
7612
+ [
7613
+ "button",
7614
+ "checkbox",
7615
+ "color",
7616
+ "date",
7617
+ "datetime-local",
7618
+ "file",
7619
+ "hidden",
7620
+ "image",
7621
+ "month",
7622
+ "number",
7623
+ "radio",
7624
+ "range",
7625
+ "reset",
7626
+ "search",
7627
+ "submit",
7628
+ "tel",
7629
+ "text",
7630
+ "time",
7631
+ "week"
7632
+ ]
7633
+ ],
7634
+ [
7635
+ "autocomplete",
7636
+ [
7637
+ "color",
7638
+ "date",
7639
+ "datetime-local",
7640
+ "email",
7641
+ "file",
7642
+ "hidden",
7643
+ "image",
7644
+ "month",
7645
+ "number",
7646
+ "password",
7647
+ "range",
7648
+ "search",
7649
+ "tel",
7650
+ "text",
7651
+ "time",
7652
+ "url",
7653
+ "week"
7654
+ ]
7655
+ ],
7555
7656
  ["capture", ["file"]],
7556
7657
  ["checked", ["checkbox", "radio"]],
7557
- ["dirname", ["text", "search"]],
7658
+ ["colorspace", ["color"]],
7659
+ ["dirname", ["hidden", "text", "search", "url", "tel", "email"]],
7558
7660
  ["height", ["image"]],
7559
7661
  [
7560
7662
  "list",
@@ -7581,6 +7683,8 @@ const restricted = /* @__PURE__ */ new Map([
7581
7683
  ["multiple", ["email", "file"]],
7582
7684
  ["pattern", ["text", "search", "url", "tel", "email", "password"]],
7583
7685
  ["placeholder", ["text", "search", "url", "tel", "email", "password", "number"]],
7686
+ ["popovertarget", ["button"]],
7687
+ ["popovertargetaction", ["button"]],
7584
7688
  [
7585
7689
  "readonly",
7586
7690
  [
@@ -7621,6 +7725,31 @@ const restricted = /* @__PURE__ */ new Map([
7621
7725
  ["size", ["text", "search", "url", "tel", "email", "password"]],
7622
7726
  ["src", ["image"]],
7623
7727
  ["step", ["date", "month", "week", "time", "datetime-local", "number", "range"]],
7728
+ [
7729
+ "value",
7730
+ [
7731
+ "button",
7732
+ "checkbox",
7733
+ "color",
7734
+ "date",
7735
+ "datetime-local",
7736
+ "email",
7737
+ "hidden",
7738
+ "month",
7739
+ "number",
7740
+ "password",
7741
+ "radio",
7742
+ "range",
7743
+ "reset",
7744
+ "search",
7745
+ "submit",
7746
+ "tel",
7747
+ "text",
7748
+ "time",
7749
+ "url",
7750
+ "week"
7751
+ ]
7752
+ ],
7624
7753
  ["width", ["image"]]
7625
7754
  ]);
7626
7755
  function isInput(event) {
@@ -8612,16 +8741,6 @@ class NoInlineStyle extends Rule {
8612
8741
  }
8613
8742
  }
8614
8743
 
8615
- const ARIA = [
8616
- { property: "aria-activedescendant", isList: false },
8617
- { property: "aria-controls", isList: true },
8618
- { property: "aria-describedby", isList: true },
8619
- { property: "aria-details", isList: false },
8620
- { property: "aria-errormessage", isList: false },
8621
- { property: "aria-flowto", isList: true },
8622
- { property: "aria-labelledby", isList: true },
8623
- { property: "aria-owns", isList: true }
8624
- ];
8625
8744
  function idMissing(document, id) {
8626
8745
  const nodes = document.querySelectorAll(generateIdSelector(id));
8627
8746
  return nodes.length === 0;
@@ -8636,20 +8755,18 @@ class NoMissingReferences extends Rule {
8636
8755
  setup() {
8637
8756
  this.on("dom:ready", (event) => {
8638
8757
  const document = event.document;
8639
- for (const node of document.querySelectorAll("label[for]")) {
8640
- const attr = node.getAttribute("for");
8641
- this.validateReference(document, node, attr, false);
8642
- }
8643
- for (const node of document.querySelectorAll("input[list]")) {
8644
- const attr = node.getAttribute("list");
8645
- this.validateReference(document, node, attr, false);
8646
- }
8647
- for (const { property, isList } of ARIA) {
8648
- for (const node of document.querySelectorAll(`[${property}]`)) {
8649
- const attr = node.getAttribute(property);
8650
- this.validateReference(document, node, attr, isList);
8758
+ walk.depthFirst(document, (node) => {
8759
+ const meta = node.meta;
8760
+ if (!meta?.attributes) {
8761
+ return;
8651
8762
  }
8652
- }
8763
+ for (const attr of node.attributes) {
8764
+ const attrMeta = meta.attributes[attr.key];
8765
+ if (attrMeta?.reference === "id") {
8766
+ this.validateReference(document, node, attr, attrMeta.list ?? false);
8767
+ }
8768
+ }
8769
+ });
8653
8770
  });
8654
8771
  }
8655
8772
  validateReference(document, node, attr, isList) {
@@ -11812,7 +11929,8 @@ class ResolvedConfig {
11812
11929
  /**
11813
11930
  * @internal
11814
11931
  */
11815
- constructor({ metaTable, plugins, rules, transformers }, original) {
11932
+ constructor(options, original) {
11933
+ const { metaTable, plugins, rules, transformers } = options;
11816
11934
  this.metaTable = metaTable;
11817
11935
  this.plugins = plugins;
11818
11936
  this.rules = rules;
@@ -12714,7 +12832,7 @@ class EventHandler {
12714
12832
  }
12715
12833
 
12716
12834
  const name = "html-validate";
12717
- const version = "11.3.0";
12835
+ const version = "11.5.0";
12718
12836
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
12719
12837
 
12720
12838
  function freeze(src) {
@@ -15421,7 +15539,7 @@ var ignoreExports = /*@__PURE__*/ requireIgnore();
15421
15539
  var ignore = /*@__PURE__*/getDefaultExportFromCjs(ignoreExports);
15422
15540
 
15423
15541
  const engines = {
15424
- node: "^22.17.0 || >= 24.0.0"
15542
+ node: "^22.22.0 || >= 24.8.0"
15425
15543
  };
15426
15544
 
15427
15545
  var jestWorkerPath = "./jest-worker.js";
@@ -15461,6 +15579,12 @@ exports.bugs = bugs;
15461
15579
  exports.classifyNodeText = classifyNodeText;
15462
15580
  exports.codeFrameColumns = codeFrameColumns;
15463
15581
  exports.compatibilityCheckImpl = compatibilityCheckImpl;
15582
+ exports.config = config$5;
15583
+ exports.config$1 = config$4;
15584
+ exports.config$2 = config$3;
15585
+ exports.config$3 = config$2;
15586
+ exports.config$4 = config$1;
15587
+ exports.config$5 = config;
15464
15588
  exports.configurationSchema = configurationSchema;
15465
15589
  exports.deepmerge = deepmerge;
15466
15590
  exports.defineConfig = defineConfig;
@@ -15477,6 +15601,7 @@ exports.jestWorkerPath = jestWorkerPath;
15477
15601
  exports.keywordPatternMatcher = keywordPatternMatcher;
15478
15602
  exports.name = name;
15479
15603
  exports.normalizeSource = normalizeSource;
15604
+ exports.parseSeverity = parseSeverity;
15480
15605
  exports.presets = presets;
15481
15606
  exports.ruleExists = ruleExists;
15482
15607
  exports.sliceLocation = sliceLocation;