mirror of
https://github.com/pyscript/pyscript.git
synced 2026-02-23 17:10:28 -05:00
* Added polyscript/service-worker as workaround for missing sabayon * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * updated polyscript to its latest * Updated polyscript one mor time --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
19 lines
591 B
JavaScript
19 lines
591 B
JavaScript
import withResolvers from "@webreflection/utils/with-resolvers";
|
|
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 } = 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"));
|
|
});
|