File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed
Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 11/*!
22* screenfull
3- * v4.2.0 - 2019-04-01
3+ * v4.2.1 - 2019-07-27
44* (c) Sindre Sorhus; MIT License
55*/
66( function ( ) {
8484
8585 var screenfull = {
8686 request : function ( elem ) {
87- return new Promise ( function ( resolve ) {
87+ return new Promise ( function ( resolve , reject ) {
8888 var request = fn . requestFullscreen ;
8989
9090 var onFullScreenEntered = function ( ) {
9191 this . off ( 'change' , onFullScreenEntered ) ;
9292 resolve ( ) ;
9393 } . bind ( this ) ;
9494
95+ this . on ( 'change' , onFullScreenEntered ) ;
96+
9597 elem = elem || document . documentElement ;
9698
99+ var promise ;
100+
97101 // Work around Safari 5.1 bug: reports support for
98102 // keyboard in fullscreen even though it doesn't.
99103 // Browser sniffing, since the alternative with
100104 // setTimeout is even worse.
101105 if ( / V e r s i o n \/ 5 \. 1 (?: \. \d + ) ? S a f a r i \/ / . test ( navigator . userAgent ) ) {
102- elem [ request ] ( ) ;
106+ promise = elem [ request ] ( ) ;
103107 } else {
104- elem [ request ] ( keyboardAllowed ? Element . ALLOW_KEYBOARD_INPUT : { } ) ;
108+ promise = elem [ request ] ( keyboardAllowed ? Element . ALLOW_KEYBOARD_INPUT : { } ) ;
105109 }
106110
107- this . on ( 'change' , onFullScreenEntered ) ;
111+ Promise . resolve ( promise ) . catch ( reject ) ;
108112 } . bind ( this ) ) ;
109113 } ,
110114 exit : function ( ) {
You can’t perform that action at this time.
0 commit comments