@asamuzakjp/dom-selector 8.1.5 → 8.2.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/package.json CHANGED
@@ -25,29 +25,29 @@
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
- "@asamuzakjp/generational-cache": "^3.0.1",
29
28
  "bidi-js": "^1.0.3",
30
29
  "css-tree": "^3.2.1",
31
- "is-potential-custom-element-name": "^1.0.1"
30
+ "is-potential-custom-element-name": "^1.0.1",
31
+ "lru-cache": "^11.5.2"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/css-tree": "^2.3.11",
35
- "@types/node": "^26.0.0",
35
+ "@types/node": "^26.1.1",
36
36
  "c8": "^11.0.0",
37
37
  "chai": "^6.2.2",
38
38
  "commander": "^15.0.0",
39
- "eslint": "^9.39.4",
39
+ "eslint": "^9.39.5",
40
40
  "eslint-config-prettier": "^10.1.8",
41
- "eslint-plugin-jsdoc": "^63.0.6",
41
+ "eslint-plugin-jsdoc": "^63.0.13",
42
42
  "eslint-plugin-prettier": "^5.5.6",
43
- "eslint-plugin-regexp": "^3.1.0",
43
+ "eslint-plugin-regexp": "^3.1.1",
44
44
  "eslint-plugin-unicorn": "^65.0.1",
45
- "globals": "^17.6.0",
45
+ "globals": "^17.7.0",
46
46
  "jsdom": "^29.1.1",
47
47
  "mitata": "^1.0.34",
48
48
  "mocha": "^11.7.6",
49
49
  "neostandard": "^0.13.0",
50
- "prettier": "^3.8.4",
50
+ "prettier": "^3.9.5",
51
51
  "sinon": "^22.0.0",
52
52
  "tinybench": "^6.0.2",
53
53
  "typescript": "^6.0.3",
@@ -88,5 +88,5 @@
88
88
  "engines": {
89
89
  "node": "^22.13.0 || >=24.0.0"
90
90
  },
91
- "version": "8.1.5"
91
+ "version": "8.2.1"
92
92
  }
package/src/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  /* import */
9
- import { GenerationalCache } from '@asamuzakjp/generational-cache';
9
+ import { LRUCache } from 'lru-cache';
10
10
  import { Finder } from './js/finder.js';
11
11
  import { Nwsapi } from './js/nwsapi.js';
12
12
  import { extractSubjectsAst } from './js/parser.js';
@@ -26,7 +26,7 @@ import {
26
26
  TARGET_LINEAL,
27
27
  TARGET_SELF
28
28
  } from './js/constant.js';
29
- const CACHE_SIZE = 2048;
29
+ const CACHE_SIZE = 4096;
30
30
 
31
31
  /* regexp */
32
32
  const REG_SELECTOR = /[[\]():\\"'`]/;
@@ -60,11 +60,11 @@ export class DOMSelector {
60
60
  this.#window = window;
61
61
  this.#document = document ?? window.document;
62
62
  this.#idlUtils = idlUtils;
63
- this.#cache = new GenerationalCache(cacheSize ?? CACHE_SIZE, {
64
- strictvalidate: false
63
+ this.#cache = new LRUCache({
64
+ max: cacheSize ?? CACHE_SIZE
65
65
  });
66
66
  this.#finder = new Finder(this.#window);
67
- this.#nwsapi = new Nwsapi(this.#window, this.#document);
67
+ this.#nwsapi = new Nwsapi(this.#window, this.#document, cacheSize);
68
68
  }
69
69
 
70
70
  /**
@@ -396,6 +396,8 @@ export class DOMSelector {
396
396
  if (document && REG_UNIVERSAL.test(selector)) {
397
397
  return collectAllDescendants(node, document);
398
398
  }
399
+ // Only enabled when debugging.
400
+ /*
399
401
  if (this.#canUseNwsapi(document)) {
400
402
  const cacheKey = `querySelectorAll_${selector}`;
401
403
  let filterMatches = this.#cache.get(cacheKey);
@@ -411,6 +413,7 @@ export class DOMSelector {
411
413
  }
412
414
  }
413
415
  }
416
+ */
414
417
  try {
415
418
  const nodes = this.#finder
416
419
  .setup(selector, this.#wrapNode(node), opt)
@@ -7,6 +7,8 @@ export const ATRULE = 'Atrule';
7
7
  export const ATTR_SELECTOR = 'AttributeSelector';
8
8
  export const CLASS_SELECTOR = 'ClassSelector';
9
9
  export const COMBINATOR = 'Combinator';
10
+ export const DIR_NEXT = 'next';
11
+ export const DIR_PREV = 'prev';
10
12
  export const IDENT = 'Identifier';
11
13
  export const ID_SELECTOR = 'IdSelector';
12
14
  export const NOT_SUPPORTED_ERR = 'NotSupportedError';