Skip to content

Commit 8b2ae0d

Browse files
crisbetokara
authored andcommitted
fix(focus-trap): avoid closure compiler issues when adding anchors (#3448)
1 parent 02f4bc3 commit 8b2ae0d

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/lib/core/a11y/focus-trap.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,11 @@ export class FocusTrap {
7272
}
7373

7474
this._ngZone.runOutsideAngular(() => {
75-
this._element
76-
.insertAdjacentElement('beforebegin', this._startAnchor)
77-
.addEventListener('focus', () => this.focusLastTabbableElement());
75+
this._startAnchor.addEventListener('focus', () => this.focusLastTabbableElement());
76+
this._endAnchor.addEventListener('focus', () => this.focusFirstTabbableElement());
7877

79-
this._element
80-
.insertAdjacentElement('afterend', this._endAnchor)
81-
.addEventListener('focus', () => this.focusFirstTabbableElement());
78+
this._element.parentNode.insertBefore(this._startAnchor, this._element);
79+
this._element.parentNode.insertBefore(this._endAnchor, this._element.nextSibling);
8280
});
8381
}
8482

0 commit comments

Comments
 (0)