Fullscreen-API-Polyfill icon indicating copy to clipboard operation
Fullscreen-API-Polyfill copied to clipboard

promise always pending, never update it's status

Open alonesuperman opened this issue 7 years ago • 2 comments

chorme 69

I think maybe you forgot to register the event of w3.events.change. Because I can see only "dispatch w3.events.change" but none of "addEventListener w3.events.change" in your source code.

My solution is modify your code as follow:

Modify your function which called resolver. Replace all "api.events" as "w3.events" under this function

function createResolver(method) {
    return function resolver(resolve, reject) {
        // Reject the promise if asked to exitFullscreen and there is no element currently in fullscreen
        if (method === w3.exit && !doc[api.element]) {
            setTimeout(function () {
                reject(new TypeError());
            }, 1);
            return;
        }

        // When receiving an internal fullscreenchange event, fulfill the promise
        function change() {
            resolve();
            doc.removeEventListener(w3.events.change, change, false);
        }

        // When receiving an internal fullscreenerror event, reject the promise
        function error() {
            reject(new TypeError());
            doc.removeEventListener(w3.events.error, error, false);
        }

        doc.addEventListener(w3.events.change, change, false);
        doc.addEventListener(w3.events.error, error, false);
    };
}

alonesuperman avatar Sep 27 '18 05:09 alonesuperman

Same issue here 👍

Hoijof avatar Nov 19 '18 10:11 Hoijof

Same problem on safari 14.1.1 (OSX). The code above fixes it. 👍

uuf6429 avatar Sep 30 '21 17:09 uuf6429