@asamuzakjp/dom-selector 8.0.0-a.1 → 8.0.0
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 +0 -80
- package/package.json +10 -6
- package/src/js/finder.js +1512 -170
- package/src/js/nwsapi.js +1 -1
- package/src/js/parser.js +0 -1
- package/src/js/utility.js +3 -3
- package/types/js/finder.d.ts +11 -12
- package/src/js/event-tracker.js +0 -131
- package/src/js/pseudo-evaluator.js +0 -1226
- package/types/js/event-tracker.d.ts +0 -12
- package/types/js/pseudo-evaluator.d.ts +0 -11
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
|
@@ -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.
|
|
45
|
-
"jsdom": "^29.1.
|
|
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": "^
|
|
80
|
+
"node": "^22.13.0 || >=24.0.0"
|
|
77
81
|
},
|
|
78
|
-
"version": "8.0.0
|
|
82
|
+
"version": "8.0.0"
|
|
79
83
|
}
|