File tree 3 files changed +6
-48
lines changed
3 files changed +6
-48
lines changed Original file line number Diff line number Diff line change 8
8
9
9
import { FocusTrapInertStrategy } from './focus-trap-inert-strategy' ;
10
10
import { ConfigurableFocusTrap } from './configurable-focus-trap' ;
11
- import { closest } from './polyfill' ;
12
11
13
12
/**
14
13
* Lightweight FocusTrapInertStrategy that adds a document focus event
@@ -53,7 +52,8 @@ export class EventListenerFocusTrapInertStrategy implements FocusTrapInertStrate
53
52
54
53
// Don't refocus if target was in an overlay, because the overlay might be associated
55
54
// with an element inside the FocusTrap, ex. mat-select.
56
- if ( ! focusTrapRoot . contains ( target ) && closest ( target , 'div.cdk-overlay-pane' ) === null ) {
55
+ if ( target && ! focusTrapRoot . contains ( target ) &&
56
+ target . closest ( 'div.cdk-overlay-pane' ) === null ) {
57
57
// Some legacy FocusTrap usages have logic that focuses some element on the page
58
58
// just before FocusTrap is destroyed. For backwards compatibility, wait
59
59
// to be sure FocusTrap is still enabled before refocusing.
Original file line number Diff line number Diff line change @@ -271,12 +271,10 @@ export class FocusTrap {
271
271
return root ;
272
272
}
273
273
274
- // Iterate in DOM order. Note that IE doesn't have `children` for SVG so we fall
275
- // back to `childNodes` which includes text nodes, comments etc.
276
- let children = root . children || root . childNodes ;
274
+ const children = root . children ;
277
275
278
276
for ( let i = 0 ; i < children . length ; i ++ ) {
279
- let tabbableChild = children [ i ] . nodeType === this . _document . ELEMENT_NODE ?
277
+ const tabbableChild = children [ i ] . nodeType === this . _document . ELEMENT_NODE ?
280
278
this . _getFirstTabbableElement ( children [ i ] as HTMLElement ) :
281
279
null ;
282
280
@@ -295,10 +293,10 @@ export class FocusTrap {
295
293
}
296
294
297
295
// Iterate in reverse DOM order.
298
- let children = root . children || root . childNodes ;
296
+ const children = root . children ;
299
297
300
298
for ( let i = children . length - 1 ; i >= 0 ; i -- ) {
301
- let tabbableChild = children [ i ] . nodeType === this . _document . ELEMENT_NODE ?
299
+ const tabbableChild = children [ i ] . nodeType === this . _document . ELEMENT_NODE ?
302
300
this . _getLastTabbableElement ( children [ i ] as HTMLElement ) :
303
301
null ;
304
302
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments