html-validate 8.18.0 → 8.18.1

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
@@ -6278,8 +6278,8 @@ class FormDupName extends Rule {
6278
6278
  if (!attr || !haveName(name)) {
6279
6279
  continue;
6280
6280
  }
6281
- const form = control.closest("form") ?? document.root;
6282
- this.validateUniqueName(control, form, attr, name);
6281
+ const group = control.closest("form, template") ?? document.root;
6282
+ this.validateUniqueName(control, group, attr, name);
6283
6283
  }
6284
6284
  for (const control of sharedControls) {
6285
6285
  const attr = control.getAttribute("name");
@@ -6287,13 +6287,13 @@ class FormDupName extends Rule {
6287
6287
  if (!attr || !haveName(name)) {
6288
6288
  continue;
6289
6289
  }
6290
- const form = control.closest("form") ?? document.root;
6291
- this.validateSharedName(control, form, attr, name);
6290
+ const group = control.closest("form, template") ?? document.root;
6291
+ this.validateSharedName(control, group, attr, name);
6292
6292
  }
6293
6293
  });
6294
6294
  }
6295
- validateUniqueName(control, form, attr, name) {
6296
- const elements = this.getUniqueElements(form);
6295
+ validateUniqueName(control, group, attr, name) {
6296
+ const elements = this.getUniqueElements(group);
6297
6297
  const { allowArrayBrackets } = this.options;
6298
6298
  if (allowArrayBrackets) {
6299
6299
  const isarray = name.endsWith("[]");
@@ -6338,9 +6338,9 @@ class FormDupName extends Rule {
6338
6338
  });
6339
6339
  }
6340
6340
  }
6341
- validateSharedName(control, form, attr, name) {
6342
- const uniqueElements = this.getUniqueElements(form);
6343
- const sharedElements = this.getSharedElements(form);
6341
+ validateSharedName(control, group, attr, name) {
6342
+ const uniqueElements = this.getUniqueElements(group);
6343
+ const sharedElements = this.getSharedElements(group);
6344
6344
  const type = control.getAttributeValue("type") ?? "";
6345
6345
  if (uniqueElements.has(name) || sharedElements.has(name) && sharedElements.get(name) !== type) {
6346
6346
  const context = {
@@ -6369,23 +6369,23 @@ class FormDupName extends Rule {
6369
6369
  }
6370
6370
  return meta.formAssociated.listed;
6371
6371
  }
6372
- getUniqueElements(form) {
6373
- const existing = form.cacheGet(UNIQUE_CACHE_KEY);
6372
+ getUniqueElements(group) {
6373
+ const existing = group.cacheGet(UNIQUE_CACHE_KEY);
6374
6374
  if (existing) {
6375
6375
  return existing;
6376
6376
  } else {
6377
6377
  const elements = /* @__PURE__ */ new Map();
6378
- form.cacheSet(UNIQUE_CACHE_KEY, elements);
6378
+ group.cacheSet(UNIQUE_CACHE_KEY, elements);
6379
6379
  return elements;
6380
6380
  }
6381
6381
  }
6382
- getSharedElements(form) {
6383
- const existing = form.cacheGet(SHARED_CACHE_KEY);
6382
+ getSharedElements(group) {
6383
+ const existing = group.cacheGet(SHARED_CACHE_KEY);
6384
6384
  if (existing) {
6385
6385
  return existing;
6386
6386
  } else {
6387
6387
  const elements = /* @__PURE__ */ new Map();
6388
- form.cacheSet(SHARED_CACHE_KEY, elements);
6388
+ group.cacheSet(SHARED_CACHE_KEY, elements);
6389
6389
  return elements;
6390
6390
  }
6391
6391
  }
@@ -7475,6 +7475,7 @@ class NoDupClass extends Rule {
7475
7475
  }
7476
7476
  }
7477
7477
 
7478
+ const CACHE_KEY = Symbol("no-dup-id");
7478
7479
  class NoDupID extends Rule {
7479
7480
  documentation() {
7480
7481
  return {
@@ -7485,7 +7486,6 @@ class NoDupID extends Rule {
7485
7486
  setup() {
7486
7487
  this.on("dom:ready", (event) => {
7487
7488
  const { document } = event;
7488
- const existing = /* @__PURE__ */ new Set();
7489
7489
  const elements = document.querySelectorAll("[id]");
7490
7490
  const relevant = elements.filter(isRelevant$3);
7491
7491
  for (const el of relevant) {
@@ -7494,6 +7494,7 @@ class NoDupID extends Rule {
7494
7494
  continue;
7495
7495
  }
7496
7496
  const id = attr.value.toString();
7497
+ const existing = getExisting(el, document.root);
7497
7498
  if (existing.has(id)) {
7498
7499
  this.report(el, `Duplicate ID "${id}"`, attr.valueLocation);
7499
7500
  }
@@ -7502,6 +7503,16 @@ class NoDupID extends Rule {
7502
7503
  });
7503
7504
  }
7504
7505
  }
7506
+ function getExisting(element, root) {
7507
+ const group = element.closest("template") ?? root;
7508
+ const existing = group.cacheGet(CACHE_KEY);
7509
+ if (existing) {
7510
+ return existing;
7511
+ } else {
7512
+ const existing2 = /* @__PURE__ */ new Set();
7513
+ return group.cacheSet(CACHE_KEY, existing2);
7514
+ }
7515
+ }
7505
7516
  function isRelevant$3(element) {
7506
7517
  const attr = element.getAttribute("id");
7507
7518
  if (!attr) {
@@ -12678,7 +12689,7 @@ class HtmlValidate {
12678
12689
  }
12679
12690
 
12680
12691
  const name = "html-validate";
12681
- const version = "8.18.0";
12692
+ const version = "8.18.1";
12682
12693
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
12683
12694
 
12684
12695
  function definePlugin(plugin) {