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/es/core.js CHANGED
@@ -6268,8 +6268,8 @@ class FormDupName extends Rule {
6268
6268
  if (!attr || !haveName(name)) {
6269
6269
  continue;
6270
6270
  }
6271
- const form = control.closest("form") ?? document.root;
6272
- this.validateUniqueName(control, form, attr, name);
6271
+ const group = control.closest("form, template") ?? document.root;
6272
+ this.validateUniqueName(control, group, attr, name);
6273
6273
  }
6274
6274
  for (const control of sharedControls) {
6275
6275
  const attr = control.getAttribute("name");
@@ -6277,13 +6277,13 @@ class FormDupName extends Rule {
6277
6277
  if (!attr || !haveName(name)) {
6278
6278
  continue;
6279
6279
  }
6280
- const form = control.closest("form") ?? document.root;
6281
- this.validateSharedName(control, form, attr, name);
6280
+ const group = control.closest("form, template") ?? document.root;
6281
+ this.validateSharedName(control, group, attr, name);
6282
6282
  }
6283
6283
  });
6284
6284
  }
6285
- validateUniqueName(control, form, attr, name) {
6286
- const elements = this.getUniqueElements(form);
6285
+ validateUniqueName(control, group, attr, name) {
6286
+ const elements = this.getUniqueElements(group);
6287
6287
  const { allowArrayBrackets } = this.options;
6288
6288
  if (allowArrayBrackets) {
6289
6289
  const isarray = name.endsWith("[]");
@@ -6328,9 +6328,9 @@ class FormDupName extends Rule {
6328
6328
  });
6329
6329
  }
6330
6330
  }
6331
- validateSharedName(control, form, attr, name) {
6332
- const uniqueElements = this.getUniqueElements(form);
6333
- const sharedElements = this.getSharedElements(form);
6331
+ validateSharedName(control, group, attr, name) {
6332
+ const uniqueElements = this.getUniqueElements(group);
6333
+ const sharedElements = this.getSharedElements(group);
6334
6334
  const type = control.getAttributeValue("type") ?? "";
6335
6335
  if (uniqueElements.has(name) || sharedElements.has(name) && sharedElements.get(name) !== type) {
6336
6336
  const context = {
@@ -6359,23 +6359,23 @@ class FormDupName extends Rule {
6359
6359
  }
6360
6360
  return meta.formAssociated.listed;
6361
6361
  }
6362
- getUniqueElements(form) {
6363
- const existing = form.cacheGet(UNIQUE_CACHE_KEY);
6362
+ getUniqueElements(group) {
6363
+ const existing = group.cacheGet(UNIQUE_CACHE_KEY);
6364
6364
  if (existing) {
6365
6365
  return existing;
6366
6366
  } else {
6367
6367
  const elements = /* @__PURE__ */ new Map();
6368
- form.cacheSet(UNIQUE_CACHE_KEY, elements);
6368
+ group.cacheSet(UNIQUE_CACHE_KEY, elements);
6369
6369
  return elements;
6370
6370
  }
6371
6371
  }
6372
- getSharedElements(form) {
6373
- const existing = form.cacheGet(SHARED_CACHE_KEY);
6372
+ getSharedElements(group) {
6373
+ const existing = group.cacheGet(SHARED_CACHE_KEY);
6374
6374
  if (existing) {
6375
6375
  return existing;
6376
6376
  } else {
6377
6377
  const elements = /* @__PURE__ */ new Map();
6378
- form.cacheSet(SHARED_CACHE_KEY, elements);
6378
+ group.cacheSet(SHARED_CACHE_KEY, elements);
6379
6379
  return elements;
6380
6380
  }
6381
6381
  }
@@ -7465,6 +7465,7 @@ class NoDupClass extends Rule {
7465
7465
  }
7466
7466
  }
7467
7467
 
7468
+ const CACHE_KEY = Symbol("no-dup-id");
7468
7469
  class NoDupID extends Rule {
7469
7470
  documentation() {
7470
7471
  return {
@@ -7475,7 +7476,6 @@ class NoDupID extends Rule {
7475
7476
  setup() {
7476
7477
  this.on("dom:ready", (event) => {
7477
7478
  const { document } = event;
7478
- const existing = /* @__PURE__ */ new Set();
7479
7479
  const elements = document.querySelectorAll("[id]");
7480
7480
  const relevant = elements.filter(isRelevant$3);
7481
7481
  for (const el of relevant) {
@@ -7484,6 +7484,7 @@ class NoDupID extends Rule {
7484
7484
  continue;
7485
7485
  }
7486
7486
  const id = attr.value.toString();
7487
+ const existing = getExisting(el, document.root);
7487
7488
  if (existing.has(id)) {
7488
7489
  this.report(el, `Duplicate ID "${id}"`, attr.valueLocation);
7489
7490
  }
@@ -7492,6 +7493,16 @@ class NoDupID extends Rule {
7492
7493
  });
7493
7494
  }
7494
7495
  }
7496
+ function getExisting(element, root) {
7497
+ const group = element.closest("template") ?? root;
7498
+ const existing = group.cacheGet(CACHE_KEY);
7499
+ if (existing) {
7500
+ return existing;
7501
+ } else {
7502
+ const existing2 = /* @__PURE__ */ new Set();
7503
+ return group.cacheSet(CACHE_KEY, existing2);
7504
+ }
7505
+ }
7495
7506
  function isRelevant$3(element) {
7496
7507
  const attr = element.getAttribute("id");
7497
7508
  if (!attr) {
@@ -12668,7 +12679,7 @@ class HtmlValidate {
12668
12679
  }
12669
12680
 
12670
12681
  const name = "html-validate";
12671
- const version = "8.18.0";
12682
+ const version = "8.18.1";
12672
12683
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
12673
12684
 
12674
12685
  function definePlugin(plugin) {