@asamuzakjp/dom-selector 7.0.7 → 7.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +12 -23
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -130,10 +130,8 @@ export class DOMSelector {
|
|
|
130
130
|
node.parentNode
|
|
131
131
|
) {
|
|
132
132
|
const cacheKey = `check_${selector}`;
|
|
133
|
-
let filterMatches =
|
|
134
|
-
if (
|
|
135
|
-
filterMatches = this.#cache.get(cacheKey);
|
|
136
|
-
} else {
|
|
133
|
+
let filterMatches = this.#cache.get(cacheKey);
|
|
134
|
+
if (filterMatches === undefined) {
|
|
137
135
|
filterMatches = filterSelector(selector, TARGET_SELF);
|
|
138
136
|
this.#cache.set(cacheKey, filterMatches);
|
|
139
137
|
}
|
|
@@ -144,9 +142,8 @@ export class DOMSelector {
|
|
|
144
142
|
let ast = null;
|
|
145
143
|
if (match) {
|
|
146
144
|
const astCacheKey = `check_ast_${selector}`;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
} else {
|
|
145
|
+
ast = this.#cache.get(astCacheKey);
|
|
146
|
+
if (ast === undefined) {
|
|
150
147
|
ast = this.#finder.getAST(selector);
|
|
151
148
|
this.#cache.set(astCacheKey, ast);
|
|
152
149
|
}
|
|
@@ -193,10 +190,8 @@ export class DOMSelector {
|
|
|
193
190
|
node.parentNode
|
|
194
191
|
) {
|
|
195
192
|
const cacheKey = `matches_${selector}`;
|
|
196
|
-
let filterMatches =
|
|
197
|
-
if (
|
|
198
|
-
filterMatches = this.#cache.get(cacheKey);
|
|
199
|
-
} else {
|
|
193
|
+
let filterMatches = this.#cache.get(cacheKey);
|
|
194
|
+
if (filterMatches === undefined) {
|
|
200
195
|
filterMatches = filterSelector(selector, TARGET_SELF);
|
|
201
196
|
this.#cache.set(cacheKey, filterMatches);
|
|
202
197
|
}
|
|
@@ -245,10 +240,8 @@ export class DOMSelector {
|
|
|
245
240
|
node.parentNode
|
|
246
241
|
) {
|
|
247
242
|
const cacheKey = `closest_${selector}`;
|
|
248
|
-
let filterMatches =
|
|
249
|
-
if (
|
|
250
|
-
filterMatches = this.#cache.get(cacheKey);
|
|
251
|
-
} else {
|
|
243
|
+
let filterMatches = this.#cache.get(cacheKey);
|
|
244
|
+
if (filterMatches === undefined) {
|
|
252
245
|
filterMatches = filterSelector(selector, TARGET_LINEAL);
|
|
253
246
|
this.#cache.set(cacheKey, filterMatches);
|
|
254
247
|
}
|
|
@@ -304,10 +297,8 @@ export class DOMSelector {
|
|
|
304
297
|
(node.nodeType !== DOCUMENT_FRAGMENT_NODE || !node.host)
|
|
305
298
|
) {
|
|
306
299
|
const cacheKey = `querySelector_${selector}`;
|
|
307
|
-
let filterMatches =
|
|
308
|
-
if (
|
|
309
|
-
filterMatches = this.#cache.get(cacheKey);
|
|
310
|
-
} else {
|
|
300
|
+
let filterMatches = this.#cache.get(cacheKey);
|
|
301
|
+
if (filterMatches === undefined) {
|
|
311
302
|
filterMatches = filterSelector(selector, TARGET_FIRST);
|
|
312
303
|
this.#cache.set(cacheKey, filterMatches);
|
|
313
304
|
}
|
|
@@ -357,10 +348,8 @@ export class DOMSelector {
|
|
|
357
348
|
(node.nodeType !== DOCUMENT_FRAGMENT_NODE || !node.host)
|
|
358
349
|
) {
|
|
359
350
|
const cacheKey = `querySelectorAll_${selector}`;
|
|
360
|
-
let filterMatches =
|
|
361
|
-
if (
|
|
362
|
-
filterMatches = this.#cache.get(cacheKey);
|
|
363
|
-
} else {
|
|
351
|
+
let filterMatches = this.#cache.get(cacheKey);
|
|
352
|
+
if (filterMatches === undefined) {
|
|
364
353
|
filterMatches = filterSelector(selector, TARGET_ALL);
|
|
365
354
|
this.#cache.set(cacheKey, filterMatches);
|
|
366
355
|
}
|