16 lines
320 B
JavaScript
16 lines
320 B
JavaScript
// src/internal/event.ts
|
|
function waitForEvent(el, eventName) {
|
|
return new Promise((resolve) => {
|
|
function done(event) {
|
|
if (event.target === el) {
|
|
el.removeEventListener(eventName, done);
|
|
resolve();
|
|
}
|
|
}
|
|
el.addEventListener(eventName, done);
|
|
});
|
|
}
|
|
|
|
export {
|
|
waitForEvent
|
|
};
|