From 5b22a88f3fd25ad9d3ec8f878f86d575d4f03544 Mon Sep 17 00:00:00 2001 From: crisbeto Date: Sun, 5 Mar 2017 22:10:38 +0100 Subject: [PATCH] fix(focus-trap): avoid closure compiler issues when adding anchors Switches away from using `insertAdjacentElement` when adding the anchor elements in the focus trap, in order to avoid issues with Closure compiler. --- 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 7bdbd42f5574..c2d4c95b2d5d 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); }); }