query-selector-shadow-dom-modern 1.0.0 → 1.0.2
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 +5 -0
- package/dist/umd/index.cjs +535 -0
- package/dist/umd/index.cjs.map +1 -0
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/index.min.js +2 -0
- package/dist/umd/index.min.js.map +7 -0
- package/package.json +16 -6
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# query-selector-shadow-dom-modern
|
|
2
2
|
|
|
3
|
+
[](https://github.com/kaixinol/query-selector-shadow-dom-modern/actions/workflows/release.yml)
|
|
4
|
+
|
|
3
5
|
Modern drop-in replacement for [query-selector-shadow-dom](https://www.npmjs.com/package/query-selector-shadow-dom). Zero dependencies, full TypeScript support.
|
|
4
6
|
|
|
5
7
|
querySelector that can pierce Shadow DOM roots without knowing the path through nested shadow roots. Useful for automated testing of Web Components (Selenium, Puppeteer, Playwright, etc.).
|
|
@@ -33,7 +35,10 @@ const filtered = collectAllElementsDeep('a[href]');
|
|
|
33
35
|
### UMD (browser)
|
|
34
36
|
|
|
35
37
|
```html
|
|
38
|
+
<!-- Full build (debuggable, with sourcemap) -->
|
|
36
39
|
<script src="node_modules/query-selector-shadow-dom-modern/dist/umd/index.js"></script>
|
|
40
|
+
<!-- Or minified (~1.9 KB gzipped) -->
|
|
41
|
+
<script src="node_modules/query-selector-shadow-dom-modern/dist/umd/index.min.js"></script>
|
|
37
42
|
<script>
|
|
38
43
|
const btn = querySelectorShadowDom.querySelectorDeep('.btn-in-shadow-dom');
|
|
39
44
|
</script>
|
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* query-selector-shadow-dom-modern
|
|
5
|
+
*
|
|
6
|
+
* Drop-in replacement for https://www.npmjs.com/package/query-selector-shadow-dom
|
|
7
|
+
* with the same public API:
|
|
8
|
+
*
|
|
9
|
+
* - querySelectorDeep(selector, root?, allElements?)
|
|
10
|
+
* - querySelectorAllDeep(selector, root?, allElements?)
|
|
11
|
+
* - collectAllElementsDeep(selector?, root?, cachedElements?)
|
|
12
|
+
*
|
|
13
|
+
* but faster and safer:
|
|
14
|
+
* - Native `querySelector(All)` does the heavy lifting whenever possible
|
|
15
|
+
* (whole-selector fast path when no shadow roots are involved, and a
|
|
16
|
+
* per-root pre-filter on the right-most compound selector otherwise).
|
|
17
|
+
* - Selector parsing is memoized (strings are immutable — safe to cache).
|
|
18
|
+
* - No DOM caching: results are always computed from the live tree, so
|
|
19
|
+
* dynamic pages never see stale data.
|
|
20
|
+
* - Full combinator support across shadow boundaries: ` `, `>`, `+`, `~`.
|
|
21
|
+
* - Cross-realm safe (iframe documents): no `instanceof` on DOM classes.
|
|
22
|
+
*/
|
|
23
|
+
const ELEMENT_NODE = 1;
|
|
24
|
+
const DOCUMENT_FRAGMENT_NODE = 11;
|
|
25
|
+
/** Cross-realm-safe Element check (`instanceof` fails across frames). */
|
|
26
|
+
function isElementNode(node) {
|
|
27
|
+
return !!node && node.nodeType === ELEMENT_NODE;
|
|
28
|
+
}
|
|
29
|
+
/** Cross-realm-safe ShadowRoot check. */
|
|
30
|
+
function isHostedFragment(node) {
|
|
31
|
+
return (!!node &&
|
|
32
|
+
node.nodeType === DOCUMENT_FRAGMENT_NODE &&
|
|
33
|
+
!!node.host);
|
|
34
|
+
}
|
|
35
|
+
/** `el.matches()` that never throws (context-dependent pseudo-classes etc.). */
|
|
36
|
+
function matchesSelector(el, compound) {
|
|
37
|
+
try {
|
|
38
|
+
return el.matches(compound);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Parent in the composed (flat-ish) tree: crosses shadow boundaries towards
|
|
46
|
+
* the host, and stops at the boundary the search was scoped to.
|
|
47
|
+
* Matches the original library's findParentOrHost semantics.
|
|
48
|
+
*/
|
|
49
|
+
function composedParent(el, boundary) {
|
|
50
|
+
if (el === boundary)
|
|
51
|
+
return null;
|
|
52
|
+
const parent = el.parentElement;
|
|
53
|
+
if (parent)
|
|
54
|
+
return parent;
|
|
55
|
+
const rootNode = el.getRootNode();
|
|
56
|
+
if (rootNode === el || rootNode === boundary)
|
|
57
|
+
return null;
|
|
58
|
+
if (isHostedFragment(rootNode))
|
|
59
|
+
return rootNode.host;
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Verify that `el` (already known to match the right-most compound) satisfies
|
|
64
|
+
* the whole selector path, walking the composed tree right-to-left.
|
|
65
|
+
* `tokens` looks like: [compound, combinator, compound, ...].
|
|
66
|
+
*/
|
|
67
|
+
function matchesComposedPath(el, tokens, boundary) {
|
|
68
|
+
let node = el;
|
|
69
|
+
let i = tokens.length - 1;
|
|
70
|
+
while (i > 0 && node) {
|
|
71
|
+
const combinator = tokens[i - 1];
|
|
72
|
+
const compound = tokens[i - 2];
|
|
73
|
+
if (combinator === '>') {
|
|
74
|
+
node = composedParent(node, boundary);
|
|
75
|
+
if (!node || !matchesSelector(node, compound))
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
else if (combinator === '+') {
|
|
79
|
+
node = node.previousElementSibling;
|
|
80
|
+
if (!node || !matchesSelector(node, compound))
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
else if (combinator === '~') {
|
|
84
|
+
node = node.previousElementSibling;
|
|
85
|
+
let found = false;
|
|
86
|
+
while (node) {
|
|
87
|
+
if (matchesSelector(node, compound)) {
|
|
88
|
+
found = true;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
node = node.previousElementSibling;
|
|
92
|
+
}
|
|
93
|
+
if (!found)
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// descendant combinator
|
|
98
|
+
node = composedParent(node, boundary);
|
|
99
|
+
let found = false;
|
|
100
|
+
while (node) {
|
|
101
|
+
if (matchesSelector(node, compound)) {
|
|
102
|
+
found = true;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
node = composedParent(node, boundary);
|
|
106
|
+
}
|
|
107
|
+
if (!found)
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
i -= 2;
|
|
111
|
+
}
|
|
112
|
+
return i <= 0;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* All queryable roots below (and including) `root`: the root itself plus every
|
|
116
|
+
* open shadow root found underneath, in discovery order. Computed fresh on
|
|
117
|
+
* every call — never cached, so dynamic DOMs are always correct.
|
|
118
|
+
*/
|
|
119
|
+
function collectRoots(root) {
|
|
120
|
+
const roots = [root];
|
|
121
|
+
const pending = [];
|
|
122
|
+
if (isElementNode(root) && root.shadowRoot) {
|
|
123
|
+
roots.push(root.shadowRoot);
|
|
124
|
+
pending.push(root.shadowRoot);
|
|
125
|
+
}
|
|
126
|
+
let scope = root;
|
|
127
|
+
while (scope) {
|
|
128
|
+
const all = scope.querySelectorAll('*');
|
|
129
|
+
for (let i = 0; i < all.length; i++) {
|
|
130
|
+
const shadowRoot = all[i].shadowRoot;
|
|
131
|
+
if (shadowRoot) {
|
|
132
|
+
roots.push(shadowRoot);
|
|
133
|
+
pending.push(shadowRoot);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
scope = pending.pop();
|
|
137
|
+
}
|
|
138
|
+
return roots;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Collect every element under `root` in the original library's order
|
|
142
|
+
* (composed tree pre-order: a host's shadow content comes immediately after
|
|
143
|
+
* the host element). One native `querySelectorAll('*')` per root — the
|
|
144
|
+
* browser does the walking.
|
|
145
|
+
*/
|
|
146
|
+
function collectAllElements(root, filter) {
|
|
147
|
+
const out = [];
|
|
148
|
+
collectInto(root, out, filter);
|
|
149
|
+
return out;
|
|
150
|
+
}
|
|
151
|
+
function collectInto(scope, out, filter) {
|
|
152
|
+
// A root element's own shadow content is listed first (original behavior).
|
|
153
|
+
if (isElementNode(scope) && scope.shadowRoot) {
|
|
154
|
+
collectList(scope.shadowRoot.querySelectorAll('*'), out, filter);
|
|
155
|
+
}
|
|
156
|
+
collectList(scope.querySelectorAll('*'), out, filter);
|
|
157
|
+
}
|
|
158
|
+
function collectList(list, out, filter) {
|
|
159
|
+
for (let i = 0; i < list.length; i++) {
|
|
160
|
+
const el = list[i];
|
|
161
|
+
if (!filter || matchesSelector(el, filter)) {
|
|
162
|
+
out.push(el);
|
|
163
|
+
}
|
|
164
|
+
const shadowRoot = el.shadowRoot;
|
|
165
|
+
if (shadowRoot) {
|
|
166
|
+
collectList(shadowRoot.querySelectorAll('*'), out, filter);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Generator variant of the same traversal, for callers that can stop early.
|
|
172
|
+
*/
|
|
173
|
+
function* iterateDeep(root) {
|
|
174
|
+
const stack = [];
|
|
175
|
+
const pushChildren = (scope) => {
|
|
176
|
+
const kids = scope.children;
|
|
177
|
+
for (let i = kids.length - 1; i >= 0; i--)
|
|
178
|
+
stack.push(kids[i]);
|
|
179
|
+
};
|
|
180
|
+
if (isElementNode(root)) {
|
|
181
|
+
pushChildren(root);
|
|
182
|
+
if (root.shadowRoot)
|
|
183
|
+
pushChildren(root.shadowRoot);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
pushChildren(root);
|
|
187
|
+
}
|
|
188
|
+
while (stack.length > 0) {
|
|
189
|
+
const el = stack.pop();
|
|
190
|
+
yield el;
|
|
191
|
+
pushChildren(el);
|
|
192
|
+
if (el.shadowRoot)
|
|
193
|
+
pushChildren(el.shadowRoot);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
const PARSE_CACHE_LIMIT = 512;
|
|
197
|
+
const parseCache = new Map();
|
|
198
|
+
/** Split into comma-separated parts, each tokenized as [compound, combinator, ...]. Memoized. */
|
|
199
|
+
function parseSelector(selector) {
|
|
200
|
+
const cached = parseCache.get(selector);
|
|
201
|
+
if (cached)
|
|
202
|
+
return cached;
|
|
203
|
+
const parts = [];
|
|
204
|
+
for (const part of splitByComma(selector)) {
|
|
205
|
+
const tokens = tokenizePath(part);
|
|
206
|
+
if (tokens.length > 0)
|
|
207
|
+
parts.push(tokens);
|
|
208
|
+
}
|
|
209
|
+
if (parseCache.size >= PARSE_CACHE_LIMIT)
|
|
210
|
+
parseCache.clear();
|
|
211
|
+
parseCache.set(selector, parts);
|
|
212
|
+
return parts;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Candidates for one tokenized selector part: elements matching the
|
|
216
|
+
* right-most compound, natively pre-filtered inside each root.
|
|
217
|
+
* Returns the candidates either as a single ordered list (when only one root
|
|
218
|
+
* produced hits) or as a Set plus a flag that a composed-order walk is needed.
|
|
219
|
+
*/
|
|
220
|
+
function collectCandidates(roots, rightMostCompound) {
|
|
221
|
+
let list = null;
|
|
222
|
+
let set = null;
|
|
223
|
+
let rootsWithHits = 0;
|
|
224
|
+
for (const root of roots) {
|
|
225
|
+
let found;
|
|
226
|
+
try {
|
|
227
|
+
found = root.querySelectorAll(rightMostCompound);
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
continue; // selector not valid in this root's context
|
|
231
|
+
}
|
|
232
|
+
if (found.length === 0)
|
|
233
|
+
continue;
|
|
234
|
+
rootsWithHits++;
|
|
235
|
+
if (!list) {
|
|
236
|
+
list = Array.from(found);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
if (!set)
|
|
240
|
+
set = new Set(list);
|
|
241
|
+
for (let i = 0; i < found.length; i++)
|
|
242
|
+
set.add(found[i]);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return { list, set, rootsWithHits };
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Finds the first matching element on the page, piercing any number of nested
|
|
249
|
+
* shadow roots. Same signature and semantics as the original library.
|
|
250
|
+
*/
|
|
251
|
+
function querySelectorDeep(selector, root = document, allElements = null) {
|
|
252
|
+
if (!selector || !selector.trim())
|
|
253
|
+
return null;
|
|
254
|
+
// Native fast path — identical to the original library: a plain
|
|
255
|
+
// light-DOM match always wins, no matter what lives in shadow roots.
|
|
256
|
+
const lightElement = root.querySelector(selector);
|
|
257
|
+
if (lightElement)
|
|
258
|
+
return lightElement;
|
|
259
|
+
const parts = parseSelector(selector);
|
|
260
|
+
if (parts.length === 0)
|
|
261
|
+
return null;
|
|
262
|
+
// Caller-supplied element list (original API's third argument).
|
|
263
|
+
if (allElements) {
|
|
264
|
+
for (const tokens of parts) {
|
|
265
|
+
const last = tokens[tokens.length - 1];
|
|
266
|
+
for (const el of allElements) {
|
|
267
|
+
if (matchesSelector(el, last) &&
|
|
268
|
+
(tokens.length === 1 || matchesComposedPath(el, tokens, root))) {
|
|
269
|
+
return el;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
const roots = collectRoots(root);
|
|
276
|
+
if (roots.length === 1)
|
|
277
|
+
return null; // no shadow roots; native query already failed
|
|
278
|
+
for (const tokens of parts) {
|
|
279
|
+
const last = tokens[tokens.length - 1];
|
|
280
|
+
const { list, set, rootsWithHits } = collectCandidates(roots, last);
|
|
281
|
+
if (!list)
|
|
282
|
+
continue;
|
|
283
|
+
const verified = (el) => tokens.length === 1 || matchesComposedPath(el, tokens, root);
|
|
284
|
+
if (rootsWithHits === 1) {
|
|
285
|
+
// All candidates live in a single root → that root's native order is composed order.
|
|
286
|
+
for (const el of list) {
|
|
287
|
+
if (verified(el))
|
|
288
|
+
return el;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
const candidates = set ?? new Set(list);
|
|
293
|
+
for (const el of iterateDeep(root)) {
|
|
294
|
+
if (candidates.has(el) && verified(el))
|
|
295
|
+
return el;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Finds all matching elements on the page, piercing any number of nested
|
|
303
|
+
* shadow roots. Same signature and semantics as the original library
|
|
304
|
+
* (results are additionally de-duplicated).
|
|
305
|
+
*/
|
|
306
|
+
function querySelectorAllDeep(selector, root = document, allElements = null) {
|
|
307
|
+
if (!selector || !selector.trim())
|
|
308
|
+
return [];
|
|
309
|
+
const parts = parseSelector(selector);
|
|
310
|
+
if (parts.length === 0)
|
|
311
|
+
return [];
|
|
312
|
+
// Caller-supplied element list (original API's third argument).
|
|
313
|
+
if (allElements) {
|
|
314
|
+
const out = [];
|
|
315
|
+
const seen = new Set();
|
|
316
|
+
for (const tokens of parts) {
|
|
317
|
+
const last = tokens[tokens.length - 1];
|
|
318
|
+
for (const el of allElements) {
|
|
319
|
+
if (seen.has(el) || !matchesSelector(el, last))
|
|
320
|
+
continue;
|
|
321
|
+
if (tokens.length === 1 || matchesComposedPath(el, tokens, root)) {
|
|
322
|
+
seen.add(el);
|
|
323
|
+
out.push(el);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return out;
|
|
328
|
+
}
|
|
329
|
+
const roots = collectRoots(root);
|
|
330
|
+
// No shadow roots below `root` → hand everything to the browser.
|
|
331
|
+
if (roots.length === 1) {
|
|
332
|
+
return Array.from(root.querySelectorAll(selector));
|
|
333
|
+
}
|
|
334
|
+
const results = [];
|
|
335
|
+
const seen = new Set();
|
|
336
|
+
for (const tokens of parts) {
|
|
337
|
+
const last = tokens[tokens.length - 1];
|
|
338
|
+
const { list, set, rootsWithHits } = collectCandidates(roots, last);
|
|
339
|
+
if (!list)
|
|
340
|
+
continue;
|
|
341
|
+
if (rootsWithHits === 1) {
|
|
342
|
+
// All candidates live in a single root → its native order is composed order.
|
|
343
|
+
for (const el of list) {
|
|
344
|
+
if (seen.has(el))
|
|
345
|
+
continue;
|
|
346
|
+
if (tokens.length === 1 || matchesComposedPath(el, tokens, root)) {
|
|
347
|
+
seen.add(el);
|
|
348
|
+
results.push(el);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
// Candidates spread across roots → merge in composed tree order.
|
|
354
|
+
const candidates = set ?? new Set(list);
|
|
355
|
+
const all = collectAllElements(root);
|
|
356
|
+
for (let i = 0; i < all.length; i++) {
|
|
357
|
+
const el = all[i];
|
|
358
|
+
if (!candidates.has(el) || seen.has(el))
|
|
359
|
+
continue;
|
|
360
|
+
if (tokens.length === 1 || matchesComposedPath(el, tokens, root)) {
|
|
361
|
+
seen.add(el);
|
|
362
|
+
results.push(el);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return results;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Finds all elements on the page, inclusive of those within shadow roots.
|
|
371
|
+
* Optionally filtered by a CSS selector.
|
|
372
|
+
* Same signature and semantics as the original library.
|
|
373
|
+
*/
|
|
374
|
+
function collectAllElementsDeep(selector = null, root = document, cachedElements = null) {
|
|
375
|
+
if (cachedElements) {
|
|
376
|
+
const all = cachedElements;
|
|
377
|
+
return selector ? all.filter((el) => matchesSelector(el, selector)) : all;
|
|
378
|
+
}
|
|
379
|
+
// Single pass: elements are filtered while the tree is being walked.
|
|
380
|
+
return collectAllElements(root, selector ?? undefined);
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Split a selector list on top-level commas (ignores commas inside quotes,
|
|
384
|
+
* attribute brackets and pseudo-class parentheses).
|
|
385
|
+
*/
|
|
386
|
+
function splitByComma(selector) {
|
|
387
|
+
if (!selector || !selector.trim())
|
|
388
|
+
return [];
|
|
389
|
+
const results = [];
|
|
390
|
+
let current = '';
|
|
391
|
+
let parenDepth = 0;
|
|
392
|
+
let bracketDepth = 0;
|
|
393
|
+
let inSingleQuote = false;
|
|
394
|
+
let inDoubleQuote = false;
|
|
395
|
+
let escaped = false;
|
|
396
|
+
for (let i = 0; i < selector.length; i++) {
|
|
397
|
+
const char = selector[i];
|
|
398
|
+
if (escaped) {
|
|
399
|
+
current += char;
|
|
400
|
+
escaped = false;
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
if (char === '\\') {
|
|
404
|
+
escaped = true;
|
|
405
|
+
current += char;
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
if (char === "'" && !inDoubleQuote) {
|
|
409
|
+
inSingleQuote = !inSingleQuote;
|
|
410
|
+
current += char;
|
|
411
|
+
continue;
|
|
412
|
+
}
|
|
413
|
+
if (char === '"' && !inSingleQuote) {
|
|
414
|
+
inDoubleQuote = !inDoubleQuote;
|
|
415
|
+
current += char;
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
if (!inSingleQuote && !inDoubleQuote) {
|
|
419
|
+
if (char === '(')
|
|
420
|
+
parenDepth++;
|
|
421
|
+
else if (char === ')')
|
|
422
|
+
parenDepth = Math.max(0, parenDepth - 1);
|
|
423
|
+
else if (char === '[')
|
|
424
|
+
bracketDepth++;
|
|
425
|
+
else if (char === ']')
|
|
426
|
+
bracketDepth = Math.max(0, bracketDepth - 1);
|
|
427
|
+
else if (char === ',' && parenDepth === 0 && bracketDepth === 0) {
|
|
428
|
+
results.push(current.trim());
|
|
429
|
+
current = '';
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
current += char;
|
|
434
|
+
}
|
|
435
|
+
if (current.trim()) {
|
|
436
|
+
results.push(current.trim());
|
|
437
|
+
}
|
|
438
|
+
return results;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Tokenize a CSS selector into compounds and combinators:
|
|
442
|
+
* 'div > p span' → ['div', '>', 'p', ' ', 'span'].
|
|
443
|
+
*/
|
|
444
|
+
function tokenizePath(selector) {
|
|
445
|
+
if (!selector || !selector.trim())
|
|
446
|
+
return [];
|
|
447
|
+
const tokens = [];
|
|
448
|
+
let current = '';
|
|
449
|
+
let parenDepth = 0;
|
|
450
|
+
let bracketDepth = 0;
|
|
451
|
+
let inSingleQuote = false;
|
|
452
|
+
let inDoubleQuote = false;
|
|
453
|
+
let escaped = false;
|
|
454
|
+
const pushCurrent = () => {
|
|
455
|
+
const trimmed = current.trim();
|
|
456
|
+
if (trimmed) {
|
|
457
|
+
tokens.push(trimmed);
|
|
458
|
+
}
|
|
459
|
+
current = '';
|
|
460
|
+
};
|
|
461
|
+
for (let i = 0; i < selector.length; i++) {
|
|
462
|
+
const char = selector[i];
|
|
463
|
+
if (escaped) {
|
|
464
|
+
current += char;
|
|
465
|
+
escaped = false;
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
if (char === '\\') {
|
|
469
|
+
escaped = true;
|
|
470
|
+
current += char;
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
if (char === "'" && !inDoubleQuote) {
|
|
474
|
+
inSingleQuote = !inSingleQuote;
|
|
475
|
+
current += char;
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
478
|
+
if (char === '"' && !inSingleQuote) {
|
|
479
|
+
inDoubleQuote = !inDoubleQuote;
|
|
480
|
+
current += char;
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
483
|
+
if (!inSingleQuote && !inDoubleQuote) {
|
|
484
|
+
if (char === '(')
|
|
485
|
+
parenDepth++;
|
|
486
|
+
else if (char === ')')
|
|
487
|
+
parenDepth = Math.max(0, parenDepth - 1);
|
|
488
|
+
else if (char === '[')
|
|
489
|
+
bracketDepth++;
|
|
490
|
+
else if (char === ']')
|
|
491
|
+
bracketDepth = Math.max(0, bracketDepth - 1);
|
|
492
|
+
if (parenDepth === 0 && bracketDepth === 0) {
|
|
493
|
+
if (char === '>' || char === '+' || char === '~') {
|
|
494
|
+
pushCurrent();
|
|
495
|
+
tokens.push(char);
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
if (/\s/.test(char)) {
|
|
499
|
+
pushCurrent();
|
|
500
|
+
while (i + 1 < selector.length && /\s/.test(selector[i + 1])) {
|
|
501
|
+
i++;
|
|
502
|
+
}
|
|
503
|
+
let nextChar = '';
|
|
504
|
+
for (let j = i + 1; j < selector.length; j++) {
|
|
505
|
+
if (!/\s/.test(selector[j])) {
|
|
506
|
+
nextChar = selector[j];
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
const lastToken = tokens[tokens.length - 1];
|
|
511
|
+
const isLastCombinator = lastToken === ' ' || lastToken === '>' || lastToken === '+' || lastToken === '~';
|
|
512
|
+
if (tokens.length > 0 &&
|
|
513
|
+
!isLastCombinator &&
|
|
514
|
+
nextChar &&
|
|
515
|
+
nextChar !== '>' &&
|
|
516
|
+
nextChar !== '+' &&
|
|
517
|
+
nextChar !== '~') {
|
|
518
|
+
tokens.push(' ');
|
|
519
|
+
}
|
|
520
|
+
continue;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
current += char;
|
|
525
|
+
}
|
|
526
|
+
pushCurrent();
|
|
527
|
+
return tokens;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
exports.collectAllElementsDeep = collectAllElementsDeep;
|
|
531
|
+
exports.querySelectorAllDeep = querySelectorAllDeep;
|
|
532
|
+
exports.querySelectorDeep = querySelectorDeep;
|
|
533
|
+
exports.splitByComma = splitByComma;
|
|
534
|
+
exports.tokenizePath = tokenizePath;
|
|
535
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["/**\n * query-selector-shadow-dom-modern\n *\n * Drop-in replacement for https://www.npmjs.com/package/query-selector-shadow-dom\n * with the same public API:\n *\n * - querySelectorDeep(selector, root?, allElements?)\n * - querySelectorAllDeep(selector, root?, allElements?)\n * - collectAllElementsDeep(selector?, root?, cachedElements?)\n *\n * but faster and safer:\n * - Native `querySelector(All)` does the heavy lifting whenever possible\n * (whole-selector fast path when no shadow roots are involved, and a\n * per-root pre-filter on the right-most compound selector otherwise).\n * - Selector parsing is memoized (strings are immutable — safe to cache).\n * - No DOM caching: results are always computed from the live tree, so\n * dynamic pages never see stale data.\n * - Full combinator support across shadow boundaries: ` `, `>`, `+`, `~`.\n * - Cross-realm safe (iframe documents): no `instanceof` on DOM classes.\n */\n\nexport type QueryableNode = Document | DocumentFragment | Element;\n\nconst ELEMENT_NODE = 1;\nconst DOCUMENT_FRAGMENT_NODE = 11;\n\n/** Cross-realm-safe Element check (`instanceof` fails across frames). */\nfunction isElementNode(node: unknown): node is Element {\n return !!node && (node as Node).nodeType === ELEMENT_NODE;\n}\n\n/** Cross-realm-safe ShadowRoot check. */\nfunction isHostedFragment(node: unknown): node is ShadowRoot {\n return (\n !!node &&\n (node as Node).nodeType === DOCUMENT_FRAGMENT_NODE &&\n !!(node as ShadowRoot).host\n );\n}\n\n/** `el.matches()` that never throws (context-dependent pseudo-classes etc.). */\nfunction matchesSelector(el: Element, compound: string): boolean {\n try {\n return el.matches(compound);\n } catch {\n return false;\n }\n}\n\n/**\n * Parent in the composed (flat-ish) tree: crosses shadow boundaries towards\n * the host, and stops at the boundary the search was scoped to.\n * Matches the original library's findParentOrHost semantics.\n */\nfunction composedParent(el: Element, boundary: QueryableNode): Element | null {\n if (el === boundary) return null;\n const parent = el.parentElement;\n if (parent) return parent;\n const rootNode = el.getRootNode();\n if (rootNode === el || rootNode === boundary) return null;\n if (isHostedFragment(rootNode)) return rootNode.host;\n return null;\n}\n\n/**\n * Verify that `el` (already known to match the right-most compound) satisfies\n * the whole selector path, walking the composed tree right-to-left.\n * `tokens` looks like: [compound, combinator, compound, ...].\n */\nfunction matchesComposedPath(el: Element, tokens: string[], boundary: QueryableNode): boolean {\n let node: Element | null = el;\n let i = tokens.length - 1;\n\n while (i > 0 && node) {\n const combinator = tokens[i - 1];\n const compound = tokens[i - 2];\n\n if (combinator === '>') {\n node = composedParent(node, boundary);\n if (!node || !matchesSelector(node, compound)) return false;\n } else if (combinator === '+') {\n node = node.previousElementSibling;\n if (!node || !matchesSelector(node, compound)) return false;\n } else if (combinator === '~') {\n node = node.previousElementSibling;\n let found = false;\n while (node) {\n if (matchesSelector(node, compound)) {\n found = true;\n break;\n }\n node = node.previousElementSibling;\n }\n if (!found) return false;\n } else {\n // descendant combinator\n node = composedParent(node, boundary);\n let found = false;\n while (node) {\n if (matchesSelector(node, compound)) {\n found = true;\n break;\n }\n node = composedParent(node, boundary);\n }\n if (!found) return false;\n }\n i -= 2;\n }\n return i <= 0;\n}\n\n/**\n * All queryable roots below (and including) `root`: the root itself plus every\n * open shadow root found underneath, in discovery order. Computed fresh on\n * every call — never cached, so dynamic DOMs are always correct.\n */\nfunction collectRoots(root: QueryableNode): QueryableNode[] {\n const roots: QueryableNode[] = [root];\n const pending: QueryableNode[] = [];\n\n if (isElementNode(root) && root.shadowRoot) {\n roots.push(root.shadowRoot);\n pending.push(root.shadowRoot);\n }\n\n let scope: QueryableNode | undefined = root;\n while (scope) {\n const all = scope.querySelectorAll('*');\n for (let i = 0; i < all.length; i++) {\n const shadowRoot = (all[i] as Element).shadowRoot;\n if (shadowRoot) {\n roots.push(shadowRoot);\n pending.push(shadowRoot);\n }\n }\n scope = pending.pop();\n }\n return roots;\n}\n\n/**\n * Collect every element under `root` in the original library's order\n * (composed tree pre-order: a host's shadow content comes immediately after\n * the host element). One native `querySelectorAll('*')` per root — the\n * browser does the walking.\n */\nfunction collectAllElements(root: QueryableNode, filter?: string): Element[] {\n const out: Element[] = [];\n collectInto(root, out, filter);\n return out;\n}\n\nfunction collectInto(scope: QueryableNode, out: Element[], filter?: string): void {\n // A root element's own shadow content is listed first (original behavior).\n if (isElementNode(scope) && scope.shadowRoot) {\n collectList(scope.shadowRoot.querySelectorAll('*'), out, filter);\n }\n collectList(scope.querySelectorAll('*'), out, filter);\n}\n\nfunction collectList(list: NodeListOf<Element>, out: Element[], filter?: string): void {\n for (let i = 0; i < list.length; i++) {\n const el = list[i];\n if (!filter || matchesSelector(el, filter)) {\n out.push(el);\n }\n const shadowRoot = el.shadowRoot;\n if (shadowRoot) {\n collectList(shadowRoot.querySelectorAll('*'), out, filter);\n }\n }\n}\n\n/**\n * Generator variant of the same traversal, for callers that can stop early.\n */\nfunction* iterateDeep(root: QueryableNode): Generator<Element, void, undefined> {\n const stack: Element[] = [];\n const pushChildren = (scope: QueryableNode) => {\n const kids = scope.children;\n for (let i = kids.length - 1; i >= 0; i--) stack.push(kids[i]);\n };\n\n if (isElementNode(root)) {\n pushChildren(root);\n if (root.shadowRoot) pushChildren(root.shadowRoot);\n } else {\n pushChildren(root);\n }\n\n while (stack.length > 0) {\n const el = stack.pop()!;\n yield el;\n pushChildren(el);\n if (el.shadowRoot) pushChildren(el.shadowRoot);\n }\n}\n\nconst PARSE_CACHE_LIMIT = 512;\nconst parseCache = new Map<string, string[][]>();\n\n/** Split into comma-separated parts, each tokenized as [compound, combinator, ...]. Memoized. */\nfunction parseSelector(selector: string): string[][] {\n const cached = parseCache.get(selector);\n if (cached) return cached;\n\n const parts: string[][] = [];\n for (const part of splitByComma(selector)) {\n const tokens = tokenizePath(part);\n if (tokens.length > 0) parts.push(tokens);\n }\n\n if (parseCache.size >= PARSE_CACHE_LIMIT) parseCache.clear();\n parseCache.set(selector, parts);\n return parts;\n}\n\n/**\n * Candidates for one tokenized selector part: elements matching the\n * right-most compound, natively pre-filtered inside each root.\n * Returns the candidates either as a single ordered list (when only one root\n * produced hits) or as a Set plus a flag that a composed-order walk is needed.\n */\nfunction collectCandidates<T extends Element>(\n roots: QueryableNode[],\n rightMostCompound: string,\n): { list: T[] | null; set: Set<T> | null; rootsWithHits: number } {\n let list: T[] | null = null;\n let set: Set<T> | null = null;\n let rootsWithHits = 0;\n\n for (const root of roots) {\n let found: NodeListOf<T>;\n try {\n found = root.querySelectorAll<T>(rightMostCompound);\n } catch {\n continue; // selector not valid in this root's context\n }\n if (found.length === 0) continue;\n rootsWithHits++;\n if (!list) {\n list = Array.from(found);\n } else {\n if (!set) set = new Set(list);\n for (let i = 0; i < found.length; i++) set.add(found[i]);\n }\n }\n return { list, set, rootsWithHits };\n}\n\n/**\n * Finds the first matching element on the page, piercing any number of nested\n * shadow roots. Same signature and semantics as the original library.\n */\nexport function querySelectorDeep<T extends Element = HTMLElement>(\n selector: string,\n root: QueryableNode = document,\n allElements: Element[] | null = null,\n): T | null {\n if (!selector || !selector.trim()) return null;\n\n // Native fast path — identical to the original library: a plain\n // light-DOM match always wins, no matter what lives in shadow roots.\n const lightElement = root.querySelector<T>(selector);\n if (lightElement) return lightElement;\n\n const parts = parseSelector(selector);\n if (parts.length === 0) return null;\n\n // Caller-supplied element list (original API's third argument).\n if (allElements) {\n for (const tokens of parts) {\n const last = tokens[tokens.length - 1];\n for (const el of allElements) {\n if (\n matchesSelector(el, last) &&\n (tokens.length === 1 || matchesComposedPath(el, tokens, root))\n ) {\n return el as T;\n }\n }\n }\n return null;\n }\n\n const roots = collectRoots(root);\n if (roots.length === 1) return null; // no shadow roots; native query already failed\n\n for (const tokens of parts) {\n const last = tokens[tokens.length - 1];\n const { list, set, rootsWithHits } = collectCandidates<T>(roots, last);\n if (!list) continue;\n\n const verified = (el: T): boolean =>\n tokens.length === 1 || matchesComposedPath(el, tokens, root);\n\n if (rootsWithHits === 1) {\n // All candidates live in a single root → that root's native order is composed order.\n for (const el of list) {\n if (verified(el)) return el;\n }\n } else {\n const candidates = set ?? new Set(list);\n for (const el of iterateDeep(root)) {\n if (candidates.has(el as T) && verified(el as T)) return el as T;\n }\n }\n }\n return null;\n}\n\n/**\n * Finds all matching elements on the page, piercing any number of nested\n * shadow roots. Same signature and semantics as the original library\n * (results are additionally de-duplicated).\n */\nexport function querySelectorAllDeep<T extends Element = HTMLElement>(\n selector: string,\n root: QueryableNode = document,\n allElements: Element[] | null = null,\n): T[] {\n if (!selector || !selector.trim()) return [];\n\n const parts = parseSelector(selector);\n if (parts.length === 0) return [];\n\n // Caller-supplied element list (original API's third argument).\n if (allElements) {\n const out: T[] = [];\n const seen = new Set<Element>();\n for (const tokens of parts) {\n const last = tokens[tokens.length - 1];\n for (const el of allElements) {\n if (seen.has(el) || !matchesSelector(el, last)) continue;\n if (tokens.length === 1 || matchesComposedPath(el, tokens, root)) {\n seen.add(el);\n out.push(el as T);\n }\n }\n }\n return out;\n }\n\n const roots = collectRoots(root);\n\n // No shadow roots below `root` → hand everything to the browser.\n if (roots.length === 1) {\n return Array.from(root.querySelectorAll<T>(selector));\n }\n\n const results: T[] = [];\n const seen = new Set<T>();\n\n for (const tokens of parts) {\n const last = tokens[tokens.length - 1];\n const { list, set, rootsWithHits } = collectCandidates<T>(roots, last);\n if (!list) continue;\n\n if (rootsWithHits === 1) {\n // All candidates live in a single root → its native order is composed order.\n for (const el of list) {\n if (seen.has(el)) continue;\n if (tokens.length === 1 || matchesComposedPath(el, tokens, root)) {\n seen.add(el);\n results.push(el);\n }\n }\n } else {\n // Candidates spread across roots → merge in composed tree order.\n const candidates = set ?? new Set(list);\n const all = collectAllElements(root);\n for (let i = 0; i < all.length; i++) {\n const el = all[i] as T;\n if (!candidates.has(el) || seen.has(el)) continue;\n if (tokens.length === 1 || matchesComposedPath(el, tokens, root)) {\n seen.add(el);\n results.push(el);\n }\n }\n }\n }\n return results;\n}\n\n/**\n * Finds all elements on the page, inclusive of those within shadow roots.\n * Optionally filtered by a CSS selector.\n * Same signature and semantics as the original library.\n */\nexport function collectAllElementsDeep<T extends Element = HTMLElement>(\n selector: string | null = null,\n root: QueryableNode = document,\n cachedElements: Element[] | null = null,\n): T[] {\n if (cachedElements) {\n const all = cachedElements as T[];\n return selector ? all.filter((el) => matchesSelector(el, selector)) : all;\n }\n\n // Single pass: elements are filtered while the tree is being walked.\n return collectAllElements(root, selector ?? undefined) as T[];\n}\n\n/**\n * Split a selector list on top-level commas (ignores commas inside quotes,\n * attribute brackets and pseudo-class parentheses).\n */\nexport function splitByComma(selector: string): string[] {\n if (!selector || !selector.trim()) return [];\n\n const results: string[] = [];\n let current = '';\n let parenDepth = 0;\n let bracketDepth = 0;\n let inSingleQuote = false;\n let inDoubleQuote = false;\n let escaped = false;\n\n for (let i = 0; i < selector.length; i++) {\n const char = selector[i];\n\n if (escaped) {\n current += char;\n escaped = false;\n continue;\n }\n\n if (char === '\\\\') {\n escaped = true;\n current += char;\n continue;\n }\n\n if (char === \"'\" && !inDoubleQuote) {\n inSingleQuote = !inSingleQuote;\n current += char;\n continue;\n }\n\n if (char === '\"' && !inSingleQuote) {\n inDoubleQuote = !inDoubleQuote;\n current += char;\n continue;\n }\n\n if (!inSingleQuote && !inDoubleQuote) {\n if (char === '(') parenDepth++;\n else if (char === ')') parenDepth = Math.max(0, parenDepth - 1);\n else if (char === '[') bracketDepth++;\n else if (char === ']') bracketDepth = Math.max(0, bracketDepth - 1);\n else if (char === ',' && parenDepth === 0 && bracketDepth === 0) {\n results.push(current.trim());\n current = '';\n continue;\n }\n }\n\n current += char;\n }\n\n if (current.trim()) {\n results.push(current.trim());\n }\n\n return results;\n}\n\n/**\n * Tokenize a CSS selector into compounds and combinators:\n * 'div > p span' → ['div', '>', 'p', ' ', 'span'].\n */\nexport function tokenizePath(selector: string): string[] {\n if (!selector || !selector.trim()) return [];\n\n const tokens: string[] = [];\n let current = '';\n let parenDepth = 0;\n let bracketDepth = 0;\n let inSingleQuote = false;\n let inDoubleQuote = false;\n let escaped = false;\n\n const pushCurrent = () => {\n const trimmed = current.trim();\n if (trimmed) {\n tokens.push(trimmed);\n }\n current = '';\n };\n\n for (let i = 0; i < selector.length; i++) {\n const char = selector[i];\n\n if (escaped) {\n current += char;\n escaped = false;\n continue;\n }\n\n if (char === '\\\\') {\n escaped = true;\n current += char;\n continue;\n }\n\n if (char === \"'\" && !inDoubleQuote) {\n inSingleQuote = !inSingleQuote;\n current += char;\n continue;\n }\n\n if (char === '\"' && !inSingleQuote) {\n inDoubleQuote = !inDoubleQuote;\n current += char;\n continue;\n }\n\n if (!inSingleQuote && !inDoubleQuote) {\n if (char === '(') parenDepth++;\n else if (char === ')') parenDepth = Math.max(0, parenDepth - 1);\n else if (char === '[') bracketDepth++;\n else if (char === ']') bracketDepth = Math.max(0, bracketDepth - 1);\n\n if (parenDepth === 0 && bracketDepth === 0) {\n if (char === '>' || char === '+' || char === '~') {\n pushCurrent();\n tokens.push(char);\n continue;\n }\n\n if (/\\s/.test(char)) {\n pushCurrent();\n\n while (i + 1 < selector.length && /\\s/.test(selector[i + 1])) {\n i++;\n }\n\n let nextChar = '';\n for (let j = i + 1; j < selector.length; j++) {\n if (!/\\s/.test(selector[j])) {\n nextChar = selector[j];\n break;\n }\n }\n\n const lastToken = tokens[tokens.length - 1];\n const isLastCombinator =\n lastToken === ' ' || lastToken === '>' || lastToken === '+' || lastToken === '~';\n\n if (\n tokens.length > 0 &&\n !isLastCombinator &&\n nextChar &&\n nextChar !== '>' &&\n nextChar !== '+' &&\n nextChar !== '~'\n ) {\n tokens.push(' ');\n }\n continue;\n }\n }\n }\n\n current += char;\n }\n\n pushCurrent();\n\n return tokens;\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AAIH,MAAM,YAAY,GAAG,CAAC;AACtB,MAAM,sBAAsB,GAAG,EAAE;AAEjC;AACA,SAAS,aAAa,CAAC,IAAa,EAAA;IAChC,OAAO,CAAC,CAAC,IAAI,IAAK,IAAa,CAAC,QAAQ,KAAK,YAAY;AAC7D;AAEA;AACA,SAAS,gBAAgB,CAAC,IAAa,EAAA;IACnC,QACI,CAAC,CAAC,IAAI;QACL,IAAa,CAAC,QAAQ,KAAK,sBAAsB;AAClD,QAAA,CAAC,CAAE,IAAmB,CAAC,IAAI;AAEnC;AAEA;AACA,SAAS,eAAe,CAAC,EAAW,EAAE,QAAgB,EAAA;AAClD,IAAA,IAAI;AACA,QAAA,OAAO,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/B;AAAE,IAAA,MAAM;AACJ,QAAA,OAAO,KAAK;IACh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;AACjB,oBAAA,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;wBAC1C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE;AACzB,4BAAA,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC;4BACtB;wBACJ;oBACJ;oBAEA,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;AAC3C,oBAAA,MAAM,gBAAgB,GAClB,SAAS,KAAK,GAAG,IAAI,SAAS,KAAK,GAAG,IAAI,SAAS,KAAK,GAAG,IAAI,SAAS,KAAK,GAAG;AAEpF,oBAAA,IACI,MAAM,CAAC,MAAM,GAAG,CAAC;AACjB,wBAAA,CAAC,gBAAgB;wBACjB,QAAQ;AACR,wBAAA,QAAQ,KAAK,GAAG;AAChB,wBAAA,QAAQ,KAAK,GAAG;wBAChB,QAAQ,KAAK,GAAG,EAClB;AACE,wBAAA,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;oBACpB;oBACA;gBACJ;YACJ;QACJ;QAEA,OAAO,IAAI,IAAI;IACnB;AAEA,IAAA,WAAW,EAAE;AAEb,IAAA,OAAO,MAAM;AACjB;;;;;;"}
|
package/dist/umd/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["/**\n * query-selector-shadow-dom-modern\n *\n * Drop-in replacement for https://www.npmjs.com/package/query-selector-shadow-dom\n * with the same public API:\n *\n * - querySelectorDeep(selector, root?, allElements?)\n * - querySelectorAllDeep(selector, root?, allElements?)\n * - collectAllElementsDeep(selector?, root?, cachedElements?)\n *\n * but faster and safer:\n * - Native `querySelector(All)` does the heavy lifting whenever possible\n * (whole-selector fast path when no shadow roots are involved, and a\n * per-root pre-filter on the right-most compound selector otherwise).\n * - Selector parsing is memoized (strings are immutable — safe to cache).\n * - No DOM caching: results are always computed from the live tree, so\n * dynamic pages never see stale data.\n * - Full combinator support across shadow boundaries: ` `, `>`, `+`, `~`.\n * - Cross-realm safe (iframe documents): no `instanceof` on DOM classes.\n */\n\nexport type QueryableNode = Document | DocumentFragment | Element;\n\nconst ELEMENT_NODE = 1;\nconst DOCUMENT_FRAGMENT_NODE = 11;\n\n/** Cross-realm-safe Element check (`instanceof` fails across frames). */\nfunction isElementNode(node: unknown): node is Element {\n return !!node && (node as Node).nodeType === ELEMENT_NODE;\n}\n\n/** Cross-realm-safe ShadowRoot check. */\nfunction isHostedFragment(node: unknown): node is ShadowRoot {\n return (\n !!node &&\n (node as Node).nodeType === DOCUMENT_FRAGMENT_NODE &&\n !!(node as ShadowRoot).host\n );\n}\n\n/** `el.matches()` that never throws (context-dependent pseudo-classes etc.). */\nfunction matchesSelector(el: Element, compound: string): boolean {\n try {\n return el.matches(compound);\n } catch {\n return false;\n }\n}\n\n/**\n * Parent in the composed (flat-ish) tree: crosses shadow boundaries towards\n * the host, and stops at the boundary the search was scoped to.\n * Matches the original library's findParentOrHost semantics.\n */\nfunction composedParent(el: Element, boundary: QueryableNode): Element | null {\n if (el === boundary) return null;\n const parent = el.parentElement;\n if (parent) return parent;\n const rootNode = el.getRootNode();\n if (rootNode === el || rootNode === boundary) return null;\n if (isHostedFragment(rootNode)) return rootNode.host;\n return null;\n}\n\n/**\n * Verify that `el` (already known to match the right-most compound) satisfies\n * the whole selector path, walking the composed tree right-to-left.\n * `tokens` looks like: [compound, combinator, compound, ...].\n */\nfunction matchesComposedPath(el: Element, tokens: string[], boundary: QueryableNode): boolean {\n let node: Element | null = el;\n let i = tokens.length - 1;\n\n while (i > 0 && node) {\n const combinator = tokens[i - 1];\n const compound = tokens[i - 2];\n\n if (combinator === '>') {\n node = composedParent(node, boundary);\n if (!node || !matchesSelector(node, compound)) return false;\n } else if (combinator === '+') {\n node = node.previousElementSibling;\n if (!node || !matchesSelector(node, compound)) return false;\n } else if (combinator === '~') {\n node = node.previousElementSibling;\n let found = false;\n while (node) {\n if (matchesSelector(node, compound)) {\n found = true;\n break;\n }\n node = node.previousElementSibling;\n }\n if (!found) return false;\n } else {\n // descendant combinator\n node = composedParent(node, boundary);\n let found = false;\n while (node) {\n if (matchesSelector(node, compound)) {\n found = true;\n break;\n }\n node = composedParent(node, boundary);\n }\n if (!found) return false;\n }\n i -= 2;\n }\n return i <= 0;\n}\n\n/**\n * All queryable roots below (and including) `root`: the root itself plus every\n * open shadow root found underneath, in discovery order. Computed fresh on\n * every call — never cached, so dynamic DOMs are always correct.\n */\nfunction collectRoots(root: QueryableNode): QueryableNode[] {\n const roots: QueryableNode[] = [root];\n const pending: QueryableNode[] = [];\n\n if (isElementNode(root) && root.shadowRoot) {\n roots.push(root.shadowRoot);\n pending.push(root.shadowRoot);\n }\n\n let scope: QueryableNode | undefined = root;\n while (scope) {\n const all = scope.querySelectorAll('*');\n for (let i = 0; i < all.length; i++) {\n const shadowRoot = (all[i] as Element).shadowRoot;\n if (shadowRoot) {\n roots.push(shadowRoot);\n pending.push(shadowRoot);\n }\n }\n scope = pending.pop();\n }\n return roots;\n}\n\n/**\n * Collect every element under `root` in the original library's order\n * (composed tree pre-order: a host's shadow content comes immediately after\n * the host element). One native `querySelectorAll('*')` per root — the\n * browser does the walking.\n */\nfunction collectAllElements(root: QueryableNode, filter?: string): Element[] {\n const out: Element[] = [];\n collectInto(root, out, filter);\n return out;\n}\n\nfunction collectInto(scope: QueryableNode, out: Element[], filter?: string): void {\n // A root element's own shadow content is listed first (original behavior).\n if (isElementNode(scope) && scope.shadowRoot) {\n collectList(scope.shadowRoot.querySelectorAll('*'), out, filter);\n }\n collectList(scope.querySelectorAll('*'), out, filter);\n}\n\nfunction collectList(list: NodeListOf<Element>, out: Element[], filter?: string): void {\n for (let i = 0; i < list.length; i++) {\n const el = list[i];\n if (!filter || matchesSelector(el, filter)) {\n out.push(el);\n }\n const shadowRoot = el.shadowRoot;\n if (shadowRoot) {\n collectList(shadowRoot.querySelectorAll('*'), out, filter);\n }\n }\n}\n\n/**\n * Generator variant of the same traversal, for callers that can stop early.\n */\nfunction* iterateDeep(root: QueryableNode): Generator<Element, void, undefined> {\n const stack: Element[] = [];\n const pushChildren = (scope: QueryableNode) => {\n const kids = scope.children;\n for (let i = kids.length - 1; i >= 0; i--) stack.push(kids[i]);\n };\n\n if (isElementNode(root)) {\n pushChildren(root);\n if (root.shadowRoot) pushChildren(root.shadowRoot);\n } else {\n pushChildren(root);\n }\n\n while (stack.length > 0) {\n const el = stack.pop()!;\n yield el;\n pushChildren(el);\n if (el.shadowRoot) pushChildren(el.shadowRoot);\n }\n}\n\nconst PARSE_CACHE_LIMIT = 512;\nconst parseCache = new Map<string, string[][]>();\n\n/** Split into comma-separated parts, each tokenized as [compound, combinator, ...]. Memoized. */\nfunction parseSelector(selector: string): string[][] {\n const cached = parseCache.get(selector);\n if (cached) return cached;\n\n const parts: string[][] = [];\n for (const part of splitByComma(selector)) {\n const tokens = tokenizePath(part);\n if (tokens.length > 0) parts.push(tokens);\n }\n\n if (parseCache.size >= PARSE_CACHE_LIMIT) parseCache.clear();\n parseCache.set(selector, parts);\n return parts;\n}\n\n/**\n * Candidates for one tokenized selector part: elements matching the\n * right-most compound, natively pre-filtered inside each root.\n * Returns the candidates either as a single ordered list (when only one root\n * produced hits) or as a Set plus a flag that a composed-order walk is needed.\n */\nfunction collectCandidates<T extends Element>(\n roots: QueryableNode[],\n rightMostCompound: string,\n): { list: T[] | null; set: Set<T> | null; rootsWithHits: number } {\n let list: T[] | null = null;\n let set: Set<T> | null = null;\n let rootsWithHits = 0;\n\n for (const root of roots) {\n let found: NodeListOf<T>;\n try {\n found = root.querySelectorAll<T>(rightMostCompound);\n } catch {\n continue; // selector not valid in this root's context\n }\n if (found.length === 0) continue;\n rootsWithHits++;\n if (!list) {\n list = Array.from(found);\n } else {\n if (!set) set = new Set(list);\n for (let i = 0; i < found.length; i++) set.add(found[i]);\n }\n }\n return { list, set, rootsWithHits };\n}\n\n/**\n * Finds the first matching element on the page, piercing any number of nested\n * shadow roots. Same signature and semantics as the original library.\n */\nexport function querySelectorDeep<T extends Element = HTMLElement>(\n selector: string,\n root: QueryableNode = document,\n allElements: Element[] | null = null,\n): T | null {\n if (!selector || !selector.trim()) return null;\n\n // Native fast path — identical to the original library: a plain\n // light-DOM match always wins, no matter what lives in shadow roots.\n const lightElement = root.querySelector<T>(selector);\n if (lightElement) return lightElement;\n\n const parts = parseSelector(selector);\n if (parts.length === 0) return null;\n\n // Caller-supplied element list (original API's third argument).\n if (allElements) {\n for (const tokens of parts) {\n const last = tokens[tokens.length - 1];\n for (const el of allElements) {\n if (\n matchesSelector(el, last) &&\n (tokens.length === 1 || matchesComposedPath(el, tokens, root))\n ) {\n return el as T;\n }\n }\n }\n return null;\n }\n\n const roots = collectRoots(root);\n if (roots.length === 1) return null; // no shadow roots; native query already failed\n\n for (const tokens of parts) {\n const last = tokens[tokens.length - 1];\n const { list, set, rootsWithHits } = collectCandidates<T>(roots, last);\n if (!list) continue;\n\n const verified = (el: T): boolean =>\n tokens.length === 1 || matchesComposedPath(el, tokens, root);\n\n if (rootsWithHits === 1) {\n // All candidates live in a single root → that root's native order is composed order.\n for (const el of list) {\n if (verified(el)) return el;\n }\n } else {\n const candidates = set ?? new Set(list);\n for (const el of iterateDeep(root)) {\n if (candidates.has(el as T) && verified(el as T)) return el as T;\n }\n }\n }\n return null;\n}\n\n/**\n * Finds all matching elements on the page, piercing any number of nested\n * shadow roots. Same signature and semantics as the original library\n * (results are additionally de-duplicated).\n */\nexport function querySelectorAllDeep<T extends Element = HTMLElement>(\n selector: string,\n root: QueryableNode = document,\n allElements: Element[] | null = null,\n): T[] {\n if (!selector || !selector.trim()) return [];\n\n const parts = parseSelector(selector);\n if (parts.length === 0) return [];\n\n // Caller-supplied element list (original API's third argument).\n if (allElements) {\n const out: T[] = [];\n const seen = new Set<Element>();\n for (const tokens of parts) {\n const last = tokens[tokens.length - 1];\n for (const el of allElements) {\n if (seen.has(el) || !matchesSelector(el, last)) continue;\n if (tokens.length === 1 || matchesComposedPath(el, tokens, root)) {\n seen.add(el);\n out.push(el as T);\n }\n }\n }\n return out;\n }\n\n const roots = collectRoots(root);\n\n // No shadow roots below `root` → hand everything to the browser.\n if (roots.length === 1) {\n return Array.from(root.querySelectorAll<T>(selector));\n }\n\n const results: T[] = [];\n const seen = new Set<T>();\n\n for (const tokens of parts) {\n const last = tokens[tokens.length - 1];\n const { list, set, rootsWithHits } = collectCandidates<T>(roots, last);\n if (!list) continue;\n\n if (rootsWithHits === 1) {\n // All candidates live in a single root → its native order is composed order.\n for (const el of list) {\n if (seen.has(el)) continue;\n if (tokens.length === 1 || matchesComposedPath(el, tokens, root)) {\n seen.add(el);\n results.push(el);\n }\n }\n } else {\n // Candidates spread across roots → merge in composed tree order.\n const candidates = set ?? new Set(list);\n const all = collectAllElements(root);\n for (let i = 0; i < all.length; i++) {\n const el = all[i] as T;\n if (!candidates.has(el) || seen.has(el)) continue;\n if (tokens.length === 1 || matchesComposedPath(el, tokens, root)) {\n seen.add(el);\n results.push(el);\n }\n }\n }\n }\n return results;\n}\n\n/**\n * Finds all elements on the page, inclusive of those within shadow roots.\n * Optionally filtered by a CSS selector.\n * Same signature and semantics as the original library.\n */\nexport function collectAllElementsDeep<T extends Element = HTMLElement>(\n selector: string | null = null,\n root: QueryableNode = document,\n cachedElements: Element[] | null = null,\n): T[] {\n if (cachedElements) {\n const all = cachedElements as T[];\n return selector ? all.filter((el) => matchesSelector(el, selector)) : all;\n }\n\n // Single pass: elements are filtered while the tree is being walked.\n return collectAllElements(root, selector ?? undefined) as T[];\n}\n\n/**\n * Split a selector list on top-level commas (ignores commas inside quotes,\n * attribute brackets and pseudo-class parentheses).\n */\nexport function splitByComma(selector: string): string[] {\n if (!selector || !selector.trim()) return [];\n\n const results: string[] = [];\n let current = '';\n let parenDepth = 0;\n let bracketDepth = 0;\n let inSingleQuote = false;\n let inDoubleQuote = false;\n let escaped = false;\n\n for (let i = 0; i < selector.length; i++) {\n const char = selector[i];\n\n if (escaped) {\n current += char;\n escaped = false;\n continue;\n }\n\n if (char === '\\\\') {\n escaped = true;\n current += char;\n continue;\n }\n\n if (char === \"'\" && !inDoubleQuote) {\n inSingleQuote = !inSingleQuote;\n current += char;\n continue;\n }\n\n if (char === '\"' && !inSingleQuote) {\n inDoubleQuote = !inDoubleQuote;\n current += char;\n continue;\n }\n\n if (!inSingleQuote && !inDoubleQuote) {\n if (char === '(') parenDepth++;\n else if (char === ')') parenDepth = Math.max(0, parenDepth - 1);\n else if (char === '[') bracketDepth++;\n else if (char === ']') bracketDepth = Math.max(0, bracketDepth - 1);\n else if (char === ',' && parenDepth === 0 && bracketDepth === 0) {\n results.push(current.trim());\n current = '';\n continue;\n }\n }\n\n current += char;\n }\n\n if (current.trim()) {\n results.push(current.trim());\n }\n\n return results;\n}\n\n/**\n * Tokenize a CSS selector into compounds and combinators:\n * 'div > p span' → ['div', '>', 'p', ' ', 'span'].\n */\nexport function tokenizePath(selector: string): string[] {\n if (!selector || !selector.trim()) return [];\n\n const tokens: string[] = [];\n let current = '';\n let parenDepth = 0;\n let bracketDepth = 0;\n let inSingleQuote = false;\n let inDoubleQuote = false;\n let escaped = false;\n\n const pushCurrent = () => {\n const trimmed = current.trim();\n if (trimmed) {\n tokens.push(trimmed);\n }\n current = '';\n };\n\n for (let i = 0; i < selector.length; i++) {\n const char = selector[i];\n\n if (escaped) {\n current += char;\n escaped = false;\n continue;\n }\n\n if (char === '\\\\') {\n escaped = true;\n current += char;\n continue;\n }\n\n if (char === \"'\" && !inDoubleQuote) {\n inSingleQuote = !inSingleQuote;\n current += char;\n continue;\n }\n\n if (char === '\"' && !inSingleQuote) {\n inDoubleQuote = !inDoubleQuote;\n current += char;\n continue;\n }\n\n if (!inSingleQuote && !inDoubleQuote) {\n if (char === '(') parenDepth++;\n else if (char === ')') parenDepth = Math.max(0, parenDepth - 1);\n else if (char === '[') bracketDepth++;\n else if (char === ']') bracketDepth = Math.max(0, bracketDepth - 1);\n\n if (parenDepth === 0 && bracketDepth === 0) {\n if (char === '>' || char === '+' || char === '~') {\n pushCurrent();\n tokens.push(char);\n continue;\n }\n\n if (/\\s/.test(char)) {\n pushCurrent();\n\n while (i + 1 < selector.length && /\\s/.test(selector[i + 1])) {\n i++;\n }\n\n let nextChar = '';\n for (let j = i + 1; j < selector.length; j++) {\n if (!/\\s/.test(selector[j])) {\n nextChar = selector[j];\n break;\n }\n }\n\n const lastToken = tokens[tokens.length - 1];\n const isLastCombinator =\n lastToken === ' ' || lastToken === '>' || lastToken === '+' || lastToken === '~';\n\n if (\n tokens.length > 0 &&\n !isLastCombinator &&\n nextChar &&\n nextChar !== '>' &&\n nextChar !== '+' &&\n nextChar !== '~'\n ) {\n tokens.push(' ');\n }\n continue;\n }\n }\n }\n\n current += char;\n }\n\n pushCurrent();\n\n return tokens;\n}\n"],"names":[],"mappings":";;;;;;IAAA;;;;;;;;;;;;;;;;;;;IAmBG;IAIH,MAAM,YAAY,GAAG,CAAC;IACtB,MAAM,sBAAsB,GAAG,EAAE;IAEjC;IACA,SAAS,aAAa,CAAC,IAAa,EAAA;QAChC,OAAO,CAAC,CAAC,IAAI,IAAK,IAAa,CAAC,QAAQ,KAAK,YAAY;IAC7D;IAEA;IACA,SAAS,gBAAgB,CAAC,IAAa,EAAA;QACnC,QACI,CAAC,CAAC,IAAI;YACL,IAAa,CAAC,QAAQ,KAAK,sBAAsB;IAClD,QAAA,CAAC,CAAE,IAAmB,CAAC,IAAI;IAEnC;IAEA;IACA,SAAS,eAAe,CAAC,EAAW,EAAE,QAAgB,EAAA;IAClD,IAAA,IAAI;IACA,QAAA,OAAO,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC/B;IAAE,IAAA,MAAM;IACJ,QAAA,OAAO,KAAK;QAChB;IACJ;IAEA;;;;IAIG;IACH,SAAS,cAAc,CAAC,EAAW,EAAE,QAAuB,EAAA;QACxD,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BAAA,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;4BAC1C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE;IACzB,4BAAA,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC;gCACtB;4BACJ;wBACJ;wBAEA,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3C,oBAAA,MAAM,gBAAgB,GAClB,SAAS,KAAK,GAAG,IAAI,SAAS,KAAK,GAAG,IAAI,SAAS,KAAK,GAAG,IAAI,SAAS,KAAK,GAAG;IAEpF,oBAAA,IACI,MAAM,CAAC,MAAM,GAAG,CAAC;IACjB,wBAAA,CAAC,gBAAgB;4BACjB,QAAQ;IACR,wBAAA,QAAQ,KAAK,GAAG;IAChB,wBAAA,QAAQ,KAAK,GAAG;4BAChB,QAAQ,KAAK,GAAG,EAClB;IACE,wBAAA,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;wBACpB;wBACA;oBACJ;gBACJ;YACJ;YAEA,OAAO,IAAI,IAAI;QACnB;IAEA,IAAA,WAAW,EAAE;IAEb,IAAA,OAAO,MAAM;IACjB;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["/**\n * query-selector-shadow-dom-modern\n *\n * Drop-in replacement for https://www.npmjs.com/package/query-selector-shadow-dom\n * with the same public API:\n *\n * - querySelectorDeep(selector, root?, allElements?)\n * - querySelectorAllDeep(selector, root?, allElements?)\n * - collectAllElementsDeep(selector?, root?, cachedElements?)\n *\n * but faster and safer:\n * - Native `querySelector(All)` does the heavy lifting whenever possible\n * (whole-selector fast path when no shadow roots are involved, and a\n * per-root pre-filter on the right-most compound selector otherwise).\n * - Selector parsing is memoized (strings are immutable — safe to cache).\n * - No DOM caching: results are always computed from the live tree, so\n * dynamic pages never see stale data.\n * - Full combinator support across shadow boundaries: ` `, `>`, `+`, `~`.\n * - Cross-realm safe (iframe documents): no `instanceof` on DOM classes.\n */\n\nexport type QueryableNode = Document | DocumentFragment | Element;\n\nconst ELEMENT_NODE = 1;\nconst DOCUMENT_FRAGMENT_NODE = 11;\n\n/** Cross-realm-safe Element check (`instanceof` fails across frames). */\nfunction isElementNode(node: unknown): node is Element {\n return !!node && (node as Node).nodeType === ELEMENT_NODE;\n}\n\n/** Cross-realm-safe ShadowRoot check. */\nfunction isHostedFragment(node: unknown): node is ShadowRoot {\n return (\n !!node &&\n (node as Node).nodeType === DOCUMENT_FRAGMENT_NODE &&\n !!(node as ShadowRoot).host\n );\n}\n\n/** `el.matches()` that never throws (context-dependent pseudo-classes etc.). */\nfunction matchesSelector(el: Element, compound: string): boolean {\n try {\n return el.matches(compound);\n } catch {\n return false;\n }\n}\n\n/**\n * Parent in the composed (flat-ish) tree: crosses shadow boundaries towards\n * the host, and stops at the boundary the search was scoped to.\n * Matches the original library's findParentOrHost semantics.\n */\nfunction composedParent(el: Element, boundary: QueryableNode): Element | null {\n if (el === boundary) return null;\n const parent = el.parentElement;\n if (parent) return parent;\n const rootNode = el.getRootNode();\n if (rootNode === el || rootNode === boundary) return null;\n if (isHostedFragment(rootNode)) return rootNode.host;\n return null;\n}\n\n/**\n * Verify that `el` (already known to match the right-most compound) satisfies\n * the whole selector path, walking the composed tree right-to-left.\n * `tokens` looks like: [compound, combinator, compound, ...].\n */\nfunction matchesComposedPath(el: Element, tokens: string[], boundary: QueryableNode): boolean {\n let node: Element | null = el;\n let i = tokens.length - 1;\n\n while (i > 0 && node) {\n const combinator = tokens[i - 1];\n const compound = tokens[i - 2];\n\n if (combinator === '>') {\n node = composedParent(node, boundary);\n if (!node || !matchesSelector(node, compound)) return false;\n } else if (combinator === '+') {\n node = node.previousElementSibling;\n if (!node || !matchesSelector(node, compound)) return false;\n } else if (combinator === '~') {\n node = node.previousElementSibling;\n let found = false;\n while (node) {\n if (matchesSelector(node, compound)) {\n found = true;\n break;\n }\n node = node.previousElementSibling;\n }\n if (!found) return false;\n } else {\n // descendant combinator\n node = composedParent(node, boundary);\n let found = false;\n while (node) {\n if (matchesSelector(node, compound)) {\n found = true;\n break;\n }\n node = composedParent(node, boundary);\n }\n if (!found) return false;\n }\n i -= 2;\n }\n return i <= 0;\n}\n\n/**\n * All queryable roots below (and including) `root`: the root itself plus every\n * open shadow root found underneath, in discovery order. Computed fresh on\n * every call — never cached, so dynamic DOMs are always correct.\n */\nfunction collectRoots(root: QueryableNode): QueryableNode[] {\n const roots: QueryableNode[] = [root];\n const pending: QueryableNode[] = [];\n\n if (isElementNode(root) && root.shadowRoot) {\n roots.push(root.shadowRoot);\n pending.push(root.shadowRoot);\n }\n\n let scope: QueryableNode | undefined = root;\n while (scope) {\n const all = scope.querySelectorAll('*');\n for (let i = 0; i < all.length; i++) {\n const shadowRoot = (all[i] as Element).shadowRoot;\n if (shadowRoot) {\n roots.push(shadowRoot);\n pending.push(shadowRoot);\n }\n }\n scope = pending.pop();\n }\n return roots;\n}\n\n/**\n * Collect every element under `root` in the original library's order\n * (composed tree pre-order: a host's shadow content comes immediately after\n * the host element). One native `querySelectorAll('*')` per root — the\n * browser does the walking.\n */\nfunction collectAllElements(root: QueryableNode, filter?: string): Element[] {\n const out: Element[] = [];\n collectInto(root, out, filter);\n return out;\n}\n\nfunction collectInto(scope: QueryableNode, out: Element[], filter?: string): void {\n // A root element's own shadow content is listed first (original behavior).\n if (isElementNode(scope) && scope.shadowRoot) {\n collectList(scope.shadowRoot.querySelectorAll('*'), out, filter);\n }\n collectList(scope.querySelectorAll('*'), out, filter);\n}\n\nfunction collectList(list: NodeListOf<Element>, out: Element[], filter?: string): void {\n for (let i = 0; i < list.length; i++) {\n const el = list[i];\n if (!filter || matchesSelector(el, filter)) {\n out.push(el);\n }\n const shadowRoot = el.shadowRoot;\n if (shadowRoot) {\n collectList(shadowRoot.querySelectorAll('*'), out, filter);\n }\n }\n}\n\n/**\n * Generator variant of the same traversal, for callers that can stop early.\n */\nfunction* iterateDeep(root: QueryableNode): Generator<Element, void, undefined> {\n const stack: Element[] = [];\n const pushChildren = (scope: QueryableNode) => {\n const kids = scope.children;\n for (let i = kids.length - 1; i >= 0; i--) stack.push(kids[i]);\n };\n\n if (isElementNode(root)) {\n pushChildren(root);\n if (root.shadowRoot) pushChildren(root.shadowRoot);\n } else {\n pushChildren(root);\n }\n\n while (stack.length > 0) {\n const el = stack.pop()!;\n yield el;\n pushChildren(el);\n if (el.shadowRoot) pushChildren(el.shadowRoot);\n }\n}\n\nconst PARSE_CACHE_LIMIT = 512;\nconst parseCache = new Map<string, string[][]>();\n\n/** Split into comma-separated parts, each tokenized as [compound, combinator, ...]. Memoized. */\nfunction parseSelector(selector: string): string[][] {\n const cached = parseCache.get(selector);\n if (cached) return cached;\n\n const parts: string[][] = [];\n for (const part of splitByComma(selector)) {\n const tokens = tokenizePath(part);\n if (tokens.length > 0) parts.push(tokens);\n }\n\n if (parseCache.size >= PARSE_CACHE_LIMIT) parseCache.clear();\n parseCache.set(selector, parts);\n return parts;\n}\n\n/**\n * Candidates for one tokenized selector part: elements matching the\n * right-most compound, natively pre-filtered inside each root.\n * Returns the candidates either as a single ordered list (when only one root\n * produced hits) or as a Set plus a flag that a composed-order walk is needed.\n */\nfunction collectCandidates<T extends Element>(\n roots: QueryableNode[],\n rightMostCompound: string,\n): { list: T[] | null; set: Set<T> | null; rootsWithHits: number } {\n let list: T[] | null = null;\n let set: Set<T> | null = null;\n let rootsWithHits = 0;\n\n for (const root of roots) {\n let found: NodeListOf<T>;\n try {\n found = root.querySelectorAll<T>(rightMostCompound);\n } catch {\n continue; // selector not valid in this root's context\n }\n if (found.length === 0) continue;\n rootsWithHits++;\n if (!list) {\n list = Array.from(found);\n } else {\n if (!set) set = new Set(list);\n for (let i = 0; i < found.length; i++) set.add(found[i]);\n }\n }\n return { list, set, rootsWithHits };\n}\n\n/**\n * Finds the first matching element on the page, piercing any number of nested\n * shadow roots. Same signature and semantics as the original library.\n */\nexport function querySelectorDeep<T extends Element = HTMLElement>(\n selector: string,\n root: QueryableNode = document,\n allElements: Element[] | null = null,\n): T | null {\n if (!selector || !selector.trim()) return null;\n\n // Native fast path — identical to the original library: a plain\n // light-DOM match always wins, no matter what lives in shadow roots.\n const lightElement = root.querySelector<T>(selector);\n if (lightElement) return lightElement;\n\n const parts = parseSelector(selector);\n if (parts.length === 0) return null;\n\n // Caller-supplied element list (original API's third argument).\n if (allElements) {\n for (const tokens of parts) {\n const last = tokens[tokens.length - 1];\n for (const el of allElements) {\n if (\n matchesSelector(el, last) &&\n (tokens.length === 1 || matchesComposedPath(el, tokens, root))\n ) {\n return el as T;\n }\n }\n }\n return null;\n }\n\n const roots = collectRoots(root);\n if (roots.length === 1) return null; // no shadow roots; native query already failed\n\n for (const tokens of parts) {\n const last = tokens[tokens.length - 1];\n const { list, set, rootsWithHits } = collectCandidates<T>(roots, last);\n if (!list) continue;\n\n const verified = (el: T): boolean =>\n tokens.length === 1 || matchesComposedPath(el, tokens, root);\n\n if (rootsWithHits === 1) {\n // All candidates live in a single root → that root's native order is composed order.\n for (const el of list) {\n if (verified(el)) return el;\n }\n } else {\n const candidates = set ?? new Set(list);\n for (const el of iterateDeep(root)) {\n if (candidates.has(el as T) && verified(el as T)) return el as T;\n }\n }\n }\n return null;\n}\n\n/**\n * Finds all matching elements on the page, piercing any number of nested\n * shadow roots. Same signature and semantics as the original library\n * (results are additionally de-duplicated).\n */\nexport function querySelectorAllDeep<T extends Element = HTMLElement>(\n selector: string,\n root: QueryableNode = document,\n allElements: Element[] | null = null,\n): T[] {\n if (!selector || !selector.trim()) return [];\n\n const parts = parseSelector(selector);\n if (parts.length === 0) return [];\n\n // Caller-supplied element list (original API's third argument).\n if (allElements) {\n const out: T[] = [];\n const seen = new Set<Element>();\n for (const tokens of parts) {\n const last = tokens[tokens.length - 1];\n for (const el of allElements) {\n if (seen.has(el) || !matchesSelector(el, last)) continue;\n if (tokens.length === 1 || matchesComposedPath(el, tokens, root)) {\n seen.add(el);\n out.push(el as T);\n }\n }\n }\n return out;\n }\n\n const roots = collectRoots(root);\n\n // No shadow roots below `root` → hand everything to the browser.\n if (roots.length === 1) {\n return Array.from(root.querySelectorAll<T>(selector));\n }\n\n const results: T[] = [];\n const seen = new Set<T>();\n\n for (const tokens of parts) {\n const last = tokens[tokens.length - 1];\n const { list, set, rootsWithHits } = collectCandidates<T>(roots, last);\n if (!list) continue;\n\n if (rootsWithHits === 1) {\n // All candidates live in a single root → its native order is composed order.\n for (const el of list) {\n if (seen.has(el)) continue;\n if (tokens.length === 1 || matchesComposedPath(el, tokens, root)) {\n seen.add(el);\n results.push(el);\n }\n }\n } else {\n // Candidates spread across roots → merge in composed tree order.\n const candidates = set ?? new Set(list);\n const all = collectAllElements(root);\n for (let i = 0; i < all.length; i++) {\n const el = all[i] as T;\n if (!candidates.has(el) || seen.has(el)) continue;\n if (tokens.length === 1 || matchesComposedPath(el, tokens, root)) {\n seen.add(el);\n results.push(el);\n }\n }\n }\n }\n return results;\n}\n\n/**\n * Finds all elements on the page, inclusive of those within shadow roots.\n * Optionally filtered by a CSS selector.\n * Same signature and semantics as the original library.\n */\nexport function collectAllElementsDeep<T extends Element = HTMLElement>(\n selector: string | null = null,\n root: QueryableNode = document,\n cachedElements: Element[] | null = null,\n): T[] {\n if (cachedElements) {\n const all = cachedElements as T[];\n return selector ? all.filter((el) => matchesSelector(el, selector)) : all;\n }\n\n // Single pass: elements are filtered while the tree is being walked.\n return collectAllElements(root, selector ?? undefined) as T[];\n}\n\n/**\n * Split a selector list on top-level commas (ignores commas inside quotes,\n * attribute brackets and pseudo-class parentheses).\n */\nexport function splitByComma(selector: string): string[] {\n if (!selector || !selector.trim()) return [];\n\n const results: string[] = [];\n let current = '';\n let parenDepth = 0;\n let bracketDepth = 0;\n let inSingleQuote = false;\n let inDoubleQuote = false;\n let escaped = false;\n\n for (let i = 0; i < selector.length; i++) {\n const char = selector[i];\n\n if (escaped) {\n current += char;\n escaped = false;\n continue;\n }\n\n if (char === '\\\\') {\n escaped = true;\n current += char;\n continue;\n }\n\n if (char === \"'\" && !inDoubleQuote) {\n inSingleQuote = !inSingleQuote;\n current += char;\n continue;\n }\n\n if (char === '\"' && !inSingleQuote) {\n inDoubleQuote = !inDoubleQuote;\n current += char;\n continue;\n }\n\n if (!inSingleQuote && !inDoubleQuote) {\n if (char === '(') parenDepth++;\n else if (char === ')') parenDepth = Math.max(0, parenDepth - 1);\n else if (char === '[') bracketDepth++;\n else if (char === ']') bracketDepth = Math.max(0, bracketDepth - 1);\n else if (char === ',' && parenDepth === 0 && bracketDepth === 0) {\n results.push(current.trim());\n current = '';\n continue;\n }\n }\n\n current += char;\n }\n\n if (current.trim()) {\n results.push(current.trim());\n }\n\n return results;\n}\n\n/**\n * Tokenize a CSS selector into compounds and combinators:\n * 'div > p span' → ['div', '>', 'p', ' ', 'span'].\n */\nexport function tokenizePath(selector: string): string[] {\n if (!selector || !selector.trim()) return [];\n\n const tokens: string[] = [];\n let current = '';\n let parenDepth = 0;\n let bracketDepth = 0;\n let inSingleQuote = false;\n let inDoubleQuote = false;\n let escaped = false;\n\n const pushCurrent = () => {\n const trimmed = current.trim();\n if (trimmed) {\n tokens.push(trimmed);\n }\n current = '';\n };\n\n for (let i = 0; i < selector.length; i++) {\n const char = selector[i];\n\n if (escaped) {\n current += char;\n escaped = false;\n continue;\n }\n\n if (char === '\\\\') {\n escaped = true;\n current += char;\n continue;\n }\n\n if (char === \"'\" && !inDoubleQuote) {\n inSingleQuote = !inSingleQuote;\n current += char;\n continue;\n }\n\n if (char === '\"' && !inSingleQuote) {\n inDoubleQuote = !inDoubleQuote;\n current += char;\n continue;\n }\n\n if (!inSingleQuote && !inDoubleQuote) {\n if (char === '(') parenDepth++;\n else if (char === ')') parenDepth = Math.max(0, parenDepth - 1);\n else if (char === '[') bracketDepth++;\n else if (char === ']') bracketDepth = Math.max(0, bracketDepth - 1);\n\n if (parenDepth === 0 && bracketDepth === 0) {\n if (char === '>' || char === '+' || char === '~') {\n pushCurrent();\n tokens.push(char);\n continue;\n }\n\n if (/\\s/.test(char)) {\n pushCurrent();\n\n while (i + 1 < selector.length && /\\s/.test(selector[i + 1])) {\n i++;\n }\n\n let nextChar = '';\n for (let j = i + 1; j < selector.length; j++) {\n if (!/\\s/.test(selector[j])) {\n nextChar = selector[j];\n break;\n }\n }\n\n const lastToken = tokens[tokens.length - 1];\n const isLastCombinator =\n lastToken === ' ' || lastToken === '>' || lastToken === '+' || lastToken === '~';\n\n if (\n tokens.length > 0 &&\n !isLastCombinator &&\n nextChar &&\n nextChar !== '>' &&\n nextChar !== '+' &&\n nextChar !== '~'\n ) {\n tokens.push(' ');\n }\n continue;\n }\n }\n }\n\n current += char;\n }\n\n pushCurrent();\n\n return tokens;\n}\n"],"names":[],"mappings":";;;;;;IAAA;;;;;;;;;;;;;;;;;;;IAmBG;IAIH,MAAM,YAAY,GAAG,CAAC;IACtB,MAAM,sBAAsB,GAAG,EAAE;IAEjC;IACA,SAAS,aAAa,CAAC,IAAa,EAAA;QAChC,OAAO,CAAC,CAAC,IAAI,IAAK,IAAa,CAAC,QAAQ,KAAK,YAAY;IAC7D;IAEA;IACA,SAAS,gBAAgB,CAAC,IAAa,EAAA;QACnC,QACI,CAAC,CAAC,IAAI;YACL,IAAa,CAAC,QAAQ,KAAK,sBAAsB;IAClD,QAAA,CAAC,CAAE,IAAmB,CAAC,IAAI;IAEnC;IAEA;IACA,SAAS,eAAe,CAAC,EAAW,EAAE,QAAgB,EAAA;IAClD,IAAA,IAAI;IACA,QAAA,OAAO,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC/B;IAAE,IAAA,MAAM;IACJ,QAAA,OAAO,KAAK;QAChB;IACJ;IAEA;;;;IAIG;IACH,SAAS,cAAc,CAAC,EAAW,EAAE,QAAuB,EAAA;QACxD,IAAI,EAAE,KAAK,QAAQ;IAAE,QAAA,OAAO,IA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C,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;4BAC1C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE;IACzB,4BAAA,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC;gCACtB;4BACJ;wBACJ;wBAEA,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3C,oBAAA,MAAM,gBAAgB,GAClB,SAAS,KAAK,GAAG,IAAI,SAAS,KAAK,GAAG,IAAI,SAAS,KAAK,GAAG,IAAI,SAAS,KAAK,GAAG;IAEpF,oBAAA,IACI,MAAM,CAAC,MAAM,GAAG,CAAC;IACjB,wBAAA,CAAC,gBAAgB;4BACjB,QAAQ;IACR,wBAAA,QAAQ,KAAK,GAAG;IAChB,wBAAA,QAAQ,KAAK,GAAG;4BAChB,QAAQ,KAAK,GAAG,EAClB;IACE,wBAAA,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;wBACpB;wBACA;oBACJ;gBACJ;YACJ;YAEA,OAAO,IAAI,IAAI;QACnB;IAEA,IAAA,WAAW,EAAE;IAEb,IAAA,OAAO,MAAM;IACjB;;;;;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";(function(d,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(d=typeof globalThis<"u"?globalThis:d||self,E(d.querySelectorShadowDom={}))})(void 0,(function(d){"use strict";function D(e){return!!e&&e.nodeType===1}function b(e){return!!e&&e.nodeType===11&&!!e.host}function p(e,o){try{return e.matches(o)}catch{return!1}}function R(e,o){if(e===o)return null;const n=e.parentElement;if(n)return n;const t=e.getRootNode();return t===e||t===o?null:b(t)?t.host:null}function w(e,o,n){let t=e,i=o.length-1;for(;i>0&&t;){const f=o[i-1],l=o[i-2];if(f===">"){if(t=R(t,n),!t||!p(t,l))return!1}else if(f==="+"){if(t=t.previousElementSibling,!t||!p(t,l))return!1}else if(f==="~"){t=t.previousElementSibling;let u=!1;for(;t;){if(p(t,l)){u=!0;break}t=t.previousElementSibling}if(!u)return!1}else{t=R(t,n);let u=!1;for(;t;){if(p(t,l)){u=!0;break}t=R(t,n)}if(!u)return!1}i-=2}return i<=0}function k(e){const o=[e],n=[];D(e)&&e.shadowRoot&&(o.push(e.shadowRoot),n.push(e.shadowRoot));let t=e;for(;t;){const i=t.querySelectorAll("*");for(let f=0;f<i.length;f++){const l=i[f].shadowRoot;l&&(o.push(l),n.push(l))}t=n.pop()}return o}function C(e,o){const n=[];return _(e,n,o),n}function _(e,o,n){D(e)&&e.shadowRoot&&A(e.shadowRoot.querySelectorAll("*"),o,n),A(e.querySelectorAll("*"),o,n)}function A(e,o,n){for(let t=0;t<e.length;t++){const i=e[t];(!n||p(i,n))&&o.push(i);const f=i.shadowRoot;f&&A(f.querySelectorAll("*"),o,n)}}function*O(e){const o=[],n=t=>{const i=t.children;for(let f=i.length-1;f>=0;f--)o.push(i[f])};for(D(e)?(n(e),e.shadowRoot&&n(e.shadowRoot)):n(e);o.length>0;){const t=o.pop();yield t,n(t),t.shadowRoot&&n(t.shadowRoot)}}const H=512,y=new Map;function N(e){const o=y.get(e);if(o)return o;const n=[];for(const t of M(e)){const i=T(t);i.length>0&&n.push(i)}return y.size>=H&&y.clear(),y.set(e,n),n}function q(e,o){let n=null,t=null,i=0;for(const f of e){let l;try{l=f.querySelectorAll(o)}catch{continue}if(l.length!==0)if(i++,!n)n=Array.from(l);else{t||(t=new Set(n));for(let u=0;u<l.length;u++)t.add(l[u])}}return{list:n,set:t,rootsWithHits:i}}function L(e,o=document,n=null){if(!e||!e.trim())return null;const t=o.querySelector(e);if(t)return t;const i=N(e);if(i.length===0)return null;if(n){for(const l of i){const u=l[l.length-1];for(const c of n)if(p(c,u)&&(l.length===1||w(c,l,o)))return c}return null}const f=k(o);if(f.length===1)return null;for(const l of i){const u=l[l.length-1],{list:c,set:s,rootsWithHits:r}=q(f,u);if(!c)continue;const a=h=>l.length===1||w(h,l,o);if(r===1){for(const h of c)if(a(h))return h}else{const h=s??new Set(c);for(const m of O(o))if(h.has(m)&&a(m))return m}}return null}function P(e,o=document,n=null){if(!e||!e.trim())return[];const t=N(e);if(t.length===0)return[];if(n){const u=[],c=new Set;for(const s of t){const r=s[s.length-1];for(const a of n)c.has(a)||!p(a,r)||(s.length===1||w(a,s,o))&&(c.add(a),u.push(a))}return u}const i=k(o);if(i.length===1)return Array.from(o.querySelectorAll(e));const f=[],l=new Set;for(const u of t){const c=u[u.length-1],{list:s,set:r,rootsWithHits:a}=q(i,c);if(s)if(a===1)for(const h of s)l.has(h)||(u.length===1||w(h,u,o))&&(l.add(h),f.push(h));else{const h=r??new Set(s),m=C(o);for(let g=0;g<m.length;g++){const S=m[g];!h.has(S)||l.has(S)||(u.length===1||w(S,u,o))&&(l.add(S),f.push(S))}}}return f}function v(e=null,o=document,n=null){if(n){const t=n;return e?t.filter(i=>p(i,e)):t}return C(o,e??void 0)}function M(e){if(!e||!e.trim())return[];const o=[];let n="",t=0,i=0,f=!1,l=!1,u=!1;for(let c=0;c<e.length;c++){const s=e[c];if(u){n+=s,u=!1;continue}if(s==="\\"){u=!0,n+=s;continue}if(s==="'"&&!l){f=!f,n+=s;continue}if(s==='"'&&!f){l=!l,n+=s;continue}if(!f&&!l){if(s==="(")t++;else if(s===")")t=Math.max(0,t-1);else if(s==="[")i++;else if(s==="]")i=Math.max(0,i-1);else if(s===","&&t===0&&i===0){o.push(n.trim()),n="";continue}}n+=s}return n.trim()&&o.push(n.trim()),o}function T(e){if(!e||!e.trim())return[];const o=[];let n="",t=0,i=0,f=!1,l=!1,u=!1;const c=()=>{const s=n.trim();s&&o.push(s),n=""};for(let s=0;s<e.length;s++){const r=e[s];if(u){n+=r,u=!1;continue}if(r==="\\"){u=!0,n+=r;continue}if(r==="'"&&!l){f=!f,n+=r;continue}if(r==='"'&&!f){l=!l,n+=r;continue}if(!f&&!l&&(r==="("?t++:r===")"?t=Math.max(0,t-1):r==="["?i++:r==="]"&&(i=Math.max(0,i-1)),t===0&&i===0)){if(r===">"||r==="+"||r==="~"){c(),o.push(r);continue}if(/\s/.test(r)){for(c();s+1<e.length&&/\s/.test(e[s+1]);)s++;let a="";for(let g=s+1;g<e.length;g++)if(!/\s/.test(e[g])){a=e[g];break}const h=o[o.length-1],m=h===" "||h===">"||h==="+"||h==="~";o.length>0&&!m&&a&&a!==">"&&a!=="+"&&a!=="~"&&o.push(" ");continue}}n+=r}return c(),o}d.collectAllElementsDeep=v,d.querySelectorAllDeep=P,d.querySelectorDeep=L,d.splitByComma=M,d.tokenizePath=T}));
|
|
2
|
+
//# sourceMappingURL=index.min.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * query-selector-shadow-dom-modern\n *\n * Drop-in replacement for https://www.npmjs.com/package/query-selector-shadow-dom\n * with the same public API:\n *\n * - querySelectorDeep(selector, root?, allElements?)\n * - querySelectorAllDeep(selector, root?, allElements?)\n * - collectAllElementsDeep(selector?, root?, cachedElements?)\n *\n * but faster and safer:\n * - Native `querySelector(All)` does the heavy lifting whenever possible\n * (whole-selector fast path when no shadow roots are involved, and a\n * per-root pre-filter on the right-most compound selector otherwise).\n * - Selector parsing is memoized (strings are immutable — safe to cache).\n * - No DOM caching: results are always computed from the live tree, so\n * dynamic pages never see stale data.\n * - Full combinator support across shadow boundaries: ` `, `>`, `+`, `~`.\n * - Cross-realm safe (iframe documents): no `instanceof` on DOM classes.\n */\n\nexport type QueryableNode = Document | DocumentFragment | Element;\n\nconst ELEMENT_NODE = 1;\nconst DOCUMENT_FRAGMENT_NODE = 11;\n\n/** Cross-realm-safe Element check (`instanceof` fails across frames). */\nfunction isElementNode(node: unknown): node is Element {\n return !!node && (node as Node).nodeType === ELEMENT_NODE;\n}\n\n/** Cross-realm-safe ShadowRoot check. */\nfunction isHostedFragment(node: unknown): node is ShadowRoot {\n return (\n !!node &&\n (node as Node).nodeType === DOCUMENT_FRAGMENT_NODE &&\n !!(node as ShadowRoot).host\n );\n}\n\n/** `el.matches()` that never throws (context-dependent pseudo-classes etc.). */\nfunction matchesSelector(el: Element, compound: string): boolean {\n try {\n return el.matches(compound);\n } catch {\n return false;\n }\n}\n\n/**\n * Parent in the composed (flat-ish) tree: crosses shadow boundaries towards\n * the host, and stops at the boundary the search was scoped to.\n * Matches the original library's findParentOrHost semantics.\n */\nfunction composedParent(el: Element, boundary: QueryableNode): Element | null {\n if (el === boundary) return null;\n const parent = el.parentElement;\n if (parent) return parent;\n const rootNode = el.getRootNode();\n if (rootNode === el || rootNode === boundary) return null;\n if (isHostedFragment(rootNode)) return rootNode.host;\n return null;\n}\n\n/**\n * Verify that `el` (already known to match the right-most compound) satisfies\n * the whole selector path, walking the composed tree right-to-left.\n * `tokens` looks like: [compound, combinator, compound, ...].\n */\nfunction matchesComposedPath(el: Element, tokens: string[], boundary: QueryableNode): boolean {\n let node: Element | null = el;\n let i = tokens.length - 1;\n\n while (i > 0 && node) {\n const combinator = tokens[i - 1];\n const compound = tokens[i - 2];\n\n if (combinator === '>') {\n node = composedParent(node, boundary);\n if (!node || !matchesSelector(node, compound)) return false;\n } else if (combinator === '+') {\n node = node.previousElementSibling;\n if (!node || !matchesSelector(node, compound)) return false;\n } else if (combinator === '~') {\n node = node.previousElementSibling;\n let found = false;\n while (node) {\n if (matchesSelector(node, compound)) {\n found = true;\n break;\n }\n node = node.previousElementSibling;\n }\n if (!found) return false;\n } else {\n // descendant combinator\n node = composedParent(node, boundary);\n let found = false;\n while (node) {\n if (matchesSelector(node, compound)) {\n found = true;\n break;\n }\n node = composedParent(node, boundary);\n }\n if (!found) return false;\n }\n i -= 2;\n }\n return i <= 0;\n}\n\n/**\n * All queryable roots below (and including) `root`: the root itself plus every\n * open shadow root found underneath, in discovery order. Computed fresh on\n * every call — never cached, so dynamic DOMs are always correct.\n */\nfunction collectRoots(root: QueryableNode): QueryableNode[] {\n const roots: QueryableNode[] = [root];\n const pending: QueryableNode[] = [];\n\n if (isElementNode(root) && root.shadowRoot) {\n roots.push(root.shadowRoot);\n pending.push(root.shadowRoot);\n }\n\n let scope: QueryableNode | undefined = root;\n while (scope) {\n const all = scope.querySelectorAll('*');\n for (let i = 0; i < all.length; i++) {\n const shadowRoot = (all[i] as Element).shadowRoot;\n if (shadowRoot) {\n roots.push(shadowRoot);\n pending.push(shadowRoot);\n }\n }\n scope = pending.pop();\n }\n return roots;\n}\n\n/**\n * Collect every element under `root` in the original library's order\n * (composed tree pre-order: a host's shadow content comes immediately after\n * the host element). One native `querySelectorAll('*')` per root — the\n * browser does the walking.\n */\nfunction collectAllElements(root: QueryableNode, filter?: string): Element[] {\n const out: Element[] = [];\n collectInto(root, out, filter);\n return out;\n}\n\nfunction collectInto(scope: QueryableNode, out: Element[], filter?: string): void {\n // A root element's own shadow content is listed first (original behavior).\n if (isElementNode(scope) && scope.shadowRoot) {\n collectList(scope.shadowRoot.querySelectorAll('*'), out, filter);\n }\n collectList(scope.querySelectorAll('*'), out, filter);\n}\n\nfunction collectList(list: NodeListOf<Element>, out: Element[], filter?: string): void {\n for (let i = 0; i < list.length; i++) {\n const el = list[i];\n if (!filter || matchesSelector(el, filter)) {\n out.push(el);\n }\n const shadowRoot = el.shadowRoot;\n if (shadowRoot) {\n collectList(shadowRoot.querySelectorAll('*'), out, filter);\n }\n }\n}\n\n/**\n * Generator variant of the same traversal, for callers that can stop early.\n */\nfunction* iterateDeep(root: QueryableNode): Generator<Element, void, undefined> {\n const stack: Element[] = [];\n const pushChildren = (scope: QueryableNode) => {\n const kids = scope.children;\n for (let i = kids.length - 1; i >= 0; i--) stack.push(kids[i]);\n };\n\n if (isElementNode(root)) {\n pushChildren(root);\n if (root.shadowRoot) pushChildren(root.shadowRoot);\n } else {\n pushChildren(root);\n }\n\n while (stack.length > 0) {\n const el = stack.pop()!;\n yield el;\n pushChildren(el);\n if (el.shadowRoot) pushChildren(el.shadowRoot);\n }\n}\n\nconst PARSE_CACHE_LIMIT = 512;\nconst parseCache = new Map<string, string[][]>();\n\n/** Split into comma-separated parts, each tokenized as [compound, combinator, ...]. Memoized. */\nfunction parseSelector(selector: string): string[][] {\n const cached = parseCache.get(selector);\n if (cached) return cached;\n\n const parts: string[][] = [];\n for (const part of splitByComma(selector)) {\n const tokens = tokenizePath(part);\n if (tokens.length > 0) parts.push(tokens);\n }\n\n if (parseCache.size >= PARSE_CACHE_LIMIT) parseCache.clear();\n parseCache.set(selector, parts);\n return parts;\n}\n\n/**\n * Candidates for one tokenized selector part: elements matching the\n * right-most compound, natively pre-filtered inside each root.\n * Returns the candidates either as a single ordered list (when only one root\n * produced hits) or as a Set plus a flag that a composed-order walk is needed.\n */\nfunction collectCandidates<T extends Element>(\n roots: QueryableNode[],\n rightMostCompound: string,\n): { list: T[] | null; set: Set<T> | null; rootsWithHits: number } {\n let list: T[] | null = null;\n let set: Set<T> | null = null;\n let rootsWithHits = 0;\n\n for (const root of roots) {\n let found: NodeListOf<T>;\n try {\n found = root.querySelectorAll<T>(rightMostCompound);\n } catch {\n continue; // selector not valid in this root's context\n }\n if (found.length === 0) continue;\n rootsWithHits++;\n if (!list) {\n list = Array.from(found);\n } else {\n if (!set) set = new Set(list);\n for (let i = 0; i < found.length; i++) set.add(found[i]);\n }\n }\n return { list, set, rootsWithHits };\n}\n\n/**\n * Finds the first matching element on the page, piercing any number of nested\n * shadow roots. Same signature and semantics as the original library.\n */\nexport function querySelectorDeep<T extends Element = HTMLElement>(\n selector: string,\n root: QueryableNode = document,\n allElements: Element[] | null = null,\n): T | null {\n if (!selector || !selector.trim()) return null;\n\n // Native fast path — identical to the original library: a plain\n // light-DOM match always wins, no matter what lives in shadow roots.\n const lightElement = root.querySelector<T>(selector);\n if (lightElement) return lightElement;\n\n const parts = parseSelector(selector);\n if (parts.length === 0) return null;\n\n // Caller-supplied element list (original API's third argument).\n if (allElements) {\n for (const tokens of parts) {\n const last = tokens[tokens.length - 1];\n for (const el of allElements) {\n if (\n matchesSelector(el, last) &&\n (tokens.length === 1 || matchesComposedPath(el, tokens, root))\n ) {\n return el as T;\n }\n }\n }\n return null;\n }\n\n const roots = collectRoots(root);\n if (roots.length === 1) return null; // no shadow roots; native query already failed\n\n for (const tokens of parts) {\n const last = tokens[tokens.length - 1];\n const { list, set, rootsWithHits } = collectCandidates<T>(roots, last);\n if (!list) continue;\n\n const verified = (el: T): boolean =>\n tokens.length === 1 || matchesComposedPath(el, tokens, root);\n\n if (rootsWithHits === 1) {\n // All candidates live in a single root → that root's native order is composed order.\n for (const el of list) {\n if (verified(el)) return el;\n }\n } else {\n const candidates = set ?? new Set(list);\n for (const el of iterateDeep(root)) {\n if (candidates.has(el as T) && verified(el as T)) return el as T;\n }\n }\n }\n return null;\n}\n\n/**\n * Finds all matching elements on the page, piercing any number of nested\n * shadow roots. Same signature and semantics as the original library\n * (results are additionally de-duplicated).\n */\nexport function querySelectorAllDeep<T extends Element = HTMLElement>(\n selector: string,\n root: QueryableNode = document,\n allElements: Element[] | null = null,\n): T[] {\n if (!selector || !selector.trim()) return [];\n\n const parts = parseSelector(selector);\n if (parts.length === 0) return [];\n\n // Caller-supplied element list (original API's third argument).\n if (allElements) {\n const out: T[] = [];\n const seen = new Set<Element>();\n for (const tokens of parts) {\n const last = tokens[tokens.length - 1];\n for (const el of allElements) {\n if (seen.has(el) || !matchesSelector(el, last)) continue;\n if (tokens.length === 1 || matchesComposedPath(el, tokens, root)) {\n seen.add(el);\n out.push(el as T);\n }\n }\n }\n return out;\n }\n\n const roots = collectRoots(root);\n\n // No shadow roots below `root` → hand everything to the browser.\n if (roots.length === 1) {\n return Array.from(root.querySelectorAll<T>(selector));\n }\n\n const results: T[] = [];\n const seen = new Set<T>();\n\n for (const tokens of parts) {\n const last = tokens[tokens.length - 1];\n const { list, set, rootsWithHits } = collectCandidates<T>(roots, last);\n if (!list) continue;\n\n if (rootsWithHits === 1) {\n // All candidates live in a single root → its native order is composed order.\n for (const el of list) {\n if (seen.has(el)) continue;\n if (tokens.length === 1 || matchesComposedPath(el, tokens, root)) {\n seen.add(el);\n results.push(el);\n }\n }\n } else {\n // Candidates spread across roots → merge in composed tree order.\n const candidates = set ?? new Set(list);\n const all = collectAllElements(root);\n for (let i = 0; i < all.length; i++) {\n const el = all[i] as T;\n if (!candidates.has(el) || seen.has(el)) continue;\n if (tokens.length === 1 || matchesComposedPath(el, tokens, root)) {\n seen.add(el);\n results.push(el);\n }\n }\n }\n }\n return results;\n}\n\n/**\n * Finds all elements on the page, inclusive of those within shadow roots.\n * Optionally filtered by a CSS selector.\n * Same signature and semantics as the original library.\n */\nexport function collectAllElementsDeep<T extends Element = HTMLElement>(\n selector: string | null = null,\n root: QueryableNode = document,\n cachedElements: Element[] | null = null,\n): T[] {\n if (cachedElements) {\n const all = cachedElements as T[];\n return selector ? all.filter((el) => matchesSelector(el, selector)) : all;\n }\n\n // Single pass: elements are filtered while the tree is being walked.\n return collectAllElements(root, selector ?? undefined) as T[];\n}\n\n/**\n * Split a selector list on top-level commas (ignores commas inside quotes,\n * attribute brackets and pseudo-class parentheses).\n */\nexport function splitByComma(selector: string): string[] {\n if (!selector || !selector.trim()) return [];\n\n const results: string[] = [];\n let current = '';\n let parenDepth = 0;\n let bracketDepth = 0;\n let inSingleQuote = false;\n let inDoubleQuote = false;\n let escaped = false;\n\n for (let i = 0; i < selector.length; i++) {\n const char = selector[i];\n\n if (escaped) {\n current += char;\n escaped = false;\n continue;\n }\n\n if (char === '\\\\') {\n escaped = true;\n current += char;\n continue;\n }\n\n if (char === \"'\" && !inDoubleQuote) {\n inSingleQuote = !inSingleQuote;\n current += char;\n continue;\n }\n\n if (char === '\"' && !inSingleQuote) {\n inDoubleQuote = !inDoubleQuote;\n current += char;\n continue;\n }\n\n if (!inSingleQuote && !inDoubleQuote) {\n if (char === '(') parenDepth++;\n else if (char === ')') parenDepth = Math.max(0, parenDepth - 1);\n else if (char === '[') bracketDepth++;\n else if (char === ']') bracketDepth = Math.max(0, bracketDepth - 1);\n else if (char === ',' && parenDepth === 0 && bracketDepth === 0) {\n results.push(current.trim());\n current = '';\n continue;\n }\n }\n\n current += char;\n }\n\n if (current.trim()) {\n results.push(current.trim());\n }\n\n return results;\n}\n\n/**\n * Tokenize a CSS selector into compounds and combinators:\n * 'div > p span' → ['div', '>', 'p', ' ', 'span'].\n */\nexport function tokenizePath(selector: string): string[] {\n if (!selector || !selector.trim()) return [];\n\n const tokens: string[] = [];\n let current = '';\n let parenDepth = 0;\n let bracketDepth = 0;\n let inSingleQuote = false;\n let inDoubleQuote = false;\n let escaped = false;\n\n const pushCurrent = () => {\n const trimmed = current.trim();\n if (trimmed) {\n tokens.push(trimmed);\n }\n current = '';\n };\n\n for (let i = 0; i < selector.length; i++) {\n const char = selector[i];\n\n if (escaped) {\n current += char;\n escaped = false;\n continue;\n }\n\n if (char === '\\\\') {\n escaped = true;\n current += char;\n continue;\n }\n\n if (char === \"'\" && !inDoubleQuote) {\n inSingleQuote = !inSingleQuote;\n current += char;\n continue;\n }\n\n if (char === '\"' && !inSingleQuote) {\n inDoubleQuote = !inDoubleQuote;\n current += char;\n continue;\n }\n\n if (!inSingleQuote && !inDoubleQuote) {\n if (char === '(') parenDepth++;\n else if (char === ')') parenDepth = Math.max(0, parenDepth - 1);\n else if (char === '[') bracketDepth++;\n else if (char === ']') bracketDepth = Math.max(0, bracketDepth - 1);\n\n if (parenDepth === 0 && bracketDepth === 0) {\n if (char === '>' || char === '+' || char === '~') {\n pushCurrent();\n tokens.push(char);\n continue;\n }\n\n if (/\\s/.test(char)) {\n pushCurrent();\n\n while (i + 1 < selector.length && /\\s/.test(selector[i + 1])) {\n i++;\n }\n\n let nextChar = '';\n for (let j = i + 1; j < selector.length; j++) {\n if (!/\\s/.test(selector[j])) {\n nextChar = selector[j];\n break;\n }\n }\n\n const lastToken = tokens[tokens.length - 1];\n const isLastCombinator =\n lastToken === ' ' || lastToken === '>' || lastToken === '+' || lastToken === '~';\n\n if (\n tokens.length > 0 &&\n !isLastCombinator &&\n nextChar &&\n nextChar !== '>' &&\n nextChar !== '+' &&\n nextChar !== '~'\n ) {\n tokens.push(' ');\n }\n continue;\n }\n }\n }\n\n current += char;\n }\n\n pushCurrent();\n\n return tokens;\n}\n"],
|
|
5
|
+
"mappings": "8PA2BA,SAASA,EAAcC,EAAa,CAChC,MAAO,CAAC,CAACA,GAASA,EAAc,WAAa,CACjD,CAGA,SAASC,EAAiBD,EAAa,CACnC,MACI,CAAC,CAACA,GACDA,EAAc,WAAa,IAC5B,CAAC,CAAEA,EAAoB,IAE/B,CAGA,SAASE,EAAgBC,EAAaC,EAAgB,CAClD,GAAI,CACA,OAAOD,EAAG,QAAQC,CAAQ,CAC9B,MAAQ,CACJ,MAAO,EACX,CACJ,CAOA,SAASC,EAAeF,EAAaG,EAAuB,CACxD,GAAIH,IAAOG,EAAU,OAAO,KAC5B,MAAMC,EAASJ,EAAG,cAClB,GAAII,EAAQ,OAAOA,EACnB,MAAMC,EAAWL,EAAG,YAAW,EAC/B,OAAIK,IAAaL,GAAMK,IAAaF,EAAiB,KACjDL,EAAiBO,CAAQ,EAAUA,EAAS,KACzC,IACX,CAOA,SAASC,EAAoBN,EAAaO,EAAkBJ,EAAuB,CAC/E,IAAIN,EAAuBG,EACvB,EAAIO,EAAO,OAAS,EAExB,KAAO,EAAI,GAAKV,GAAM,CAClB,MAAMW,EAAaD,EAAO,EAAI,CAAC,EACzBN,EAAWM,EAAO,EAAI,CAAC,EAE7B,GAAIC,IAAe,KAEf,GADAX,EAAOK,EAAeL,EAAMM,CAAQ,EAChC,CAACN,GAAQ,CAACE,EAAgBF,EAAMI,CAAQ,EAAG,MAAO,WAC/CO,IAAe,KAEtB,GADAX,EAAOA,EAAK,uBACR,CAACA,GAAQ,CAACE,EAAgBF,EAAMI,CAAQ,EAAG,MAAO,WAC/CO,IAAe,IAAK,CAC3BX,E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ACX,QACJ,CAEA,GAAI,CAACH,GAAiB,CAACC,IACfE,IAAS,IAAKL,IACTK,IAAS,IAAKL,EAAa,KAAK,IAAI,EAAGA,EAAa,CAAC,EACrDK,IAAS,IAAKJ,IACdI,IAAS,MAAKJ,EAAe,KAAK,IAAI,EAAGA,EAAe,CAAC,GAE9DD,IAAe,GAAKC,IAAiB,GAAG,CACxC,GAAII,IAAS,KAAOA,IAAS,KAAOA,IAAS,IAAK,CAC9CC,EAAW,EACXpD,EAAO,KAAKmD,CAAI,EAChB,QACJ,CAEA,GAAI,KAAK,KAAKA,CAAI,EAAG,CAGjB,IAFAC,EAAW,EAEJ3C,EAAI,EAAIe,EAAS,QAAU,KAAK,KAAKA,EAASf,EAAI,CAAC,CAAC,GACvDA,IAGJ,IAAI6C,EAAW,GACf,QAASC,EAAI9C,EAAI,EAAG8C,EAAI/B,EAAS,OAAQ+B,IACrC,GAAI,CAAC,KAAK,KAAK/B,EAAS+B,CAAC,CAAC,EAAG,CACzBD,EAAW9B,EAAS+B,CAAC,EACrB,KACJ,CAGJ,MAAMC,EAAYxD,EAAOA,EAAO,OAAS,CAAC,EACpCyD,EACFD,IAAc,KAAOA,IAAc,KAAOA,IAAc,KAAOA,IAAc,IAG7ExD,EAAO,OAAS,GAChB,CAACyD,GACDH,GACAA,IAAa,KACbA,IAAa,KACbA,IAAa,KAEbtD,EAAO,KAAK,GAAG,EAEnB,QACJ,CACJ,CAGJ6C,GAAWM,CACf,CAEA,OAAAC,EAAW,EAEJpD,CACX",
|
|
6
|
+
"names": ["isElementNode", "node", "isHostedFragment", "matchesSelector", "el", "compound", "composedParent", "boundary", "parent", "rootNode", "matchesComposedPath", "tokens", "combinator", "found", "collectRoots", "root", "roots", "pending", "scope", "all", "i", "shadowRoot", "collectAllElements", "filter", "out", "collectInto", "collectList", "list", "iterateDeep", "stack", "pushChildren", "kids", "PARSE_CACHE_LIMIT", "parseCache", "parseSelector", "selector", "cached", "parts", "part", "splitByComma", "tokenizePath", "collectCandidates", "rightMostCompound", "set", "rootsWithHits", "querySelectorDeep", "allElements", "lightElement", "last", "verified", "candidates", "querySelectorAllDeep", "seen", "results", "collectAllElementsDeep", "cachedElements", "current", "parenDepth", "bracketDepth", "inSingleQuote", "inDoubleQuote", "escaped", "char", "pushCurrent", "trimmed", "nextChar", "j", "lastToken", "isLastCombinator"]
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "query-selector-shadow-dom-modern",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Modern drop-in replacement for query-selector-shadow-dom — querySelector that pierces Shadow DOM roots without knowing the path",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "dist/umd/index.
|
|
6
|
+
"main": "dist/umd/index.cjs",
|
|
7
7
|
"module": "dist/esm/index.js",
|
|
8
8
|
"types": "dist/esm/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/esm/index.d.ts",
|
|
12
12
|
"import": "./dist/esm/index.js",
|
|
13
|
-
"require": "./dist/umd/index.
|
|
13
|
+
"require": "./dist/umd/index.cjs"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
@@ -28,23 +28,33 @@
|
|
|
28
28
|
"testing"
|
|
29
29
|
],
|
|
30
30
|
"license": "MIT",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/kaixinol/query-selector-shadow-dom-modern.git"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/kaixinol/query-selector-shadow-dom-modern/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/kaixinol/query-selector-shadow-dom-modern#readme",
|
|
31
39
|
"devDependencies": {
|
|
32
40
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
33
41
|
"@types/jsdom": "^30.0.0",
|
|
34
42
|
"@types/node": "^26.1.1",
|
|
43
|
+
"esbuild": "^0.28.2",
|
|
35
44
|
"jsdom": "^30.0.1",
|
|
36
45
|
"playwright": "^1.62.0",
|
|
37
46
|
"query-selector-shadow-dom": "^1.0.1",
|
|
38
47
|
"rollup": "^4.34.8",
|
|
39
48
|
"tslib": "^2.8.1",
|
|
40
49
|
"tsx": "^4.23.1",
|
|
41
|
-
"typescript": "^
|
|
42
|
-
"vitest": "^
|
|
50
|
+
"typescript": "^6.0.3",
|
|
51
|
+
"vitest": "^5.0.0"
|
|
43
52
|
},
|
|
44
53
|
"scripts": {
|
|
45
54
|
"build:esm": "tsc -p tsconfig.json",
|
|
46
55
|
"build:umd": "rollup -c",
|
|
47
|
-
"build": "
|
|
56
|
+
"build:min": "esbuild dist/umd/index.js --minify --sourcemap --outfile=dist/umd/index.min.js",
|
|
57
|
+
"build": "pnpm build:esm && pnpm build:umd && pnpm build:min",
|
|
48
58
|
"test": "vitest run",
|
|
49
59
|
"test:watch": "vitest",
|
|
50
60
|
"benchmark": "tsx benchmark/runner.ts",
|