@@ -37,10 +37,26 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
37
37
] ;
38
38
39
39
this . modal . style . cssText = modalStyles . join ( ';' ) ;
40
- this . modal . innerHTML = '<h5 style="margin-top: 20px"></h5><button style="margin:5px auto 5px">Retry</button><p>Alternatively, <a href>reload</a></p>' ;
41
- this . message = this . modal . querySelector ( 'h5' ) ! ;
42
- this . button = this . modal . querySelector ( 'button' ) ! ;
43
- this . reloadParagraph = this . modal . querySelector ( 'p' ) ! ;
40
+
41
+ this . message = this . document . createElement ( 'h5' ) as HTMLHeadingElement ;
42
+ this . message . style . cssText = 'margin-top: 20px' ;
43
+
44
+ this . button = this . document . createElement ( 'button' ) as HTMLButtonElement ;
45
+ this . button . style . cssText = 'margin:5px auto 5px' ;
46
+ this . button . textContent = 'Retry' ;
47
+
48
+ const link = this . document . createElement ( 'a' ) ;
49
+ link . addEventListener ( 'click' , ( ) => location . reload ( ) ) ;
50
+ link . textContent = 'reload' ;
51
+
52
+ this . reloadParagraph = this . document . createElement ( 'p' ) as HTMLParagraphElement ;
53
+ this . reloadParagraph . textContent = 'Alternatively, ' ;
54
+ this . reloadParagraph . appendChild ( link ) ;
55
+
56
+ this . modal . appendChild ( this . message ) ;
57
+ this . modal . appendChild ( this . button ) ;
58
+ this . modal . appendChild ( this . reloadParagraph ) ;
59
+
44
60
this . loader = this . getLoader ( ) ;
45
61
46
62
this . message . after ( this . loader ) ;
@@ -63,7 +79,6 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
63
79
this . failed ( ) ;
64
80
}
65
81
} ) ;
66
- this . reloadParagraph . querySelector ( 'a' ) ! . addEventListener ( 'click' , ( ) => location . reload ( ) ) ;
67
82
}
68
83
69
84
show ( ) : void {
@@ -98,16 +113,36 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
98
113
this . button . style . display = 'block' ;
99
114
this . reloadParagraph . style . display = 'none' ;
100
115
this . loader . style . display = 'none' ;
101
- this . message . innerHTML = 'Reconnection failed. Try <a href>reloading</a> the page if you\'re unable to reconnect.' ;
102
- this . message . querySelector ( 'a' ) ! . addEventListener ( 'click' , ( ) => location . reload ( ) ) ;
116
+
117
+ const errorDescription = this . document . createElement ( 'span' ) ;
118
+ errorDescription . textContent = 'Reconnection failed. Try ' ;
119
+
120
+ const link = this . document . createElement ( 'a' ) ;
121
+ link . textContent = 'reloading' ;
122
+ link . addEventListener ( 'click' , ( ) => location . reload ( ) ) ;
123
+
124
+ const errorInstructions = this . document . createElement ( 'span' ) ;
125
+ errorInstructions . textContent = ' the page if you\'re unable to reconnect.' ;
126
+
127
+ this . message . replaceChildren ( errorDescription , link , errorInstructions ) ;
103
128
}
104
129
105
130
rejected ( ) : void {
106
131
this . button . style . display = 'none' ;
107
132
this . reloadParagraph . style . display = 'none' ;
108
133
this . loader . style . display = 'none' ;
109
- this . message . innerHTML = 'Could not reconnect to the server. <a href>Reload</a> the page to restore functionality.' ;
110
- this . message . querySelector ( 'a' ) ! . addEventListener ( 'click' , ( ) => location . reload ( ) ) ;
134
+
135
+ const errorDescription = this . document . createElement ( 'span' ) ;
136
+ errorDescription . textContent = 'Could not reconnect to the server. ' ;
137
+
138
+ const link = this . document . createElement ( 'a' ) ;
139
+ link . textContent = 'Reload' ;
140
+ link . addEventListener ( 'click' , ( ) => location . reload ( ) ) ;
141
+
142
+ const errorInstructions = this . document . createElement ( 'span' ) ;
143
+ errorInstructions . textContent = ' the page to restore functionality.' ;
144
+
145
+ this . message . replaceChildren ( errorDescription , link , errorInstructions ) ;
111
146
}
112
147
113
148
private getLoader ( ) : HTMLDivElement {
0 commit comments