html-validate 11.5.2 → 11.5.3

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
@@ -2054,19 +2054,19 @@ function lastChild(node) {
2054
2054
  return node.nextSibling === null;
2055
2055
  }
2056
2056
 
2057
- const cache = {};
2057
+ const cache$1 = {};
2058
2058
  function getNthChild(node) {
2059
2059
  if (!node.parent) {
2060
2060
  return -1;
2061
2061
  }
2062
- if (!cache[node.unique]) {
2062
+ if (!cache$1[node.unique]) {
2063
2063
  const parent = node.parent;
2064
2064
  const index = parent.childElements.findIndex((cur) => {
2065
2065
  return cur.unique === node.unique;
2066
2066
  });
2067
- cache[node.unique] = index + 1;
2067
+ cache$1[node.unique] = index + 1;
2068
2068
  }
2069
- return cache[node.unique];
2069
+ return cache$1[node.unique];
2070
2070
  }
2071
2071
  function nthChild(node, args) {
2072
2072
  if (!args) {
@@ -2480,9 +2480,16 @@ function generateIdSelector(id) {
2480
2480
  return /^\d/.test(escaped) ? `[id="${escaped}"]` : `#${escaped}`;
2481
2481
  }
2482
2482
 
2483
+ const cache = /* @__PURE__ */ new Map();
2483
2484
  function parseSelector(selector) {
2485
+ const cached = cache.get(selector);
2486
+ if (cached) {
2487
+ return cached;
2488
+ }
2484
2489
  const compounds = getCompounds(selector);
2485
- return ComplexSelector.fromCompounds(compounds);
2490
+ const result = ComplexSelector.fromCompounds(compounds);
2491
+ cache.set(selector, result);
2492
+ return result;
2486
2493
  }
2487
2494
 
2488
2495
  const TEXT_NODE_NAME = "#text";
@@ -3001,9 +3008,17 @@ class HtmlElement extends DOMNode {
3001
3008
  return i <= this.siblings.length - 2 ? this.siblings[i + 1] : null;
3002
3009
  }
3003
3010
  getElementsByTagName(tagName) {
3004
- return this.childElements.reduce((matches, node) => {
3005
- return matches.concat(node.is(tagName) ? [node] : [], node.getElementsByTagName(tagName));
3006
- }, []);
3011
+ const matches = [];
3012
+ this.collectByTagName(tagName, matches);
3013
+ return matches;
3014
+ }
3015
+ collectByTagName(tagName, matches) {
3016
+ for (const node of this.childElements) {
3017
+ if (node.is(tagName)) {
3018
+ matches.push(node);
3019
+ }
3020
+ node.collectByTagName(tagName, matches);
3021
+ }
3007
3022
  }
3008
3023
  querySelector(selector) {
3009
3024
  const it = this.querySelectorImpl(selector);
@@ -4807,14 +4822,20 @@ class Context {
4807
4822
  return JSON.stringify(this.string.length > n ? `${this.string.slice(0, 10)}...` : this.string);
4808
4823
  }
4809
4824
  consume(n, state) {
4810
- let consumed = this.string.slice(0, n);
4811
- let offset;
4812
- while ((offset = consumed.indexOf("\n")) >= 0) {
4813
- this.line++;
4814
- this.column = 1;
4815
- consumed = consumed.slice(offset + 1);
4816
- }
4817
- this.column += consumed.length;
4825
+ let lastNewline = -1;
4826
+ let newlines = 0;
4827
+ for (let i = 0; i < n; i++) {
4828
+ if (this.string[i] === "\n") {
4829
+ newlines++;
4830
+ lastNewline = i;
4831
+ }
4832
+ }
4833
+ if (newlines > 0) {
4834
+ this.line += newlines;
4835
+ this.column = n - lastNewline;
4836
+ } else {
4837
+ this.column += n;
4838
+ }
4818
4839
  this.offset += n;
4819
4840
  this.string = this.string.slice(n);
4820
4841
  this.state = state;
@@ -12823,7 +12844,7 @@ class EventHandler {
12823
12844
  }
12824
12845
 
12825
12846
  const name = "html-validate";
12826
- const version = "11.5.2";
12847
+ const version = "11.5.3";
12827
12848
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
12828
12849
 
12829
12850
  function freeze(src) {