From 8b2ae0d8aab6d348a2e2ca947c7625b57abbd368 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Mon, 6 Mar 2017 18:24:48 +0100 Subject: [PATCH] fix(focus-trap): avoid closure compiler issues when adding anchors (#3448) --- src/lib/core/a11y/focus-trap.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/lib/core/a11y/focus-trap.ts b/src/lib/core/a11y/focus-trap.ts index 7bdbd42f557..c2d4c95b2d5 100644 --- a/src/lib/core/a11y/focus-trap.ts +++ b/src/lib/core/a11y/focus-trap.ts @@ -72,13 +72,11 @@ export class FocusTrap { } this._ngZone.runOutsideAngular(() => { - this._element - .insertAdjacentElement('beforebegin', this._startAnchor) - .addEventListener('focus', () => this.focusLastTabbableElement()); + this._startAnchor.addEventListener('focus', () => this.focusLastTabbableElement()); + this._endAnchor.addEventListener('focus', () => this.focusFirstTabbableElement()); - this._element - .insertAdjacentElement('afterend', this._endAnchor) - .addEventListener('focus', () => this.focusFirstTabbableElement()); + this._element.parentNode.insertBefore(this._startAnchor, this._element); + this._element.parentNode.insertBefore(this._endAnchor, this._element.nextSibling); }); }