File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -20,8 +20,8 @@ import {coerceBooleanProperty} from '../coercion/boolean-property';
20
20
* This will be replaced with a more intelligent solution before the library is considered stable.
21
21
*/
22
22
export class FocusTrap {
23
- private _startAnchor : HTMLElement = this . _createAnchor ( ) ;
24
- private _endAnchor : HTMLElement = this . _createAnchor ( ) ;
23
+ private _startAnchor : HTMLElement ;
24
+ private _endAnchor : HTMLElement ;
25
25
26
26
/** Whether the focus trap is active. */
27
27
get enabled ( ) : boolean { return this . _enabled ; }
@@ -60,6 +60,14 @@ export class FocusTrap {
60
60
* in the constructor, but can be deferred for cases like directives with `*ngIf`.
61
61
*/
62
62
attachAnchors ( ) : void {
63
+ if ( ! this . _startAnchor ) {
64
+ this . _startAnchor = this . _createAnchor ( ) ;
65
+ }
66
+
67
+ if ( ! this . _endAnchor ) {
68
+ this . _endAnchor = this . _createAnchor ( ) ;
69
+ }
70
+
63
71
this . _ngZone . runOutsideAngular ( ( ) => {
64
72
this . _element
65
73
. insertAdjacentElement ( 'beforebegin' , this . _startAnchor )
You can’t perform that action at this time.
0 commit comments