html-validate 9.5.2 → 9.5.4

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
@@ -1378,6 +1378,9 @@ class DynamicValue {
1378
1378
  }
1379
1379
  }
1380
1380
 
1381
+ function isStaticAttribute(attr) {
1382
+ return Boolean(attr?.isStatic);
1383
+ }
1381
1384
  function isDynamicAttribute(attr) {
1382
1385
  return Boolean(attr?.isDynamic);
1383
1386
  }
@@ -2007,7 +2010,7 @@ class AttributeCondition extends Condition {
2007
2010
  const [, key, op, value] = /^(.+?)(?:([~^$*|]?=)"([^"]+?)")?$/.exec(attr);
2008
2011
  this.key = key;
2009
2012
  this.op = op;
2010
- this.value = value;
2013
+ this.value = typeof value === "string" ? stripslashes(value) : value;
2011
2014
  }
2012
2015
  match(node) {
2013
2016
  const attr = node.getAttribute(this.key, true);
@@ -2640,9 +2643,7 @@ class HtmlElement extends DOMNode {
2640
2643
  * the subsequent `dom:ready` event).
2641
2644
  */
2642
2645
  loadMeta(meta) {
2643
- if (!this.metaElement) {
2644
- this.metaElement = {};
2645
- }
2646
+ this.metaElement ??= {};
2646
2647
  for (const key of MetaCopyableProperty) {
2647
2648
  const value = meta[key];
2648
2649
  if (typeof value !== "undefined") {
@@ -6101,7 +6102,7 @@ class ElementPermittedContent extends Rule {
6101
6102
  return false;
6102
6103
  }
6103
6104
  validatePermittedDescendant(node, parent) {
6104
- for (let cur = parent; cur && !cur.isRootElement(); cur = /* istanbul ignore next */
6105
+ for (let cur = parent; cur && !cur.isRootElement() && cur.tagName !== "template"; cur = /* istanbul ignore next */
6105
6106
  cur.parent ?? null) {
6106
6107
  const meta = cur.meta;
6107
6108
  if (!meta) {
@@ -8020,7 +8021,7 @@ const ARIA = [
8020
8021
  { property: "aria-owns", isList: true }
8021
8022
  ];
8022
8023
  function idMissing(document, id) {
8023
- const nodes = document.querySelectorAll(`[id="${id}"]`);
8024
+ const nodes = document.querySelectorAll(generateIdSelector(id));
8024
8025
  return nodes.length === 0;
8025
8026
  }
8026
8027
  class NoMissingReferences extends Rule {
@@ -8238,15 +8239,14 @@ class NoRedundantFor extends Rule {
8238
8239
  return;
8239
8240
  }
8240
8241
  const attr = target.getAttribute("for");
8241
- if (!attr || attr.isDynamic) {
8242
+ if (!attr || !isStaticAttribute(attr)) {
8242
8243
  return;
8243
8244
  }
8244
8245
  const id = attr.value;
8245
8246
  if (!id) {
8246
8247
  return;
8247
8248
  }
8248
- const escaped = escapeSelectorComponent(id);
8249
- const control = target.querySelector(`[id="${escaped}"]`);
8249
+ const control = target.querySelector(generateIdSelector(id));
8250
8250
  if (!control) {
8251
8251
  return;
8252
8252
  }
@@ -11729,7 +11729,7 @@ class EventHandler {
11729
11729
  }
11730
11730
 
11731
11731
  const name = "html-validate";
11732
- const version = "9.5.2";
11732
+ const version = "9.5.4";
11733
11733
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
11734
11734
 
11735
11735
  function freeze(src) {
@@ -12662,9 +12662,7 @@ class Engine {
12662
12662
  rule.block(blocker);
12663
12663
  }
12664
12664
  const unregisterOpen = parser.on("tag:start", (_event, data) => {
12665
- if (directiveBlock === null) {
12666
- directiveBlock = data.target.parent?.unique ?? null;
12667
- }
12665
+ directiveBlock ??= data.target.parent?.unique ?? null;
12668
12666
  data.target.blockRules(ruleIds, blocker);
12669
12667
  });
12670
12668
  const unregisterClose = parser.on("tag:end", (_event, data) => {
@@ -13360,7 +13358,7 @@ function requireIgnore () {
13360
13358
  // - ..
13361
13359
  // Valid:
13362
13360
  // - .foo
13363
- const REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/;
13361
+ const REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
13364
13362
 
13365
13363
  const REGEX_TEST_TRAILING_SLASH = /\/$/;
13366
13364