Removing code that is not needed

It seems none of this was needed.

eventHandlers: {}

    function getIframe(player) {
        return Object.values(player).find(
            (item) => item.nodeName === "IFRAME"
        );
    }
        const iframe = getIframe(player);
        iframe.dispatchEvent(new Event("afterPlayerReady"));
        const iframe = getIframe(player);
        const eventHandler = config.eventHandlers.afterPlayerReady;
        iframe.addEventListener("afterPlayerReady", eventHandler);

config.eventHandlers.afterPlayerReady = videoPlayer.afterPlayerReady;

Code works without it: https://jsfiddle.net/2w19gmjo/