11/*!
2- * Viewer.js v1.10.4
2+ * Viewer.js v1.10.5
33 * https://fengyuanchen.github.io/viewerjs
44 *
55 * Copyright 2015-present Chen Fengyuan
66 * Released under the MIT license
77 *
8- * Date: 2022-02-13T08:40:00.127Z
8+ * Date: 2022-04-05T08:21:02.491Z
99 */
1010
1111function ownKeys ( object , enumerableOnly ) {
@@ -3038,10 +3038,20 @@ var others = {
30383038 var viewer = _this . viewer ;
30393039 var target = event . target ;
30403040
3041- if ( target !== document && target !== viewer && ! viewer . contains ( target ) // Avoid conflicts with other modals (#474)
3042- && ( target . getAttribute ( 'tabindex' ) === null || target . getAttribute ( 'aria-modal' ) !== 'true' ) ) {
3043- viewer . focus ( ) ;
3041+ if ( target === document || target === viewer || viewer . contains ( target ) ) {
3042+ return ;
3043+ }
3044+
3045+ while ( target ) {
3046+ // Avoid conflicts with other modals (#474, #540)
3047+ if ( target . getAttribute ( 'tabindex' ) !== null || target . getAttribute ( 'aria-modal' ) === 'true' ) {
3048+ return ;
3049+ }
3050+
3051+ target = target . parentElement ;
30443052 }
3053+
3054+ viewer . focus ( ) ;
30453055 } ) ;
30463056 } ,
30473057 clearEnforceFocus : function clearEnforceFocus ( ) {
@@ -3338,6 +3348,7 @@ var Viewer = /*#__PURE__*/function () {
33383348 forEach ( images , function ( image ) {
33393349 if ( ! image . complete ) {
33403350 removeListener ( image , EVENT_LOAD , progress ) ;
3351+ removeListener ( image , EVENT_ERROR , progress ) ;
33413352 }
33423353 } ) ;
33433354 }
@@ -3346,7 +3357,18 @@ var Viewer = /*#__PURE__*/function () {
33463357 if ( image . complete ) {
33473358 progress ( ) ;
33483359 } else {
3349- addListener ( image , EVENT_LOAD , progress , {
3360+ var onLoad ;
3361+ var onError ;
3362+ addListener ( image , EVENT_LOAD , onLoad = function onLoad ( ) {
3363+ removeListener ( image , EVENT_ERROR , onError ) ;
3364+ progress ( ) ;
3365+ } , {
3366+ once : true
3367+ } ) ;
3368+ addListener ( image , EVENT_ERROR , onError = function onError ( ) {
3369+ removeListener ( image , EVENT_LOAD , onLoad ) ;
3370+ progress ( ) ;
3371+ } , {
33503372 once : true
33513373 } ) ;
33523374 }
0 commit comments