@asamuzakjp/dom-selector 8.0.0-a.2 → 8.0.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/README.md CHANGED
@@ -87,86 +87,6 @@ querySelectorAll - equivalent to [Document.querySelectorAll()][69], [DocumentFra
87
87
  Returns **[Array][62]<([object][60] \| [undefined][63])>** array of matched nodes
88
88
 
89
89
 
90
- ## Monkey patch jsdom
91
-
92
- ``` javascript
93
- import { DOMSelector } from '@asamuzakjp/dom-selector';
94
- import { JSDOM } from 'jsdom';
95
-
96
- const dom = new JSDOM('', {
97
- runScripts: 'dangerously',
98
- url: 'http://localhost/',
99
- beforeParse: window => {
100
- const domSelector = new DOMSelector(window);
101
-
102
- const matches = domSelector.matches.bind(domSelector);
103
- window.Element.prototype.matches = function (...args) {
104
- if (!args.length) {
105
- throw new window.TypeError('1 argument required, but only 0 present.');
106
- }
107
- const [selector] = args;
108
- return matches(selector, this);
109
- };
110
-
111
- const closest = domSelector.closest.bind(domSelector);
112
- window.Element.prototype.closest = function (...args) {
113
- if (!args.length) {
114
- throw new window.TypeError('1 argument required, but only 0 present.');
115
- }
116
- const [selector] = args;
117
- return closest(selector, this);
118
- };
119
-
120
- const querySelector = domSelector.querySelector.bind(domSelector);
121
- window.Document.prototype.querySelector = function (...args) {
122
- if (!args.length) {
123
- throw new window.TypeError('1 argument required, but only 0 present.');
124
- }
125
- const [selector] = args;
126
- return querySelector(selector, this);
127
- };
128
- window.DocumentFragment.prototype.querySelector = function (...args) {
129
- if (!args.length) {
130
- throw new window.TypeError('1 argument required, but only 0 present.');
131
- }
132
- const [selector] = args;
133
- return querySelector(selector, this);
134
- };
135
- window.Element.prototype.querySelector = function (...args) {
136
- if (!args.length) {
137
- throw new window.TypeError('1 argument required, but only 0 present.');
138
- }
139
- const [selector] = args;
140
- return querySelector(selector, this);
141
- };
142
-
143
- const querySelectorAll = domSelector.querySelectorAll.bind(domSelector);
144
- window.Document.prototype.querySelectorAll = function (...args) {
145
- if (!args.length) {
146
- throw new window.TypeError('1 argument required, but only 0 present.');
147
- }
148
- const [selector] = args;
149
- return querySelectorAll(selector, this);
150
- };
151
- window.DocumentFragment.prototype.querySelectorAll = function (...args) {
152
- if (!args.length) {
153
- throw new window.TypeError('1 argument required, but only 0 present.');
154
- }
155
- const [selector] = args;
156
- return querySelectorAll(selector, this);
157
- };
158
- window.Element.prototype.querySelectorAll = function (...args) {
159
- if (!args.length) {
160
- throw new window.TypeError('1 argument required, but only 0 present.');
161
- }
162
- const [selector] = args;
163
- return querySelectorAll(selector, this);
164
- };
165
- }
166
- });
167
- ```
168
-
169
-
170
90
  ## Supported CSS selectors
171
91
 
172
92
  |Pattern|Supported|Note|
package/package.json CHANGED
@@ -24,7 +24,7 @@
24
24
  "./package.json": "./package.json"
25
25
  },
26
26
  "dependencies": {
27
- "@asamuzakjp/generational-cache": "^1.0.1",
27
+ "@asamuzakjp/generational-cache": "^2.0.1",
28
28
  "bidi-js": "^1.0.3",
29
29
  "css-tree": "^3.2.1",
30
30
  "is-potential-custom-element-name": "^1.0.1"
@@ -41,8 +41,8 @@
41
41
  "eslint-plugin-prettier": "^5.5.5",
42
42
  "eslint-plugin-regexp": "^3.1.0",
43
43
  "eslint-plugin-unicorn": "^64.0.0",
44
- "globals": "^17.5.0",
45
- "jsdom": "^29.1.0",
44
+ "globals": "^17.6.0",
45
+ "jsdom": "^29.1.1",
46
46
  "mitata": "^1.0.34",
47
47
  "mocha": "^11.7.5",
48
48
  "neostandard": "^0.13.0",
@@ -56,15 +56,19 @@
56
56
  "c8": {
57
57
  "yargs": "^18.0.0"
58
58
  },
59
+ "eslint": {
60
+ "brace-expansion": "^1.1.13"
61
+ },
59
62
  "jsdom": "$jsdom",
63
+ "mocha": {
64
+ "diff": "^8.0.3"
65
+ },
60
66
  "serialize-javascript": "^7.0.4"
61
67
  },
62
68
  "scripts": {
63
69
  "bench": "node benchmark/bench.js",
64
70
  "bench:cache": "node benchmark/bench-cache.js",
65
- "bench:cacheMonster": "node benchmark/bench-cache-monster.js",
66
71
  "bench:nwsapi": "node benchmark/bench-nwsapi.js",
67
- "bench:sizzle": "node benchmark/bench-sizzle.js",
68
72
  "build": "npm run tsc && npm run lint && npm test",
69
73
  "lint": "eslint --fix .",
70
74
  "test": "c8 --reporter=text mocha --exit test/**/*.test.js",
@@ -73,7 +77,7 @@
73
77
  "update:wpt": "git submodule update --init --recursive --remote"
74
78
  },
75
79
  "engines": {
76
- "node": "^20.19.0 || ^22.13.0 || >=24.0.0"
80
+ "node": "^22.13.0 || >=24.0.0"
77
81
  },
78
- "version": "8.0.0-a.2"
82
+ "version": "8.0.1"
79
83
  }
package/src/js/nwsapi.js CHANGED
@@ -10,7 +10,7 @@ import { isContentEditable } from './utility.js';
10
10
 
11
11
  /* constants */
12
12
  import { DOCUMENT_NODE, ELEMENT_NODE } from './constant.js';
13
- const CACHE_SIZE = 1024;
13
+ const CACHE_SIZE = 2048;
14
14
  const F_INIT = '"use strict";return function resolver(c,f,x,r)';
15
15
  const S_HEAD = 'var e,n,o,j=r.length-1,k=-1';
16
16
  const M_HEAD = 'var e,n,o';