File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -150,10 +150,11 @@ export class Dialog extends dialogBaseClass {
150
150
private escapePressedWithoutCancel = false ;
151
151
// This TreeWalker is used to walk through a dialog's children to find
152
152
// focusable elements. TreeWalker is faster than `querySelectorAll('*')`.
153
- private readonly treewalker = document . createTreeWalker (
154
- this ,
155
- NodeFilter . SHOW_ELEMENT ,
156
- ) ;
153
+ // We check for isServer because there isn't a "document" during an SSR
154
+ // run.
155
+ private readonly treewalker = isServer
156
+ ? null
157
+ : document . createTreeWalker ( this , NodeFilter . SHOW_ELEMENT ) ;
157
158
158
159
constructor ( ) {
159
160
super ( ) ;
@@ -559,7 +560,13 @@ export class Dialog extends dialogBaseClass {
559
560
// won't actually reach here.
560
561
}
561
562
562
- private getFirstAndLastFocusableChildren ( ) {
563
+ private getFirstAndLastFocusableChildren ( ) :
564
+ | [ HTMLElement , HTMLElement ]
565
+ | [ null , null ] {
566
+ if ( ! this . treewalker ) {
567
+ return [ null , null ] ;
568
+ }
569
+
563
570
let firstFocusableChild : HTMLElement | null = null ;
564
571
let lastFocusableChild : HTMLElement | null = null ;
565
572
You can’t perform that action at this time.
0 commit comments