mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-20 10:47:35 -05:00
18 lines
534 B
JavaScript
18 lines
534 B
JavaScript
import TYPES from "./types.js";
|
|
|
|
const waitForIt = [];
|
|
|
|
for (const [TYPE] of TYPES) {
|
|
const selectors = [`script[type="${TYPE}"]`, `${TYPE}-script`];
|
|
for (const element of document.querySelectorAll(selectors.join(","))) {
|
|
const { promise, resolve } = Promise.withResolvers();
|
|
waitForIt.push(promise);
|
|
element.addEventListener(`${TYPE}:done`, resolve, { once: true });
|
|
}
|
|
}
|
|
|
|
// wait for all the things then cleanup
|
|
Promise.all(waitForIt).then(() => {
|
|
dispatchEvent(new Event("py:all-done"));
|
|
});
|