(node: Element | Document | ShadowRoot)
| 387 | let classObserver: MutationObserver | null = null; |
| 388 | |
| 389 | export function checkImageSelectors(node: Element | Document | ShadowRoot): void { |
| 390 | for (const [selector, callbacks] of imageSelectorQueue) { |
| 391 | if (node.querySelector(selector) || (node instanceof Element && node.matches(selector))) { |
| 392 | imageSelectorQueue.delete(selector); |
| 393 | callbacks.forEach((cb) => cb()); |
| 394 | } |
| 395 | } |
| 396 | if (!classObserver) { |
| 397 | classObserver = new MutationObserver((mutations) => { |
| 398 | mutations.forEach((mutation) => { |
| 399 | imageSelectorNodeQueue.add(mutation.target as Element); |
| 400 | if (!imageSelectorQueueFrameId) { |
| 401 | imageSelectorQueueFrameId = requestAnimationFrame(() => { |
| 402 | imageSelectorNodeQueue.forEach((element) => { |
| 403 | checkImageSelectors(element); |
| 404 | }); |
| 405 | imageSelectorNodeQueue.clear(); |
| 406 | imageSelectorQueueFrameId = null; |
| 407 | }); |
| 408 | } |
| 409 | }); |
| 410 | }); |
| 411 | classObserver.observe(document.documentElement, {attributes: true, attributeFilter: ['class'], subtree: true}); |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | export function getBgImageModifier( |
| 416 | value: string, |
no test coverage detected