File tree 1 file changed +6
-3
lines changed
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,10 @@ export class FocusTrap {
27
27
get enabled ( ) : boolean { return this . _enabled ; }
28
28
set enabled ( val : boolean ) {
29
29
this . _enabled = val ;
30
- this . _startAnchor . tabIndex = this . _endAnchor . tabIndex = this . _enabled ? 0 : - 1 ;
30
+
31
+ if ( this . _startAnchor && this . _endAnchor ) {
32
+ this . _startAnchor . tabIndex = this . _endAnchor . tabIndex = this . _enabled ? 0 : - 1 ;
33
+ }
31
34
}
32
35
private _enabled : boolean = true ;
33
36
@@ -44,11 +47,11 @@ export class FocusTrap {
44
47
45
48
/** Destroys the focus trap by cleaning up the anchors. */
46
49
destroy ( ) {
47
- if ( this . _startAnchor . parentNode ) {
50
+ if ( this . _startAnchor && this . _startAnchor . parentNode ) {
48
51
this . _startAnchor . parentNode . removeChild ( this . _startAnchor ) ;
49
52
}
50
53
51
- if ( this . _endAnchor . parentNode ) {
54
+ if ( this . _endAnchor && this . _endAnchor . parentNode ) {
52
55
this . _endAnchor . parentNode . removeChild ( this . _endAnchor ) ;
53
56
}
54
57
You can’t perform that action at this time.
0 commit comments