Skip to content

Commit 9d8b51e

Browse files
committed
Mixed minor merge conflict
2 parents 5a8850c + 6abf62e commit 9d8b51e

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

src/vdom.rs

+8-17
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use next_tick::NextTick;
99
use std::{
1010
cell::RefCell,
1111
collections::{vec_deque::VecDeque, HashMap},
12-
panic,
1312
rc::Rc,
1413
};
1514
use wasm_bindgen::closure::Closure;
@@ -172,18 +171,11 @@ pub trait MountPoint {
172171

173172
impl MountPoint for &str {
174173
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+
))
187179
}
188180
}
189181

@@ -272,6 +264,9 @@ impl<Ms, Mdl, ElC: ElContainer<Ms> + 'static> App<Ms, Mdl, ElC> {
272264
update: UpdateFn<Ms, Mdl>,
273265
view: ViewFn<Mdl, ElC>,
274266
) -> AppBuilder<Ms, Mdl, ElC> {
267+
// Allows panic messages to output to the browser console.error.
268+
console_error_panic_hook::set_once();
269+
275270
AppBuilder {
276271
model,
277272
update,
@@ -361,10 +356,6 @@ impl<Ms, Mdl, ElC: ElContainer<Ms> + 'static> App<Ms, Mdl, ElC> {
361356
);
362357
routing::setup_link_listener(enclose!((self => s) move |msg| s.update(msg)), routes);
363358
}
364-
365-
// Allows panic messages to output to the browser console.error.
366-
panic::set_hook(Box::new(console_error_panic_hook::hook));
367-
368359
self
369360
}
370361

0 commit comments

Comments
 (0)