From 8a083d94735642911f4cf02aeb22a46f59203d71 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Fri, 28 Apr 2023 14:25:16 -0700 Subject: [PATCH] Nicer HTML It's easier with innerHTML rather than constructing DOM by hand. --- examples/with_winit/src/lib.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/examples/with_winit/src/lib.rs b/examples/with_winit/src/lib.rs index 3d6422d..ce95e82 100644 --- a/examples/with_winit/src/lib.rs +++ b/examples/with_winit/src/lib.rs @@ -459,14 +459,18 @@ fn display_error_message() -> Option<()> { let document = window.document()?; let elements = document.get_elements_by_tag_name("body"); let body = elements.item(0)?; - let canvas = body.first_child()?; - // TODO: style the notice at least a little, maybe link? - let text = document.create_text_node( - "WebGPU is not enabled. Make sure your browser is updated to - Chrome M113 or another browser compatible with WebGPU.", + body.set_inner_html( + r#" +

WebGPU + is not enabled. Make sure your browser is updated to + Chrome M113 or + another browser compatible with WebGPU.

"#, ); - let _ = body.insert_before(&text, Some(&canvas)); - web_sys::console::log_1(&"got body".into()); Some(()) }