File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,3 +37,7 @@ path = "../futures"
3737
3838[target .'cfg(target_os = "windows")' .dependencies .winapi ]
3939version = " 0.3.6"
40+
41+ [target .'cfg(target_arch = "wasm32")' .dependencies .web-sys ]
42+ version = " 0.3"
43+ features = [" Document" , " Window" ]
Original file line number Diff line number Diff line change @@ -148,6 +148,21 @@ where
148148 . build ( & event_loop)
149149 . map_err ( Error :: WindowCreationFailed ) ?;
150150
151+ #[ cfg( target_arch = "wasm32" ) ]
152+ {
153+ use winit:: platform:: web:: WindowExtWebSys ;
154+
155+ let canvas = window. canvas ( ) ;
156+
157+ let window = web_sys:: window ( ) . unwrap ( ) ;
158+ let document = window. document ( ) . unwrap ( ) ;
159+ let body = document. body ( ) . unwrap ( ) ;
160+
161+ let _ = body
162+ . append_child ( & canvas)
163+ . expect ( "Append canvas to HTML body" ) ;
164+ }
165+
151166 let mut clipboard = Clipboard :: connect ( & window) ;
152167
153168 run_command (
You can’t perform that action at this time.
0 commit comments