requestFullscreen is not returning a promise
https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen#Browser_compatibility
Unfortunately there's no browser support for the promise-returning version.
Sagiv b.g
I love Software development and learning new things each day. I share my learnings in debuggr.io
Updated on June 04, 2022Comments
-
Sagiv b.g almost 2 years
I'm facing an unexpected behavior and wanted to be sure i'm not missing something before i'm filling a bug.
I've played withrequestFullscreen
onchrome
andfirefox
and noticed it's not returning a promise like stated in the spec.Example for
webkit
:el.addEventListener('click', () => { const p = el.webkitRequestFullScreen(); p.then(() => {console.log('full screen')}); });
I'm getting:
Uncaught TypeError: Cannot read property 'then' of undefined at HTMLDivElement.el.addEventListener
Same goes for
firefox
:el.addEventListener('click', () => { const p = el.mozRequestFullScreen(); p.then(() => {console.log('full screen')}); });
TypeError: p is undefined
Am i reading the spec wrong? shouldn't i expect that promise?
-
Kaiido over 5 yearsAh... the [moz|webkit|o|ms]Full[s|S]creen API... That's just a mess. You shouldn't expect anything than nightmares trying to make a cross-browser code... But yes, according to specs that's what should be returned. But since nobody follows the specs there, we don't have it. FF has a 3 yo bug-report about it, currently P5... For their defense, they keep the prefixed version exactly because they don't follow the specs. On the other hand I couldn't find Chrome's discussion about it, and they did map to unprefixed method...
-
Sagiv b.g over 5 years@Kaiido thanks, been looking for that bug but had no luck finding it.
-
-
nh2 almost 5 yearsThese docs are currently wrong for Chrome. It says version 71 doesn't support the promise version, but it does. I've researched it: The change that added the promise-returning version to Chromium landed in Chromium 69.0.3446.0.