Skip to content

Commit e82ff91

Browse files
authored
refactor(cdk/a11y): clean up IE workarounds (#23304)
Cleans up the workarounds for IE11 from the `cdk/a11y` package.
1 parent 8bd8f75 commit e82ff91

File tree

3 files changed

+6
-48
lines changed

3 files changed

+6
-48
lines changed

src/cdk/a11y/focus-trap/event-listener-inert-strategy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import {FocusTrapInertStrategy} from './focus-trap-inert-strategy';
1010
import {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.

src/cdk/a11y/focus-trap/focus-trap.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff 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

src/cdk/a11y/focus-trap/polyfill.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)