@blackglory/wait-for
Version:
A module for waiting for things to happen.
12 lines • 572 B
JavaScript
import { observeRemovalOfDescendantNodes } from '@blackglory/observe';
import { firstValueFrom } from 'rxjs';
import { filter } from 'rxjs/operators';
export async function waitForAllElementsMatchingSelectorDetached(selector) {
if (countElements(selector) === 0)
return;
await firstValueFrom(observeRemovalOfDescendantNodes(document).pipe(filter(() => countElements(selector) === 0)));
}
function countElements(selector) {
return document.querySelectorAll(selector).length;
}
//# sourceMappingURL=wait-for-all-elements-matching-selector-detached.js.map