@@ -9,7 +9,6 @@ use next_tick::NextTick;
9
9
use std:: {
10
10
cell:: RefCell ,
11
11
collections:: { vec_deque:: VecDeque , HashMap } ,
12
- panic,
13
12
rc:: Rc ,
14
13
} ;
15
14
use wasm_bindgen:: closure:: Closure ;
@@ -172,18 +171,11 @@ pub trait MountPoint {
172
171
173
172
impl MountPoint for & str {
174
173
fn element ( self ) -> Element {
175
- // We log an error instead of relying on panic/except due to the panic hook not yet
176
- // being active.
177
- util:: document ( ) . get_element_by_id ( self ) . unwrap_or_else ( || {
178
- let text = format ! (
179
- concat!(
180
- "Can't find parent div with id={:?} (defaults to \" app\" , or can be set with the .mount() method)" ,
181
- ) ,
182
- self ,
183
- ) ;
184
- crate :: error ( & text) ;
185
- panic ! ( text) ;
186
- } )
174
+ util:: document ( ) . get_element_by_id ( self ) . expect ( & format ! (
175
+ "Can't find element with id={:?} - app cannot be mounted!\n \
176
+ (Id defaults to \" app\" , or can be set with the .mount() method)",
177
+ self
178
+ ) )
187
179
}
188
180
}
189
181
@@ -272,6 +264,9 @@ impl<Ms, Mdl, ElC: ElContainer<Ms> + 'static> App<Ms, Mdl, ElC> {
272
264
update : UpdateFn < Ms , Mdl > ,
273
265
view : ViewFn < Mdl , ElC > ,
274
266
) -> AppBuilder < Ms , Mdl , ElC > {
267
+ // Allows panic messages to output to the browser console.error.
268
+ console_error_panic_hook:: set_once ( ) ;
269
+
275
270
AppBuilder {
276
271
model,
277
272
update,
@@ -361,10 +356,6 @@ impl<Ms, Mdl, ElC: ElContainer<Ms> + 'static> App<Ms, Mdl, ElC> {
361
356
) ;
362
357
routing:: setup_link_listener ( enclose ! ( ( self => s) move |msg| s. update( msg) ) , routes) ;
363
358
}
364
-
365
- // Allows panic messages to output to the browser console.error.
366
- panic:: set_hook ( Box :: new ( console_error_panic_hook:: hook) ) ;
367
-
368
359
self
369
360
}
370
361
0 commit comments