@@ -286,12 +286,16 @@ class Injected {
286
286
// and only force layout during actual rafs as a small optimisation.
287
287
if ( ++ counter === 1 )
288
288
return false ;
289
+ if ( ! node . isConnected )
290
+ return 'Element is not attached to the DOM' ;
289
291
const clientRect = element . getBoundingClientRect ( ) ;
290
292
const rect = { x : clientRect . top , y : clientRect . left , width : clientRect . width , height : clientRect . height } ;
291
293
const isDisplayedAndStable = lastRect && rect . x === lastRect . x && rect . y === lastRect . y && rect . width === lastRect . width && rect . height === lastRect . height && rect . width > 0 && rect . height > 0 ;
292
294
lastRect = rect ;
293
295
return isDisplayedAndStable ;
294
296
} ) ;
297
+ if ( typeof result === 'string' )
298
+ throw new Error ( result ) ;
295
299
if ( ! result )
296
300
throw new Error ( `waiting for element to be displayed and not moving failed: timeout exceeded` ) ;
297
301
}
@@ -303,11 +307,15 @@ class Injected {
303
307
if ( ! element )
304
308
throw new Error ( 'Element is not attached to the DOM' ) ;
305
309
const result = await this . poll ( 'raf' , timeout , ( ) => {
310
+ if ( ! element ! . isConnected )
311
+ return 'Element is not attached to the DOM' ;
306
312
let hitElement = this . _deepElementFromPoint ( document , point . x , point . y ) ;
307
313
while ( hitElement && hitElement !== element )
308
314
hitElement = this . _parentElementOrShadowHost ( hitElement ) ;
309
315
return hitElement === element ;
310
316
} ) ;
317
+ if ( typeof result === 'string' )
318
+ throw new Error ( result ) ;
311
319
if ( ! result )
312
320
throw new Error ( `waiting for element to receive mouse events failed: timeout exceeded` ) ;
313
321
}
0 commit comments