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/esm/core.js CHANGED
@@ -889,6 +889,31 @@ const definitions = {
889
889
  },
890
890
  {
891
891
  regexp: true
892
+ },
893
+ {
894
+ type: "object",
895
+ title: "Named regular expression",
896
+ required: [
897
+ "name",
898
+ "pattern"
899
+ ],
900
+ additionalProperties: false,
901
+ properties: {
902
+ name: {
903
+ type: "string",
904
+ minLength: 1
905
+ },
906
+ pattern: {
907
+ anyOf: [
908
+ {
909
+ type: "string"
910
+ },
911
+ {
912
+ regexp: true
913
+ }
914
+ ]
915
+ }
916
+ }
892
917
  }
893
918
  ]
894
919
  }
@@ -897,6 +922,13 @@ const definitions = {
897
922
  type: "boolean",
898
923
  title: "Set to true if this attribute can optionally omit its value"
899
924
  },
925
+ reference: {
926
+ type: "string",
927
+ "enum": [
928
+ "id"
929
+ ],
930
+ title: "Set when the attribute references another element."
931
+ },
900
932
  required: {
901
933
  title: "Set to true or a function to evaluate if this attribute is required",
902
934
  oneOf: [
@@ -1484,10 +1516,7 @@ function expandProperties(node, entry) {
1484
1516
  setMetaProperty(entry, "focusable", entry.focusable(node._adapter));
1485
1517
  }
1486
1518
  }
1487
- function expandRegexValue(value) {
1488
- if (value instanceof RegExp) {
1489
- return value;
1490
- }
1519
+ function compileRegexString(value) {
1491
1520
  const match = /^\/(.*(?=\/))\/(i?)$/.exec(value);
1492
1521
  if (match) {
1493
1522
  const [, expr, flags] = match;
@@ -1496,9 +1525,28 @@ function expandRegexValue(value) {
1496
1525
  } else {
1497
1526
  return new RegExp(`^${expr}$`, flags);
1498
1527
  }
1499
- } else {
1500
- return value;
1501
1528
  }
1529
+ return null;
1530
+ }
1531
+ function expandRegexValue(value) {
1532
+ if (value instanceof RegExp) {
1533
+ return { name: value.toString(), pattern: value };
1534
+ }
1535
+ if (typeof value === "object") {
1536
+ if (value.pattern instanceof RegExp) {
1537
+ return { name: value.name, pattern: value.pattern };
1538
+ }
1539
+ const compiled = compileRegexString(value.pattern);
1540
+ if (!compiled) {
1541
+ throw new Error(`Failed to create regular expression from "${value.pattern}"`);
1542
+ }
1543
+ return { name: value.name, pattern: compiled };
1544
+ }
1545
+ const regex = compileRegexString(value);
1546
+ if (regex) {
1547
+ return { name: regex.toString(), pattern: regex };
1548
+ }
1549
+ return value;
1502
1550
  }
1503
1551
  function expandRegex(entry) {
1504
1552
  for (const [name, values] of Object.entries(entry.attributes)) {
@@ -3316,10 +3364,14 @@ class Validator {
3316
3364
  }
3317
3365
  const caseInsensitiveValue = value.toLowerCase();
3318
3366
  return rule.enum.some((entry) => {
3319
- if (entry instanceof RegExp) {
3367
+ if (typeof entry === "string") {
3368
+ return caseInsensitiveValue === entry;
3369
+ } else if (entry instanceof RegExp) {
3320
3370
  return entry.test(value);
3371
+ } else if (entry.pattern instanceof RegExp) {
3372
+ return entry.pattern.test(value);
3321
3373
  } else {
3322
- return caseInsensitiveValue === entry;
3374
+ throw new TypeError("RegExp was not precompiled when it should have been");
3323
3375
  }
3324
3376
  });
3325
3377
  }
@@ -5390,8 +5442,10 @@ class AttributeAllowedValues extends Rule {
5390
5442
  const allowedList = allowed.enum.map((value2) => {
5391
5443
  if (typeof value2 === "string") {
5392
5444
  return `- \`"${value2}"\``;
5393
- } else {
5445
+ } else if (value2 instanceof RegExp) {
5394
5446
  return `- \`${value2.toString()}\``;
5447
+ } else {
5448
+ return `- ${value2.name}`;
5395
5449
  }
5396
5450
  });
5397
5451
  docs.description = [
@@ -7542,10 +7596,58 @@ class IdPattern extends BasePatternRule {
7542
7596
 
7543
7597
  const restricted = /* @__PURE__ */ new Map([
7544
7598
  ["accept", ["file"]],
7599
+ ["alpha", ["color"]],
7545
7600
  ["alt", ["image"]],
7601
+ [
7602
+ "autocapitalize",
7603
+ [
7604
+ "button",
7605
+ "checkbox",
7606
+ "color",
7607
+ "date",
7608
+ "datetime-local",
7609
+ "file",
7610
+ "hidden",
7611
+ "image",
7612
+ "month",
7613
+ "number",
7614
+ "radio",
7615
+ "range",
7616
+ "reset",
7617
+ "search",
7618
+ "submit",
7619
+ "tel",
7620
+ "text",
7621
+ "time",
7622
+ "week"
7623
+ ]
7624
+ ],
7625
+ [
7626
+ "autocomplete",
7627
+ [
7628
+ "color",
7629
+ "date",
7630
+ "datetime-local",
7631
+ "email",
7632
+ "file",
7633
+ "hidden",
7634
+ "image",
7635
+ "month",
7636
+ "number",
7637
+ "password",
7638
+ "range",
7639
+ "search",
7640
+ "tel",
7641
+ "text",
7642
+ "time",
7643
+ "url",
7644
+ "week"
7645
+ ]
7646
+ ],
7546
7647
  ["capture", ["file"]],
7547
7648
  ["checked", ["checkbox", "radio"]],
7548
- ["dirname", ["text", "search"]],
7649
+ ["colorspace", ["color"]],
7650
+ ["dirname", ["hidden", "text", "search", "url", "tel", "email"]],
7549
7651
  ["height", ["image"]],
7550
7652
  [
7551
7653
  "list",
@@ -7572,6 +7674,8 @@ const restricted = /* @__PURE__ */ new Map([
7572
7674
  ["multiple", ["email", "file"]],
7573
7675
  ["pattern", ["text", "search", "url", "tel", "email", "password"]],
7574
7676
  ["placeholder", ["text", "search", "url", "tel", "email", "password", "number"]],
7677
+ ["popovertarget", ["button"]],
7678
+ ["popovertargetaction", ["button"]],
7575
7679
  [
7576
7680
  "readonly",
7577
7681
  [
@@ -7612,6 +7716,31 @@ const restricted = /* @__PURE__ */ new Map([
7612
7716
  ["size", ["text", "search", "url", "tel", "email", "password"]],
7613
7717
  ["src", ["image"]],
7614
7718
  ["step", ["date", "month", "week", "time", "datetime-local", "number", "range"]],
7719
+ [
7720
+ "value",
7721
+ [
7722
+ "button",
7723
+ "checkbox",
7724
+ "color",
7725
+ "date",
7726
+ "datetime-local",
7727
+ "email",
7728
+ "hidden",
7729
+ "month",
7730
+ "number",
7731
+ "password",
7732
+ "radio",
7733
+ "range",
7734
+ "reset",
7735
+ "search",
7736
+ "submit",
7737
+ "tel",
7738
+ "text",
7739
+ "time",
7740
+ "url",
7741
+ "week"
7742
+ ]
7743
+ ],
7615
7744
  ["width", ["image"]]
7616
7745
  ]);
7617
7746
  function isInput(event) {
@@ -8603,16 +8732,6 @@ class NoInlineStyle extends Rule {
8603
8732
  }
8604
8733
  }
8605
8734
 
8606
- const ARIA = [
8607
- { property: "aria-activedescendant", isList: false },
8608
- { property: "aria-controls", isList: true },
8609
- { property: "aria-describedby", isList: true },
8610
- { property: "aria-details", isList: false },
8611
- { property: "aria-errormessage", isList: false },
8612
- { property: "aria-flowto", isList: true },
8613
- { property: "aria-labelledby", isList: true },
8614
- { property: "aria-owns", isList: true }
8615
- ];
8616
8735
  function idMissing(document, id) {
8617
8736
  const nodes = document.querySelectorAll(generateIdSelector(id));
8618
8737
  return nodes.length === 0;
@@ -8627,20 +8746,18 @@ class NoMissingReferences extends Rule {
8627
8746
  setup() {
8628
8747
  this.on("dom:ready", (event) => {
8629
8748
  const document = event.document;
8630
- for (const node of document.querySelectorAll("label[for]")) {
8631
- const attr = node.getAttribute("for");
8632
- this.validateReference(document, node, attr, false);
8633
- }
8634
- for (const node of document.querySelectorAll("input[list]")) {
8635
- const attr = node.getAttribute("list");
8636
- this.validateReference(document, node, attr, false);
8637
- }
8638
- for (const { property, isList } of ARIA) {
8639
- for (const node of document.querySelectorAll(`[${property}]`)) {
8640
- const attr = node.getAttribute(property);
8641
- this.validateReference(document, node, attr, isList);
8749
+ walk.depthFirst(document, (node) => {
8750
+ const meta = node.meta;
8751
+ if (!meta?.attributes) {
8752
+ return;
8642
8753
  }
8643
- }
8754
+ for (const attr of node.attributes) {
8755
+ const attrMeta = meta.attributes[attr.key];
8756
+ if (attrMeta?.reference === "id") {
8757
+ this.validateReference(document, node, attr, attrMeta.list ?? false);
8758
+ }
8759
+ }
8760
+ });
8644
8761
  });
8645
8762
  }
8646
8763
  validateReference(document, node, attr, isList) {
@@ -11803,7 +11920,8 @@ class ResolvedConfig {
11803
11920
  /**
11804
11921
  * @internal
11805
11922
  */
11806
- constructor({ metaTable, plugins, rules, transformers }, original) {
11923
+ constructor(options, original) {
11924
+ const { metaTable, plugins, rules, transformers } = options;
11807
11925
  this.metaTable = metaTable;
11808
11926
  this.plugins = plugins;
11809
11927
  this.rules = rules;
@@ -12705,7 +12823,7 @@ class EventHandler {
12705
12823
  }
12706
12824
 
12707
12825
  const name = "html-validate";
12708
- const version = "11.3.0";
12826
+ const version = "11.5.0";
12709
12827
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
12710
12828
 
12711
12829
  function freeze(src) {
@@ -15412,12 +15530,12 @@ var ignoreExports = /*@__PURE__*/ requireIgnore();
15412
15530
  var ignore = /*@__PURE__*/getDefaultExportFromCjs(ignoreExports);
15413
15531
 
15414
15532
  const engines = {
15415
- node: "^22.17.0 || >= 24.0.0"
15533
+ node: "^22.22.0 || >= 24.8.0"
15416
15534
  };
15417
15535
 
15418
15536
  var jestWorkerPath = "./jest-worker.js";
15419
15537
 
15420
15538
  var vitestWorkerPath = "./vitest-worker.js";
15421
15539
 
15422
- export { transformFilename as $, Attribute as A, getEndLocation as B, Config as C, DOMNode as D, Engine as E, getFormatter as F, getStartLocation as G, HtmlElement as H, ignore as I, isThenable as J, isUserError as K, jestWorkerPath as L, MetaCopyableProperty as M, NestedError as N, keywordPatternMatcher as O, Parser as P, name as Q, Reporter as R, SchemaValidationError as S, TextClassification as T, UserError as U, normalizeSource as V, WrappedError as W, presets as X, ruleExists as Y, sliceLocation as Z, staticResolver as _, ConfigError as a, transformFilenameSync as a0, transformSource as a1, transformSourceSync as a2, version as a3, vitestWorkerPath as a4, walk as a5, ConfigLoader as b, DOMTokenList as c, DOMTree as d, DynamicValue as e, EventHandler as f, MetaTable as g, Node as h, PerformanceTracker as i, ResolvedConfig as j, Rule as k, Severity as l, StaticConfigLoader as m, TextContent$1 as n, TextNode as o, ariaNaming as p, bugs as q, classifyNodeText as r, codeFrameColumns as s, compatibilityCheckImpl as t, configurationSchema as u, deepmerge as v, defineConfig as w, definePlugin as x, engines as y, ensureError as z };
15540
+ export { name as $, Attribute as A, configurationSchema as B, Config as C, DOMNode as D, Engine as E, deepmerge as F, defineConfig as G, HtmlElement as H, definePlugin as I, engines as J, ensureError as K, getEndLocation as L, MetaCopyableProperty as M, NestedError as N, getFormatter as O, Parser as P, getStartLocation as Q, Reporter as R, SchemaValidationError as S, TextClassification as T, UserError as U, ignore as V, WrappedError as W, isThenable as X, isUserError as Y, jestWorkerPath as Z, keywordPatternMatcher as _, ConfigError as a, normalizeSource as a0, parseSeverity as a1, presets as a2, ruleExists as a3, sliceLocation as a4, staticResolver as a5, transformFilename as a6, transformFilenameSync as a7, transformSource as a8, transformSourceSync as a9, version as aa, vitestWorkerPath as ab, walk as ac, ConfigLoader as b, DOMTokenList as c, DOMTree as d, DynamicValue as e, EventHandler as f, MetaTable as g, Node as h, PerformanceTracker as i, ResolvedConfig as j, Rule as k, Severity as l, StaticConfigLoader as m, TextContent$1 as n, TextNode as o, ariaNaming as p, bugs as q, classifyNodeText as r, codeFrameColumns as s, compatibilityCheckImpl as t, config$5 as u, config$4 as v, config$3 as w, config$2 as x, config$1 as y, config as z };
15423
15541
  //# sourceMappingURL=core.js.map