Skip to content

Commit

Permalink
Return the native promise when it exists (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
stormtrooper1859 committed Feb 13, 2020
1 parent af4f50d commit 536595d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/screenfull.js
Expand Up @@ -88,7 +88,11 @@

element = element || document.documentElement;

Promise.resolve(element[fn.requestFullscreen]()).catch(reject);
var returnPromise = element[fn.requestFullscreen]();

if (returnPromise instanceof Promise) {
returnPromise.then(onFullScreenEntered).catch(reject);
}
}.bind(this));
},
exit: function () {
Expand All @@ -105,7 +109,11 @@

this.on('change', onFullScreenExit);

Promise.resolve(document[fn.exitFullscreen]()).catch(reject);
var returnPromise = document[fn.exitFullscreen]();

if (returnPromise instanceof Promise) {
returnPromise.then(onFullScreenExit).catch(reject);
}
}.bind(this));
},
toggle: function (element) {
Expand Down

0 comments on commit 536595d

Please sign in to comment.