This repository was archived by the owner on Jan 19, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import {
1010 translate ,
1111 getWindowWidth ,
1212 getWindowHeight ,
13- isInIframe ,
13+ isInSameOriginIframe ,
1414 getIEVersion ,
1515} from './util' ;
1616import {
@@ -239,7 +239,7 @@ class ReactImageLightbox extends Component {
239239 window . addEventListener ( 'pointercancel' , this . handlePointerEvent ) ;
240240 // Have to add an extra mouseup handler to catch mouseup events outside of the window
241241 // if the page containing the lightbox is displayed in an iframe
242- if ( isInIframe ( ) ) {
242+ if ( isInSameOriginIframe ( ) ) {
243243 window . top . addEventListener ( 'mouseup' , this . handleMouseUp ) ;
244244 window . top . addEventListener ( 'touchend' , this . handleTouchEnd ) ;
245245 window . top . addEventListener ( 'touchcancel' , this . handleTouchEnd ) ;
@@ -351,7 +351,7 @@ class ReactImageLightbox extends Component {
351351 window . removeEventListener ( 'pointermove' , this . handlePointerEvent ) ;
352352 window . removeEventListener ( 'pointerup' , this . handlePointerEvent ) ;
353353 window . removeEventListener ( 'pointercancel' , this . handlePointerEvent ) ;
354- if ( isInIframe ( ) ) {
354+ if ( isInSameOriginIframe ( ) ) {
355355 window . top . removeEventListener ( 'mouseup' , this . handleMouseUp ) ;
356356 window . top . removeEventListener ( 'touchend' , this . handleTouchEnd ) ;
357357 window . top . removeEventListener ( 'touchcancel' , this . handleTouchEnd ) ;
Original file line number Diff line number Diff line change @@ -52,10 +52,11 @@ export function getWindowHeight() {
5252}
5353
5454// Returns true if this window is rendered as an iframe inside another window
55- export function isInIframe ( ) {
55+ // with the same origin.
56+ export function isInSameOriginIframe ( ) {
5657 try {
57- return window . self !== window . top ;
58+ return ( window . self !== window . top ) && window . top . document ;
5859 } catch ( e ) {
59- return true ;
60+ return false ;
6061 }
6162}
You can’t perform that action at this time.
0 commit comments