File tree Expand file tree Collapse file tree 3 files changed +6
-48
lines changed Expand file tree Collapse file tree 3 files changed +6
-48
lines changed Original file line number Diff line number Diff line change 88
99import { FocusTrapInertStrategy } from './focus-trap-inert-strategy' ;
1010import { ConfigurableFocusTrap } from './configurable-focus-trap' ;
11- import { closest } from './polyfill' ;
1211
1312/**
1413 * Lightweight FocusTrapInertStrategy that adds a document focus event
@@ -53,7 +52,8 @@ export class EventListenerFocusTrapInertStrategy implements FocusTrapInertStrate
5352
5453 // Don't refocus if target was in an overlay, because the overlay might be associated
5554 // 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 ) {
5757 // Some legacy FocusTrap usages have logic that focuses some element on the page
5858 // just before FocusTrap is destroyed. For backwards compatibility, wait
5959 // 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 {
271271 return root ;
272272 }
273273
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 ;
277275
278276 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 ?
280278 this . _getFirstTabbableElement ( children [ i ] as HTMLElement ) :
281279 null ;
282280
@@ -295,10 +293,10 @@ export class FocusTrap {
295293 }
296294
297295 // Iterate in reverse DOM order.
298- let children = root . children || root . childNodes ;
296+ const children = root . children ;
299297
300298 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 ?
302300 this . _getLastTabbableElement ( children [ i ] as HTMLElement ) :
303301 null ;
304302
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments